Code for text message reminders
Ruby HTML CSS JavaScript CoffeeScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
config
db
doc
lib
log
public
script
spec
test
vendor
.DS_Store
.gitignore
.rspec
.ruby-version
.sample_env
.travis.yml
Gemfile
Gemfile.lock
Guardfile
Procfile
README.md
Rakefile
config.ru
how-to-promptly.md
import_runner.rb

README.md

Codeship Status for postcode/promptly Build Status Stories in Ready

Promptly

Promptly is a text message notification system originally built by 2013 Code for America fellows for the San Francisco Human Services Agency. See promptly.io for more info on the project. See our wiki for documentation.

Contribute

This project is not actively maintained.

Requirements

Promptly is a Ruby on Rails application that uses Twilio to send text messages.

If you need help setting up RVM, Ruby, and all that stuff, we recommend Moncef's great tutorial on setting up a Mac for development with Xcode, Homebrew, Git, RVM & Ruby.

If you are installing on Windows try RailsInstaller. Installing Rails on Windows can be tricky. There is a fork that is being actively developed within a Windows environment at SF HSA. You can have a look at their fork here: https://github.com/sf-hsa/promptly Some users have run into an error bundling on Windows because of a kgio error. See http://stackoverflow.com/questions/11199620/rails-on-windows-without-kgio for a solution, hint: you can comment out gem unicorn and use a different web server for local development.

You'll also need to setup a Twilio account and buy a Twilio phone number. You can get a development phone number for free but you'll need to pay to send text messages. Check our their pricing.

Install locally

  1. Install Bundler
$ gem install bundler
  1. Install the Heroku Toolbelt: https://toolbelt.heroku.com/

  2. Install and run PostgreSQL

Make sure PostgreSQL is running. If you're using Postgres.app, just run the application and then look for a cute elephant in the menu bar.

  1. Clone this repo
$ git clone https://github.com/postcode/promptly.git
  1. Install required gems
$ cd promptly
$ bundle install
  1. Configure environment variables by renaming .sample_env to .env and adding your (secret) keys
$ mv .sample_env .env

Promptly requires the following environment variables:

  • TWILIO_NUMBER is your Twilio phone number (just numbers, no punctuation)
  • TWILIO_SID is your Twilio account SID
  • TWILIO_TOKEN is your twilio auth token
  • SECRET_TOKEN is used to prevent cookie tampering. Run $ rake secret to get a pseudo-random key to use.

Add one variable per line in the .env file like this:

TWILIO_NUMBER=5105555555
TWILIO_SID=AC1365ff47...
...
  1. Create the file config/database.yml Insert the text below into database.yml. You will have to include your PostgreSQL username. Postgres.app creates a default user $USER with no password. Otherwise you'll have to make one yourself.
development:
  adapter: postgresql
  host: localhost
  username: [PostgreSQL username]
  #password: [Optional PostgreSQL password]
  database: promptly
  1. Setup the database
$ rake db:setup

# Equivalent to:
# rake db:create
# rake db:schema:load
# rake db:seed
  1. Start the server
$ foreman start

You should see something this in the console:

12:01:14 worker.1 | started with pid 3228
12:01:14 web.1    | started with pid 3227
12:01:16 web.1    | I, [2013-11-11T12:01:16.139986 #3227]  INFO -- : listening on addr=0.0.0.0:5000 fd=7
12:01:16 web.1    | I, [2013-11-11T12:01:16.140103 #3227]  INFO -- : worker=0 spawning...
12:01:16 web.1    | I, [2013-11-11T12:01:16.142336 #3227]  INFO -- : master process ready
12:01:16 web.1    | I, [2013-11-11T12:01:16.144046 #3229]  INFO -- : worker=0 spawned pid=3229
12:01:16 web.1    | I, [2013-11-11T12:01:16.144531 #3229]  INFO -- : Refreshing Gem list
12:01:20 web.1    | I, [2013-11-11T12:01:20.205813 #3229]  INFO -- : worker=0 ready

You can now visit Promptly at http://localhost:5000

You can sign in with email=admin@example.com and pass=administrator.

Deploy to Heroku

Signup for Heroku if you havn't already.

  1. Create a Heroku app and push your code
$ heroku login
$ heroku create
$ git push heroku master
  1. Add the Heroku PostgreSQL addon and promote it
$ heroku addons:add heroku-postgresql
$ heroku pg:promote HEROKU_POSTGRESQL_[YOUR COLOR]_URL
  1. Configure Heroku environment variables
$ heroku config:add TWILIO_NUMBER=[your Twilio phone number]

Repeat for TWILIO_SID, TWILIO_TOKEN, and SECRET_TOKEN using the values from your .env file (see above for details).

  1. Setup the database
$ heroku run rake db:setup

At this point you can run $ heroku open to see the project. We're almost done!

  1. Add a worker dyno

Promptly requires a worker dyno to queue the text message reminders. Please note this will cost you money. See the Heroku dev center for details on delayed job and pricing.

$ heroku ps:scale worker=1
  1. Add the Heroku scheduler addon

For annoying reasons we won't go into here, Promptly requires a periodic rake task to update the conversations model with incoming text messages from users. You can do this on Heroku using the scheduler addon.

$ heroku addons:add scheduler
$ heroku addons:open scheduler

Run the task rake update_conversations every 10 minutes: heroku scheduler addon

  1. Change the admin password
$ heroku open

Sign in with email=admin@example.com and password=administrator. Click Welcome, Admin in the top right and update your password.

And you're all set!

codeforamerica