Rails plugin for state machine driven interactions with Twilio telephony API.
A Workflow approach for keeping your business logic inside models
Concise Ruby way for specifying voice responses and key press actions within states
Clean and RESTful controllers that understand Twilio requests.
Automatic generation of TwiML <Response> based on current interaction state
HTML scaffolding to quickly test your interactions in the browser.
ruby script/generate twilio interaction
Add your custom state machines to interaction.rb
Test your interactions with localhost:3000/interactions
Update config/twilio.yml with your Twilio account sid, and phone number
Call your Twilio phone number and see it work with Twilio
Here is a detailed example outlining various aspects of the state machine specifiers.
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 © 2010 Dhananjay Keskar, Memamsa LLC. See LICENSE for details. memamsa.com