Rails plugin for Twilio telephony apps
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
generators/twilio
lib
rails
test
.document
.gitignore
LICENSE
README.rdoc
Rakefile
VERSION
example.rb
init.rb
twilioflow.gemspec

README.rdoc

twilioflow

Rails plugin for state machine driven interactions with Twilio telephony API.

Twilioflow provides:

  1. A Workflow approach for keeping your business logic inside models

  2. Concise Ruby way for specifying voice responses and key press actions within states

  3. Clean and RESTful controllers that understand Twilio requests.

  4. Automatic generation of TwiML <Response> based on current interaction state

  5. HTML scaffolding to quickly test your interactions in the browser.

Quickstart

  1. ruby script/generate twilio interaction

  2. Add your custom state machines to interaction.rb

  3. Test your interactions with localhost:3000/interactions

  4. Update config/twilio.yml with your Twilio account sid, and phone number

  5. Call your Twilio phone number and see it work with Twilio

Example

Here is a detailed example outlining various aspects of the state machine specifiers.

github.com/dkeskar/twilioflow/blob/master/example.rb

Interaction Model

The model (e.g. Interaction) encompasses the state machine, voice responses, key presses and transition decisions. The controller (e.g. InteractionsController) provides a set of RESTful methods for HTML testing within the browser and a twilio handler (e.g. /interactions/twilio/do.twiml).

The controller includes generated code for finding the required model object, providing the voice responses appropriate to its current state and responding to key presses. The model includes several generated methods (#says, #accepts, #respond! and #decide!) to enable the controller interaction.

Finally, the generated views (edit.html.erb and twilio.twiml.builder) create the appropriate response, readying the interaction for the next state.

Status & Improvements

The Workflow, state machine transitions, and TwiML generation have been well tested. The Rails plugin has been smoke-tested. The Gem functionality has not been exercised yet.

Twilioflow can be improved to have richer, more concise state machine specifiers, including additional Twilio Verbs. The generated TwiML can benefit from better Gather/Say nesting support. The plugin can incorporate examples of calling the Twilio REST API. It would be good if the Twilio Quick Start examples can be embedded or manifested with the Twilioflow plugin. RSpec or other tests would be nice too.

If you spot errors or omissions, please let me know.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it, so I don't unintentionally break anything in a future version.

  • Commit, avoid changing rakefile, version, or history.

  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright © 2010 Dhananjay Keskar, Memamsa LLC. See LICENSE for details. memamsa.com