SMS generation with Twilio

Twilio is a cloud communications platform. With just a few lines of Ruby your applications can start communicating with your users via phone calls and SMS messages using Twilio. Rather than just write a blog post about how it works, why don't we dig into the code and send our first SMS message right now.

All you're going to need is a free Twilio account with a number that can send SMS messages. From your account gather your Account SID and Auth Token from the dashboard and the phone number and you're ready to write some code. Open your terminal and:

            $ gem install twilio-ruby
            $ irb
            irb> require 'twilio-ruby'.
            irb> account_sid = YOUR_ACCOUNT_SID
            irb> auth_token = YOUR_AUTH_TOKEN
            irb> twilio_phone_number = YOUR_TWILIO_NUMBER
            irb> my_phone_number = YOUR_PHONE_NUMBER
            irb> client =, auth_token)
            irb> client.messages.create(to: my_phone_number,
                   from: twilio_phone_number, body: "eurucamp rocks!")

There you go, you've sent an SMS message with Twilio. Want to know more? Take a look at the API documentation, try making a phone call or get some inspiration of what you can do with Twilio and Ruby from the blog.

If you have any questions or ideas, you can chatch Twilio developer evangelist Phil Nash on Twitter or email.