Skip to main content

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.

Receiving text messages from users using cXML applications.

Using cXML​

Let's write our first cXML script. We will host this one on SignalWire, but you can use your own server if you want, which allows you to generate scripts dynamically.

Create a cXML Script​

Navigate to the "Resources" tab from the sidebar and create a new Resource. There, select the resource type of "Script", and pick "cXML script".

No Resources tab?

If you don't see the Resources tab, your SignalWire Space is on the Legacy Dashboard. Refer to the Legacy section of this guide for instructions for your Dashboard and information about the migration.

Paste the script​

There, you can paste the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message>Hello from SignalWire!</Message>
</Response>

This script will reply with a fixed message to any incoming SMS. Alternatively, you can forward the message to a different number using this script:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message to="+1xxxxxxxxxx">
You received a message from: {{From}} to SignalWire number: {{To}}.
The message is: "{{Body}}"
</Message>
</Response>

Consult the full cXML technical reference to write more complex scripts.

Copy the Request URL of the script you just created, then read the next section to configure a number to handle messages using that bin.

Assign a phone 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.

Navigate to the "Phone Numbers" section of your Dashboard and open the settings for the number you want to configure. There, assign the cXML script you just created to handle messages.

Send a test SMS​

Try sending a message to the configured phone number. If everything has gone according to plan, after a few seconds you'll receive an automated reply.

Next steps​

We have shown how to receive a text message and perform follow-up actions.

This example used the Compatibility API, and in particular cXML Scripts, to receive a message. For more advanced, real-time applications, you'll want to check out our Realtime SDK.

Ensuring message delivery

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.


In the Legacy Dashboard​

No Resources tab? Your SignalWire Space is on the Legacy Dashboard.

Expand the section below to view this guide's Legacy instructions.

Follow the above guide, with the following changes:

Create a cXML Script​

Navigate to the "LaML/cXML" section of your Dashboard and create a new cXML bin with the content above.

Assign a phone number​

Open the settings for the number you want to configure. Under "Messaging Settings", choose to handle messages using "LaML Webhooks". In the dropdown, select the cXML script you just created.

Identify your Dashboard and select between Legacy and New UIs using the tabs below.

Resources that were previously accessible in the sidebar of the legacy UI are now located in the unified Resource menu.