Spoke is an open source text-distribution tool for organizations to mobilize supporters and members into action. Spoke allows you to upload phone numbers, customize scripts and assign volunteers to communicate with supporters while allowing organizations to manage the process.
Spoke was created by Saikat Chakrabarti and Sheena Pakanati, and is now maintained by MoveOn.org.
This is generated from react-apollo-starter-kit. Look at that project's README for info on some of the libraries used.
- Install either sqlite (or another knex-supported database)
- Install the Node version listed under
engines
inpackage.json
. NVM is one way to do this. npm install
npm install -g foreman
cp .env.example .env
- Run
npm run dev
to create and populate the tables. - Create an Auth0 account. In your Auth0 account, go to Settings -> Clients -> and then grab your Client ID, Client Secret, and your Auth0 domain (should look like xxx.auth0.com). Add those inside your
.env
file (AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_DOMAIN respectively). - Add the login callback and logout callback URL in
.env
(defaulthttp://localhost:3000/login-callback
andhttp://localhost:3000/logout-callback
) to your Auth0 app settings under "Allowed Callback URLs" and "Allowed Logout URLs" respectively. - Run
npm run dev
to start the app. Wait until you see both "Node app is running ..." and "Webpack dev server is now running ..." before attempting to connect. (make sure environment variable JOBS_SAME_PROCESS=1) - Go to
localhost:3000
to load the app. - Because Spoke is invite-only you need to generate an invite. Run:
echo "INSERT INTO invite \(hash,is_valid\) VALUES \('abc-123', true\)\;" |sqlite3 mydb.sqlite
- Use the generated key to visit an invite link, e.g.: http://localhost:3000/invite/123. This should redirect you to the login screen. Use the "Sign Up" option to create your account.
- You should then be prompted to create an organization. Create it.
If you want to create an invite via the home page "Login and get started" link, make sure your SUPPRESS_SELF_INVITE
variable is not set.
**Because of issues with numbers getting marked with spam, we adopted aggressive number cycling to limit the number of texts sent from a specific number. We did not implement a corresponding process to unrent the numbers before shutting down the service, so two things are a high priority before putting Spoke back into production:
- Decide whether to keep the number cycling, since it might not be necessary on Twilio like it was on Nexmo
- If keeping it making sure there's a corresponding process to unrent unused numbers.
- Even if not keeping number cycling, there should be a process like this anyway to unrent numbers that haven't been used in X days anyway because volunteers come and go. However, cycling numbers every ~250 texts obviously racks up exponentially higher costs than just assigning a single number per volunteer. **
- Go to
localhost:3000/graphql
to mess around with the GraphQL API - Run
sqlite3 mydb.sqlite
to connect to a SQL shell for the dev database - Set up an ESLint plugin in your code editor so that you catch coding errors and follow code style guidelines more easily!
- Install the redux-devtools-extension in Chrome to get advanced Redux debugging features.
- Right now there is a bug in Apollo (apollographql/react-apollo#57) that means in one particular case, errors get swallowed. If you end up with an app that is silently breaking, console.log(this.props.data) and check the errors property.
If you need to use Twilio in development but with live keys, do the following to receive incoming replies:
- Start ngrok
- Visit https://www.twilio.com/console/voice/dev-tools/twiml-apps and go to the Spoke Dev app.
- Set Request URL under "Messaging" to http://<<YOUR_NGROK>>.ngrok.io/twilio
- In
.env
setTWILIO_APPLICATION_ID
to the Twilio Spoke Dev application ID - In
.env
setTWILIO_STATUS_CALLBACK_URL
to http://<<YOUR_NGROK>>.ngrok.io/twilio-message-report
- Run
OUTPUT_DIR=./build npm run prod-build-server
This will generate something you can deploy to production in ./build and run nodejs server/server/index.js - Run
npm run prod-build-client
- Make a copy of
deploy/spoke-pm2.config.js.template
, e.g.spoke-pm2.config.js
, add missing environment variables, and run it with pm2, e.g.pm2 start spoke-pm2.config.js --env production
- Install PostgreSQL
- Start PostgreSQL (e.g.
sudo /etc/init.d/postgresql start
), connect (e.g.sudo -u postgres psql
), create a user and database (e.g.create user spoke password 'spoke'; create database spoke owner spoke;
), disconnect (e.g.\q
) and add credentials toDB_
variables in spoke-pm2.config.js
Spoke is licensed under the MIT license.