Skip to content
🃏 The DoSomething.org chatbot.
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
app
brain
config
documentation
lib
test
.env.example
.eslintignore
.eslintrc.js
.gitignore
.nvmrc
LICENSE
Procfile
app.js
main.js
newrelic.js
package-lock.json
package.json
shell.js
wercker.yml

README.md

wercker status codecov

Gambit

Gambit is the DoSomething.org API for SMS conversations:

  • Receives inbound messages, creates/updates users and/or campaign activity, and sends an outbound reply

  • Sends outbound broadcast messages

  • Sends outbound confirmation messages for web subscriptions and/or campaign signups

  • Updates user subscription status when outbound message delivery fails

  • Sends outbound support messages from agents

Overview

Gambit receives and sends SMS messages from/to users via Twilio, forwarded from our internal message broker. It queries GraphQL to source outbound message content.

Staff members can chat with Gambit in Slack to test conversations, and can view Gambit content and conversation data from an internal web app.

Gambit forwards support requests from users into a Front inbox, where agents are able to send messages back to provide support.

Development

Gambit is built with:

Installation

Local Node, redis, and MongoDB installations are required to run this application.

We recommend using Homebrew to install both nvm (A Node.js version manager) and mongo.

  • Install Node and Mongo.
  • Clone this repo and navigate to it.
  • Create a .env file with required variables. See .env.example for guidance.
  • Your local Node.js and NPM versions should match the ones in package.json.
  • Install dependencies: npm install.
  • All tests should pass: npm run test:full.
  • Run Conversations locally: npm start (uses nodemon).

Localhost

With Gambit running locally, test Gambit replies by opening a new terminal window and running:

  • nvm use && node shell.
PuppetSloth-MacBook-Pro-2:gambit puppetsloth$ node shell


 ██████╗  █████╗ ███╗   ███╗██████╗ ██╗████████╗
██╔════╝ ██╔══██╗████╗ ████║██╔══██╗██║╚══██╔══╝
██║  ███╗███████║██╔████╔██║██████╔╝██║   ██║
██║   ██║██╔══██║██║╚██╔╝██║██╔══██╗██║   ██║
╚██████╔╝██║  ██║██║ ╚═╝ ██║██████╔╝██║   ██║
 ╚═════╝ ╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝   ╚═╝

===============================================================

* To send a photo, type 'photo'.
* To retry last message, type 'retry'.

===============================================================
You>

Input is posted to your localhost api/v2/messages?origin=twilio endpoint on behalf of the Northstar User with mobile number matching your DS_CONSOLEBOT_USER_MOBILE config variable. A new Northstar User is created for the mobile number if it doesn't exist.

Contributing

  • Contributions to this repo must adhere to the steps in wunder.io's Git workflow: Wunderflow.

  • Run npm test:full to lint code and run automated tests.

  • Pull Requests are expected to contain reasonable test coverage.

Troubleshooting

I get an ERR! cb() never called! error when running npm install.

I ran into this error when upgrading npm from 5.x to 6.x. There seems to be a bug that affects apps w/ a lot of dependencies. Here's the Link

Steps I took to fix it:

  • Raised the maxfiles and maxproc system limits, Link.
  • Exit out of all terminals and re-open.
  • Removed node_modules and package-lock.json.
  • Run npm install again.
You can’t perform that action at this time.