You’ve got a Programmable Wireless SIM in your device and you want to send a machine-to-machine command.
Programmable SMS is used to exchange text messages between people, while Commands use SMS as the means to deliver machine-to-machine messages.
You use Command resources to send a command message only to a Programmable Wireless SIM, not to a person’s phone number. Commands also provide some features such as binary message encoding, that are only useful for machine-to-machine workflows,.
You can read details about the Command resource in the Programmable Wireless API documentation.
You want to send a Command from your device to Twilio’s servers to either:
- Test Commands.
- Hit the Commands callback webhook to direct to your servers.
How you send a Command is largely dependent on the type of device you use to send a text message. Generally, you need to do the following:
- Insert a Programmable Wireless SIM in the device.
- Make sure the SIM is registered to your account and in the Ready or Active status.
- Send an SMS to the short code 2936.
The 2936 number is a special reserved short code used to exchange Commands with your Twilio SIMs.
How does Programmable Wireless know what device sent that Command? Each SIM has a unique identifier associated with it. Programmable Wireless uses that unique identifier to send Commands through your account.
- Navigate to the SIMs section of the Console.
- At the list of SIMs on your account, click on the SIM that is in your device .
- Click on the Commands tab at the top of the SIM details.
- You should see your first Command sent from a machine to a machine.
You can send Commands from any Internet-connected device using the Programmable Wireless API. You can do it right now on your computer. You’ll need to use the command line tool curl, which you may need to install. If you are running Linux or macOS, curl is probably installed already: run
which curl to check. For Windows, you will need to install curl — you can find the software and instructions from the source here.
You will also need the following Twilio-specific credentials:
- Your Programmable Wireless SIM’s SID or unique name. You can get this from the SIMs section of the Console.
- Your Account SID and Auth Token, both of which are available from your console dashboard.
Copy the following code and paste it into a command line, then edit it to add your own credentials where marked. Make sure you remove the angle brackets. Windows users may need to remove the
\ symbols and run the command on a single line:
curl -X POST https://wireless.twilio.com/v1/Commands \ --data-urlencode "Sim=<YOUR_SIM_SID_OR_NAME>" \ --data-urlencode "Command=hello_sim" \ -u <YOUR_ACCOUNT_SID>:<YOUR_AUTH_TOKEN>
This code creates a Command resource in the Twilio cloud which then triggers the transmission of the text in the
Command field to the specified SIM.
On your computer, you will see see the JSON results of the POST you sent to Twilio via curl. Shortly, you’ll receive the Command itself on your device from the 2936 number.
Again, you can verify that that command was received by following the procedure described above, or you can check on the device itself if it has a suitable interface: