Deploying and Debugging Twilio

These are the steps you should go through the sanity check your Sinatra application, deploy and test.

Check everything looks OK (locally)

Load your Sinatra application locally by typing this code in your terminal window/command line:

ruby app.rb

Open the application in a browser using the information returned (something like localhost:4567) and then go to the route we created so localhost:4567/sms/incoming

You can test your app by adding querystring parameters to check if the responses look OK: localhost:4567/sms/incoming?Body=Hi&From=+123456789

Note: Twilio will send the querystring parameters titleized (i.e. Body not body). Make sure your querystring is using the right casing.

If it works you should see a message like this:

		This is my message

If you see a message like this and there’s no errors, we’re in business and can deploy. [Note: You should test your responses by changing the querystring.] Otherwise fix it…

If you do get an error:

  • Make sure your .env has the right info included in it
  • Make sure you’ve bundle installed
  • Make sure your gem file has all of the necessary gems
  • Make sure the needed require statements are included in your app.rb

Deploy to Heroku

If the last step was successful and you have no apparent errors:

  • Open GitHub Desktop, commit your changes in your project folder, and sync the changes with
  • In the command line, type git push heroku master and deploy your application to Heroku

Then test it by sending an SMS to your Twilio Number. Fingers crossed your bot talks to you!

It didn’t work?

If it didn’t work, but it deployed OK, do the following

  • Type heroku open, see if you get any application errors. If you did then the problem is with your code.
    • Type heroku logs to see what’s happening on the server. This will let you know why the application crashed.
    • Be on the look out for missing requires, or missing gems.
  • If everything with the application looks OK, visit You’ll see a ‘bug’ icon at the top. If it’s red or orange there’s a problem! You can click into it for more info. Common problems might include:
    • HTTP Retrieval Error: The URL it’s requesting is invalid. Double check your settings on the phone number and make sure you’re using a GET request. Alternatively, the code may have crashed or given an unexpected response to Twilio.
    • Invalid Body: Something is wrong with the message you’re trying to return. Check that you’re only returning text!
    • Invalid URL format: If you’re sending media back, this can happen if Twilio doesn’t like URL you’re trying to use. Double check it’s right and that it sends back an image correctly.


The latest tutorials sent straight to your inbox.