When you purchase a new phone number with Twilio, the URL for voice and SMS is not configured so until you set this up you won’t be able to receive any incoming messages or calls. But what if you want to receive inbound text messages without sending anything back?
This morning I got a call on the Twilio support line from someone looking to receive inbound SMS messages to his Twilio numbers, without sending any responses back. To keep things as simple as possible, he just wanted to collect the information sent in via the call logs, and not deal with any complex hosting of his Twilio application. I realized this is something many customers look to do each day, so I’ve written up a step-by-step guide on how to configure your application and hosting with Twilio and Dropbox in just 5 minutes.
Creating Your Twilio Application
First, create your “application”, which in this case is really just going to be a blank XML file formatted so Twilio will understand it. We’ll call ours sms.xml (make sure you save your file with the “.xml” file extension). You can write this using any text editor.
Yep that’s right, just two lines of XML is all you need. This will let Twilio know that it is a legitimate application, but also instruct Twilio not to send any response.
Sending a Simple Response Message
If you want to send a simple response to each person who messages your Twilio number instead, try this:
<Sms>Thanks for your message!</Sms>
Hosting Static Files with Dropbox
Dropbox is a simple and free solution for hosting static files without having to set up a servier, and in this case we’re going to save a simple XML file using TwiML, or Twilio Markup Language. To get started, create a free Dropbox account.
Once you’re account has been created and you’re logged into Dropbox, we need to upload the application that you created so that we can get a URL for the file and configure your Twilio number for SMS. From within your Dropbox account, select the folder called Public. This is where we will host your application.
Select the “Upload” button and upload the file from your computer. Once the file is uploaded, it will show up in the Dropbox web UI as one of the files within the Public folder. Now we need to get the URL for this file so that we can configure your Twilio number.
To get this URL, click on your file in the list and copy the URL from your browser, it should be something like this: https://dl.dropbox.com/u/1234567/sms.xml
Configuring Your Twilio Number for SMS
Now we have a URL for our SMS application, so all we need to do it visit our Twilio.com account and tell Twilio where what to do whenever a text message is received.
Log into your Twilio account and navigate to the Phone Numbers page, and select “edit” next to the number you wish to update.
You will see the options to configure voice and SMS applications, so check the box indicating your want to use this number for SMS and paste the URL of your application into the box:
Photo credit: Dougvr6 on Flickr