Giter Club home page Giter Club logo

cognicity-grasp's Introduction

DEPRECATED

Build Status

CogniCity GRASP

Geosocial Rapid Assessment Platform

Introduction

cognicity-grasp is an extension to the CogniCity platform that adds support to collect disaster reports from residents using web-technologies. Users request a report card which is delivered in the form of a unique one time link pointing to a cognicity-server instance. The report card link is delivered by a simple conversational 'bot'. The bot can be included in cognicity-reports so that report cards can be delivered to users via social messaging or third-party application.

Key Files

  • Bot.js - GRASP module for user communication
  • ReportCard.js - GRASP module to create unique card link
  • App.js - Reference implementation
    • sample-grasp-config.js - Sample config for reference implementation
  • public/ - Folder containing web elements for card design

GRASP Process

  1. User input (e.g. via social messaging)
  2. Bot.js scans User input for keyword "report"
  3. Bot.js requests a report card from ReportCard.js
  4. ReportCard.js creates unique card link, writes this to CogniCity database, and passess to Bot.js
  5. Bot.js replies to User with unique card link
  6. User opens link, requesting card resources from an instance of CogniCity server
  7. Server uses local instance of ReportCard.js to validate unique card link against database
  • check card exists
  • check card not completed already
  1. Server responds to User with card resources
  2. User completes card, and sends response to server
  3. Server adds report card to map and responds to User with unique report link
  4. On update to reports table in CogniCity database, Bot.js responds to User thanking them, including unique report link for map

App.js

App.js is the reference implementation of CogniCity Grasp. It emulates user input from a reports module to generate a report card using Bot.js and ReportCard.js, and emulates server response for submission of the card by the user.

Dependencies

Stored in package.json, use:

npm install

Run App.js

$ node app.js
info: Application starting...
info: Bot requesting issue of card
info: Express listening
info: Issued card B1eYYW-R
Hi User, here is the link to your report card: http://localhost:3000/report/B1eYYW-R

$ curl http://localhost:3000/report/B1eYYW-R
Success - proceed with report

$ curl http://localhost:3000/report/ZZZ
Error - report card id invalid

ReportCard.js & Bot.js

ReportCard.js provides simple module for the creation, storage and validation of unique report card links.

Bot.js provides human-API endpoint to CogniCity Reports via keywords. Current keywords:

  • "reports" (case insensitive).

Bot.js requires an instance of ReportCard.js to issue report cards.

var ReportCard = require('ReportCard');
var Bot = require('Bot');

var report_card = new ReportCard(massive_database_object, winston_logger_object);
var bot = new Bot(config, report_card, winston_logger_object);

bot.parse(user_input, callback(err, response));

Bot.js Configuration

See sample-grasp-config.js

Schema

TO DO -> Move schema to /db?

Development

Unit tests

npm install --dev
npm test

Cards

Report card web elements are in the public/ folder. In the future, we'll use handlebars templates for multi-language support (see cards/).

cognicity-grasp's People

Contributors

abrahamq avatar abrahamqsdfadf avatar maanasapriyaa avatar matthewberryman avatar tomasholderness avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ziyuanshen

cognicity-grasp's Issues

Picture upload links might be issued from the server but not used by the client

Right now, the client asks the server for a signed url, the server (which has credentials)
asks s3 for a signed url where the client can PUT an image. There's a corner case where the
server asks for a signed url, but the client doesn't actually PUT the image (connection drops, user backs out, so on.)

Here's a fix: use the lambda code to touch our database after it does the compression so that it tells us that an image url is present.

13 Hazards Parameter

BNPB released regulation (no 2 year 2012) to standardise Indonesian hazards parameter. Please look into this link to see the original document.

*start from page 15 - table 1 on the document

Finding:

img_20161012_150637

Basically, the alert levels for all hazards described as:

  1. low (green)
  2. medium (yellow)
  3. tinggi (red)

The thresholds for each level in each hazards are referring to the national standards that are released by related agency (i.e extreme weather by BMKG, etc).
We will follow up to BNPB next week if there is any update on this regulation while we have a discussion with PDC as well.

cc @talltom @anexact @prittandrani @nashinmahtani @clgeros

Bot Language

Hi! We were discussing about the bot language, which is may be the best for the users if we provide Indonesian & English.

We were talking deeper about how the bot will determine the language to be used for the rest of the report, and come up to this idea that the bot will send the first message to request the user to choose the language, like in the screenshot here:

bot banjir flood

Any comments? :) @talltom @fadmastuti @anexact @nashinmahtani @clgeros

adding realtime rainfall graph

Hi @talltom , after our discussion with BMKG (Meteorological, Climatological and Geophysical Agency), they are agree to feed our map with the realtime rainfall data in mm/h. Can we show it on the map like the waterlevel or sensor data in a realtime graph per hour?

I have made the wiki page and added this on our list. Please check on this link .

BMKG also will provides us the location data of the rainfall station for Jabodetabek, Bandung, Surabaya. Can we integrate their .csv/.kml data (with a column for coordinates)?

cc @anexact

User input validation - need to build

As we are collecting data directly from users we need to add validation processes for report cards:

  1. Client side, how to inform user if input is incorrect (e.g. report length too long?)
  2. Server side, how to catch malformed input data from report cards (e.g. null geolocation etc)

Agree Report Card Data Fields

Suggested fields:

  • card_id
  • created_at (ISO 8601 timestamp with timezone from user device)
  • text (UTF8 @ 140 chars)
  • water_depth
  • image (optional)
  • location (GeoJson (point))

Test values set in 'before' not always updated

Setting global values in the 'before' function, may return false positives where these are not updated in the test due to some other errors.

Need a more robust method of testing changes to logs.

ReportCard.js causes a crash if result object is undefined

Putting this here so I remember to fix it later.

I think we're not doing error checking correctly in ReportCard.js.

/Users/abrahamq/Documents/urop/cognicity-grasp/ReportCard.js:157
else if (result[0].received === false){
^

TypeError: Cannot read property 'received' of undefined
at /Users/abrahamq/Documents/urop/cognicity-grasp/ReportCard.js:157:29
at null. (/Users/abrahamq/Documents/urop/cognicity-grasp/ReportCard.js:85:6)
at Query.handleReadyForQuery (/Users/abrahamq/Documents/urop/cognicity-grasp/node_modules/pg/lib/query.js:114:10)
at null. (/Users/abrahamq/Documents/urop/cognicity-grasp/node_modules/pg/lib/client.js:172:19)
at emitOne (events.js:82:20)
at emit (events.js:169:7)
at Socket. (/Users/abrahamq/Documents/urop/cognicity-grasp/node_modules/pg/lib/connection.js:121:12)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.