Allows Twitter users to submit flood reports via a Twitter Direct Message (DM) chat bot.
This module deploys AWS lambda functions that, after a user initiates a conversation via Twitter direct messages, uses the cognicity-bot-core module to fetch a report card from a CogniCity server and sends it to the user. The module also sends thank you messages once a user has submitted a flood report.
npm install
Adjust .travis.yml to deploy via Travis as need.
- Register Twitter account for the Account Activity API
- Create an application, dev environment and subscription for the Twitter account
- Copy tokens and secrets from https://apps.twitter.com (see configuration below)
- Deploy functions to AWS Lambda
- Connect functions to an AWS API gateway instance
- Add the API gateway endpoint URL to
src/config.js
(or set process.env) - Create a subscription using the
commands/add-subscription.js
script - Register a webhook using the
commands/add-webhook.js
script - Test the chatbot
Configuration variables are as follows (these should be set in the Lambda environment):
API_GW_WEBHOOK
- the API gateway address for the webhook endpoint. Currently this is unused.BLACKLIST
- list of comma seperated twitter user ID numbers to exclude from chatbot replies (e.g. '123,456,789')CARDS_API
- the endpoint to get new report cardsCARDS_API_KEY
- the api key for the cards endpointCARDS_DECK
- one or more of 'flood,prep', describes what cards decks can be deployedCARDS_URL
- the URL for the card resources to be sent to the userDEFAULT_INSTANCE_COUNTRY_CODE
- default country code for deployment (e.g. 'us')DEFAULT_INSTANCE_REGION_CODE
- in case a report is submitted outside the city, the code that the bot should fall back on for geographic referenceDEFAULT_LANGUAGE
- default language for user interactionsMAP_URL
- the risk map URLTWITTER_CONSUMER_KEY
- Twitter consumer keyTWITTER_CONSUMER_SECRET
- Twitter consumer secretTWITTER_TOKEN
- Twitter tokenTWITTER_TOKEN_SECRET
- Twitter secret tokenTWITTER_BOT_USER_ID
- the user ID for the bot (stop self replies) !importantTWITTER_ENDPOINT
- Twitter's API
Built in ES6, compiled with Babel, deployed to AWS Lambda using Travis.
Run
npm run build
Run unit tests (mocha + unit) and ESLint
npm test
- Issues tracked on GitHub
- Master currently deployed version, use dev branch for new features
- Note
- design pattern notes below
- note release process notes below
- update the CHANGELOG.md file with newly released version, date and high-level overview of changes. Commit the change.
- Create a tag in git from current head of master. The tag version should be the same as the version specified in the package.json file - this is the release version.
- Update the version in the package.json file and commit the change - this is a new version.
- Further development is now on the updated version number until the release process begins again.
- functions that make external calls should return a promise
- internal methods can be simple functions
- Use JSDoc comments throughout