
Hi Questetra users! I’m Hatanaka, Questetra’s CTO.
At the end of the previous blog post Phone Number Verification through Web Form Application, I mentioned that
Some may say that if I specialize in mobile phone numbers, SMS is enough rather than a phone call.
Phone Number Verification through Web Form Application
Since Twilio can also handle SMS, this time I’d like to work on sending an SMS.
To do so, I will utilize Twilio’s SMS API.
Programmable SMS: Send an SMS with the SMS API
I needed two steps for the API to make a phone call, but this can be achieved in one step. Simple.
Just send a POST request for a specific URL, including the following parameters.
- Source number
- Destination telephone number
- Contents
However, there are caveats in the phone numbers that can be used. Such as, an SMS cannot be sent with a Japanese telephone number that can be purchased on Twilio. Therefore, I need to purchase a non-Japanese phone number that is capable of sending an SMS to Japan. Depending on the country there may be cases where even though you can use SMS, it is only capable of sending to numbers in the same country. With a U.S. phone number you can send an SMS to anywhere in the world.
Although voice/SMS/MMS/FAX can all be sent if these were checked at purchase like in the above figure, I will ignore MMS (Multimedia Messaging Service) since the service is not provided in Japan.
Now, I will create a simple Workflow App.
- At the Input Step the destination phone number and a message are entered.
- The Throw (auto) Step is a Throwing Message Intermediate Event (HTTP), and it calls the SMS API.
The Data Items are as follows.
Although the input check, etc. is not the point this time, I have tried to continue setting them as before.
Data Item Name | Data-type | Required | Permission at “Input” Step |
---|---|---|---|
Title | String-type single line | No | Editable |
Phone number | String-type single line | Yes | Editable |
Regular expression to be satisfied: \+81\d{9,10} |
|||
Placeholder: +8175205XXXX |
|||
Description:
Please start with the country code (+81).<br>Only numeric without a hyphen. |
|||
Text body | String-type multiple lines | Yes | Editable |
Max Length: 100 |
I will show you a list of variables used in the App.
Variable | Value |
---|---|
AccountSID | Account ID of Twilio |
PhoneNumber | The phone number to call. Those purchased from Twilio. Designated in international call format. |
Finally, these are the settings of the Throwing Message Intermediate Event (HTTP). First, set the [Network Settings] tab as follows.
Access URL | https://api.twilio.com/2010-04-01/Accounts/${var[AccountSID]}/Messages.json |
---|---|
HTTP Method | POST (application/x-www-form-urlencoded) |
Next, on the Header tab, turn on the Set Authorization Header option, and then click [Set up Settings] to move to the HTTP authentication setting and add a setting as follows.
(Authorization type) | Basic Authentication |
---|---|
Name | HTTP Authorization setting name (arbitrary, such as “Twilio API”) |
User name | Twilio account ID (AccountSID) |
Password | Token used to access the API (AUTHTOKEN) |
The Send parameters are as follows.
Parameter name | Value |
---|---|
From | ${var[PhoneNumber]} |
To | Phone number |
Body | Text body |
That’s it for the development of the App. The content will be sent exactly as entered in the text body to the destination mobile phone/smartphone via SMS.
There is one point to note. In the settings of the mobile phone/smartphone receiving the SMS, it could be set to not receive SMS from overseas. It’s also possible this could be in the phone company’s settings and not the actual device settings. In that case, an SMS sent from this Workflow App cannot be received because the SMS isn’t from Japan.
That’s it for today. Next time I would like to substitute the Throwing Message Intermediate Event (HTTP) with a Script Task. See you then.
Pingback: Sending a Text Message in the Middle of Workflow Using SMS – Script Task version – Questetra Support