Get Started With Twilio SMS in Ruby With This Five Minute Video - Twilio
Power modern communications. Build the next generation of voice and SMS applications.
Start building for free

Get Started With Twilio SMS in Ruby With This Five Minute Video

how-to-send-sms-using-ruby

Sending and receiving text messages in Ruby is delightfully easy. Whether you are sending appointment reminders or working building a marketing notification system you’ll be up and running in no time after watching this five minute video:

Here’s the code from the video for your reference:

require 'sinatra'
require 'twilio-ruby'

post '/receive_sms' do
  content_type 'text/xml'

  response = Twilio::TwiML::Response.new do |r|
    r.Message 'Hey thanks for messaging me!'
  end

  response.to_xml
end

post '/send_sms' do
  # Phone number to send to
  to = params["to"]
  # Message to send
  message = params["body"]

  client = Twilio::REST::Client.new(
    ENV["TWILIO_ACCOUNT_SID"],
    ENV["TWILIO_AUTH_TOKEN"]
  )

  client.messages.create(
    to: to,
    from: "+12155844169",
    body: message
  )
end

What’s Next

Now that you have the power of SMS in your toolbelt you can build all sorts of things. Try one of these as your first project:

I’m really excited to see what you build with Ruby and SMS. Let me know what you’re working on either by email (brent@twilio.com) or find me on Twitter @brentschooley.

Sign up and start building
Not ready yet? Talk to an expert.