メニュー

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Programmable Wireless: Send and Receive Text Messages

Programmable SMS is offered as a developer preview forProgrammable Wireless SIMs — see the section Known Limitations, below.

Any device connected by a Programmable Wireless SIM can send and receive Programmable SMS messages. This requires the device itself to support SMS messaging. It also requires the SIM’s Rate Plan to have Messaging selected as an Enabled Service.

デバイスと送受信されるSMSメッセージはTwiMLを使用してプログラムから制御されます。

For machine-to-machine (M2M) SMS, specifically for cloud-to-device and device-to-cloud communications, see Send M2M Commands by SMS.

SIMs can only send and receive SMS messages of up to 160 characters.

SIMs cannot send or receive MMS message.

Apple iMessage is not supported.

How to Send an SMS from a Phone Containing a Programmable Wireless SIM

To sends text mesages from your phone, you need to associate a real phone number with your SIM, and set up some logic to process messages. The logic uses Twilio Markup Language (TwiML) to ensure the message you’ve sent comes from your phone number.

Purchase an SMS-enabled Twilio phone number

You first need to purchase a Twilio phone number that is SMS enabled.

  1. Point your browser to the Buy a Number section of the Console.
  2. Optionally, enter an area code of your choice in the input field.
  3. Check at least SMS from the Capabilities selections. Additional options are available by clicking Show Advanced Search.
  4. Click Search.
  5. You should see a list of available numbers to purchase.
  6. Select one number and click Buy to buy it.

Buy-Number-SMS

You now have a Twilio phone number that you can associate with a SIM.

In the Console, you want to make sure the Internet of Things icon is visible in the side menu. If not, click All Products and Services, locate it under Super Network, and pin it to the dock.

  1. Under Programmable Wireless, click SIMs.
  2. Select the SIM that is in your phone. (Need help registering a SIM? See Ordering and Registering Your First SIM)
  3. Click the Programmable Voice & SMS tab.
  4. In the Programmable SMS section, select TwiML from the SMS URL popup.
  5. Click the blue + button to the right of the input field.
  6. You’ll now see a panel appear with a TwiML template for routing messages.
  7. You can rename the Friendly Name.
  8. In the Message element, replace YOUR_NUMBER_HERE with the number you just bought.
  9. Click Add TwiML Bin.
  10. Click Save.

Add-TwiML-Bin-2.png

You need to enter phone numbes in E.164 format. What does that mean? Look here

You’re done — you can now send text messages from your phone. Feeling creative? Use functions or set up your own TwiML server to dynamically set the Caller ID.

How to Receive a Text Message on a Phone with a Programmable Wireless SIM

You can now send SMS messages from your cellphone with a Programmable Wireless SIM but you can’t yet receive them. Let’s set this up now. Once again we’ll use TwiML to tell the Twilio cloud how to handle incoming messages.

Create TwiML for incoming SMSs

In the Console, you want to make sure the TwiML Bins icon is visible in the side menu. If not, click All Products and Services , look under Runtime and pin it to the dock.

  1. Open TwiML Bins.
  2. Click the Red + Button to create a new TwiML Bin.
  3. Enter a name in the FRIENDLY NAME input field.
  4. For the TwiML Response, you can use the example shown below: copy and paste it into the TWIML field.
  5. In the Message element, enter your SIM’s SID in place of YOUR_SIM_SID_HERE. You can find your SIM SID in the SIMs section under Programmable Wireless. The SIM Sid begins with the DE prefix. The to attribute starts with “sim:”
  6. Click Create.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Message to="sim:YOUR_SIM_SID_HERE" from="{{From}}">
     {{Body}} 
   </Message> 
</Response>

TwiML-Incoming-SMS

Associate TwiML with an SMS-enabled Twilio phone number

  1. Go to the Phone Numbers section of the Console and click on the number you wish to associate with your SIM
    (See Purchase an SMS-enabled Twilio phone number above if you don’t have a number yet)
  2. Scroll down to Messaging and make sure that Webhooks, TwiML Bins, Functions, Studio or Proxy is selected for CONFIGURE WITH.
  3. Under A MESSAGE COMES IN, select TwiML.
  4. Select the TwiML you created in the previous section using its Friendly Name.
  5. Click Save.

SMS Set Incoming TwiML

Well Done! Now you can try sending a message to the phone number. If everything was set up correctly, you should receive the SMS message on your SIM-connected device.

ログと課金情報

ログ

You can view a log of messages send and recieved by selecting Phone Numbers > Active Numbers > Your Number in the Console and then clicking the Message Log tab.

請求

Most call flows that involve a SIM will include two independent call legs: one call between Twilio and the non-SIM party, and the other between Twilio and the SIM-connected device.

The call leg from Twilio to the non-SIM party (PSTN, SIP, Client, etc.) is billed at standard Twilio voice rates, depending on the connectivity method used. The other call leg between Twilio and the SIM is billed at Programmable Wireless voice rates.

既知の制限

デバイスへのProgrammable SMSではないメッセージ

A phone number is provided on the SIM known as the MSISDN which is not used by Programmable Voice or Programmable SMS. The presence of the MSISDN means that some (potentially unwanted) calls may arrive straight to your SIM without routing via Twilio. If this occurs, Twilio cannot yet offer programmatic control over the calls and you won't see them in your Twilio call logs. However, 100% of calls and messages originating from the SIM are programmatically routed by Twilio.

トライアルアカウント

Currently, Programmable SMS requires an upgraded Twilio account.

次は?

You’ve followed all the guides in the Getting Online section and you’re ready to dive deeper into Programmable Wireless. From here, you can learn more from our API documentation, or try some of our other guides:

Rate this page:

ヘルプが必要ですか?

誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。