How to receive SMS to a twilio number

BIJU  picture BIJU · May 27, 2013 · Viewed 16.2k times · Source

I have created a free account in twilio for sending SMS through my website. After my registration I got a twilio number like XXX-XXX-XXXX. I am able to send message to mobile numbers but I don't know how to use this twilio number for receiving SMS. Please help me out on this.

Answer

Devin Rader picture Devin Rader · May 27, 2013

Twilio evangelist here.

The way Twilio notifies you of both incoming SMS message and incoming voice phone calls is by using something called a webhook. This is basically an HTTP request that Twilio makes to a URL that you tell us about. Normally this URL is a web app that you've created and published to a public website.

http://en.wikipedia.org/wiki/Webhook

In your Twilio dashboard, click on the Numbers tab and you will see your trial number.

https://www.twilio.com/user/account/phone-numbers/incoming

Click the phone number and you will see two input fields, one for a Voice URL and one for a SMS url. Just put your URL's there and click the save button.

Now if you send a text message to your number, Twilio will make an HTTP request to the URL you've told us about. You can think of this like a standard Form submit. Twilio will send along parameters like the number the SMS is coming from and the body of the message. The full list of parameters we send to the SMS url is here:

https://www.twilio.com/docs/api/twiml/sms/twilio_request

Your app can grab those parameters and use them however it wants. Your app can also return TwiML instructions to us that tell us to respond to the SMS.

https://www.twilio.com/docs/api/twiml/sms/your_response

You might want to check out our quickstarts for examples of how to receive a text message and and howtos for lots more examples of both sending and receiving SMS messages.

https://www.twilio.com/docs/quickstart/php/sms/hello-monkey https://www.twilio.com/docs/howto

Hope that helps.

Devin