Sending SMS via mobile provider’s REST service.
In this post I would like to show you how can we send SMS messages from ByD utilising REST service. Although I will be using an Australian mobile provider, the process would be similar to any other REST based service.
SDK Items used in this example:
– External Web Service Integration – to define the REST service
– Custom BO – to define the communication parameters and recipient’s phone number / message
– You will have to create a FREE account at https://dev.telstra.com and apply for the API Key and API Secret.
– For now the SMS are restricted to Australian phone numbers.
Sending SMS in our example involves two REST services, first one is called with our API Key /Secret and returns an OAuth token. Then, the token is used to call the second service and send the SMS.
1. Create a new BO:
2. Activate and create new QA screen with the above elements.
3. Add first External Web Service Integration item (EWS) to the solution. Select REST as the service type.
Paste the URL to the first web service (obtained from the DEV portal), you can include the parameters but it won’t matter at this stage as they will be defined in the ABSL later on anyway. As you can see the SDK will pickup the path automatically.
4. In the next screen tick the box “Create communication scenario”. Do not enter any API Keys. Click finish.
You should end up with two new items in the solution explorer.
5. Lets now create the second EWS.
Note the new URL of the second web service.
6. After activating your objects, login to the tenant to add our new communication scenarios.
– User and Application Management -> Communication Arrangements -> New
Select our first webservice EWS_SMS_Auth
Select the associated communication system:
Ignore the Basic setting page and go straight to the Advanced settings. For our basic scenario we will set the Auth method to None and untick the “Use Basic Settings”.
Finish and active the new comm arrangement.
7. Repeat the same steps for the Second web service EWS_SMS_Send.
8. Back to studio. Create a new script file for the action we defined earlier in the BO: sendSMS.
– enter your API key and API secret.
ABSL code is fairly self explanatory, we specify the service name that we want to use, create parameters and execute the service. The only difference between the two REST services is that the second one uses POST call and has actual body content containing the message and recipient’s phone number. The only tricky bit was getting the body string right.
9. Right click on the QA screen in the SDK and select Preview.
– enter a phone number and a message
10. After you’ve hit Send button you should see the response back from the two services. The SMS result string contains the unique message ID that can be later used to query the status of the message (pending, delivered etc).
And here is our SMS:
And that’s it! I hope this post will be helpful to others working on something similar.
ABSL code is attached.