When an SMS is sent to an Plivo phone number, you can receive the text on your server by setting a Message URL in your Plivo app. Plivo will send the message along with other parameters to your Message URL. You can reply back using the Plivo Message XML.
In order to reply to a US or Canadian phone number, the `'src'` (source) phone number must be a Plivo US or Canadian phone number that is SMS-enabled. You can purchase a Plivo number from the Buy Numbers
tab on your Plivo Console and filter the Phone Numbers by selecting SMS in the features option to buy SMS enabled numbers.
- Sign up for a free Plivo trial account.
- Check out our server SDKs page and install the right helper based on the programming language you want to use.
- A phone number is required to receive and reply to SMS text messages. You can buy a Plivo phone number in over 19 countries through the Buy Numbers tab on your Plivo account UI. Check the SMS API coverage page for all the supported countries.
- Use a web hosting service to host your web application. There are many inexpensive cloud hosting providers that you can use for just a few dollars a month. Follow the instructions of your hosting provider to host your web application.
If you are using a Plivo Trial account for this example, you can only send sms to phone numbers that have been verified with Plivo. Phone numbers can be verified at the Sandbox Numbers
Set up a Web Server
Let’s assume your web server is located at
http://example.com. Below is a snippet to set up a route on your webserver. Now when we send an HTTP request to
http://example.com/reply_to_sms/ this route will be invoked.
Note: For PHP, the route will be example.com/reply_to_sms.php.
- Copy the relevant code below into a text file and save it. Let’s call it,
- Customize the
'body' with your reply.
- Next, you will now have to configure this URL in your Plivo application.