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:
❤️ +☕ - Express
- GraphQL
- MongoDB
- Redis
- RiveScript
Installation
Local Node, redis, and MongoDB installations are required to run this application. (More detailed installation instructions here).
- Install Node, Redis and MongoDB.
- Clone this repo and navigate to it.
- Create a
.env
file with required variables. See.env.example
for guidance. (Some detailed instruction here). - 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 Gambit 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
- Run
npm test:full
to lint code and run automated tests. - Pull requests are expected to contain reasonable test coverage.
Note: Git tags exist from when we used Wunderflow for branching. We now adhere to a Github flow, keeping consistent with workflow for other current DoSomething repositories, and no longer create tags for each deployment.
Troubleshooting
ERR! cb() never called!
error when running npm install
.
I get an 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
andmaxproc
system limits, Link. - Exit out of all terminals and re-open.
- Removed
node_modules
andpackage-lock.json
. - Run
npm install
again.