sinatra-twilio¶ ↑
This is a library for creating simple web apps to handle incoming SMSes/Calls with Sinatra using a nice DSL.
Installation¶ ↑
Using Bundler¶ ↑
gem 'sinatra-twilio', :require => 'sinatra/twilio'
Not using bundler¶ ↑
Run:
gem install sinatra-twilio
Then in you Sinatra app, add the following lines after you require “sinatra”:
require 'sinatra/twilio'
A totally contrived and un-tested example¶ ↑
require "sinatra" require "sinatra/twilio" callers = %w[+15551234567] pin = "1234" respond "/call" do addSay "Welcome caller." if callers.include? params[:From] addRedirect "/allowed_call" else addRedirect "/disallowed_call" end end respond "/allowed_call" do addPlay "/latest_message.mp3" end respond "/disallowed_call" do gather = Twilio::Gather.new(:action => "/authenticate") gather.addSay "Please enter your PIN now:" append gather addSay "You did not enter a pin. Good bye!" addHangup end respond "/authenticate" do if params[:Digits] == pin addRedirect "/allowed_call" else addRedirect "/disallowed_call" end end get "/latest_message.mp3" do # Assuming we have an ORM... send_file Message.last.path, :stream => true end
Contributing to sinatra-twilio¶ ↑
-
Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
-
Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
-
Fork the project
-
Start a feature/bugfix branch
-
Commit and push until you are happy with your contribution
-
Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright¶ ↑
Copyright © 2011 Bodaniel Jeanes. See LICENSE.txt for further details.