Ruby Quickstart: Sending Text Messages from a Phone Call

Did you know you can also send SMS when someone calls your Twilio number? The verb is actually a valid response to an incoming call. Give this a try:

require 'rubygems'
require 'twilio-ruby'
require 'sinatra'

get '/sms-quickstart' do do |r|
    r.Say "Hello Monkey! You will get an SMS message soon."
    r.Sms "Here it is!"

If you go that that app in your browser, you should see TwiML that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
    <Say>Hello Monkey! You will get an SMS message soon.</Say>
    <Sms>Here it is!</Sms>

Save a publicly-accessible URL to return that XML. Then, configure that URL to be the Voice URL of your Twilio phone number.

Call that number from a mobile phone -- you should hear a message and get a text message in response.

And that's all folks! Back to Quickstarts.