Provides a simple way to use Adhearsion with your existing apps built for Twilio
Add this line to your application's Gemfile:
gem 'adhearsion-twilio', :github => somleng/adhearsion-twilio.git
And then execute:
Configure your voice_request_url and status_callback_url in
config/adhearsion.rb or use the environment variables.
These should be the same endpoints that you point to in your Twilio configuration and should return valid TwiML.
Adhearsion.config do |config| # Retrieve and execute the TwiML at this URL when a phone call is received [AHN_TWILIO_VOICE_REQUEST_URL] config.twilio.voice_request_url = "http://localhost:3000/" # Retrieve and execute the TwiML using this http method [AHN_TWILIO_VOICE_REQUEST_METHOD] config.twilio.voice_request_method = "post" # Make a request to this URL when a call to this phone number is completed. [AHN_TWILIO_STATUS_CALLBACK_URL] config.twilio.status_callback_url = nil # Make a request to the status_callback_url using this method when a call to this phone number is completed. [AHN_TWILIO_STATUS_CALLBACK_METHOD] config.twilio.status_callback_method = nil # The default voice to use for a male speaker (see 'config.punchblock.default_voice' for allowed values) [AHN_TWILIO_DEFAULT_MALE_VOICE] config.twilio.default_male_voice = nil # The default voice to use for a female speaker (see 'config.punchblock.default_voice' for allowed values) [AHN_TWILIO_DEFAULT_FEMALE_VOICE] config.twilio.default_female_voice = nil end
In your controller include
Adhearsion::Twilio::ControllerMethods, answer the call and notify your voice app like this:
class CallController < Adhearsion::CallController include Adhearsion::Twilio::ControllerMethods def run notify_voice_request_url end end
notify_voice_request_url will send a Twilio Request using the url you configured in
voice_request_url then execute any TwiML you respond back with.
The following verbs have been already implemented:
The following verbs are not yet fully implemented:
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
The software is available as open source under the terms of the MIT License.