Receiving Your First SMS
To send your first SMS, you needed a phone number, API credentials, and a REST API call.
Receiving messages works a bit differently: when using the cXML API, you need to prepare an XML file with instructions on what to do after a message is received on a given phone number.
cXML Applications
Let's write our first XML bin. We will host this one on SignalWire (you can use your own server if you want, which even allows you to generate bins dynamically).
You can create and manage bins from the LaML section of your Dashboard under the Bins tab.
Create a new bin, and use the following lines as content:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message>Hello from SignalWire!</Message>
</Response>
The bin above will reply with a fixed message to any incoming SMS. Find the full technical reference in the Compatibility XML section.
Copy the Request URL of the bin you just created, then read the next section to configure a number to handle messages using that bin.
Configuring your number
The last step is connecting a number to the bin. If you don't have a phone number yet, make sure to buy one. You will need at least one number to receive messages.
Then, open the settings for the number. Under "Messaging Settings", choose to handle messages using "LaML Webhooks", then paste the URL of the bin in the field below.
Try sending a message to the configured phone number: after a few seconds you'll receive an automated reply.
If you are sending messages to the US from a 10DLC number, you must register your traffic with the Campaign Registry. Otherwise, the carriers will not deliver your messages. Please see Campaign Registry - Everything You Need To Know for more information.
Wrap up
We have shown how to receive a text message and perform follow-up actions.
This example used the Compatibility API, and in particular cXML bins, to receive a message. For more advanced, real-time applications, you'll want to check out our Realtime SDK.