Send texts to mobile

This application note describes a way to send text messages (SMS) from blocks via a SMS gateway service. It can serve a s boilerplate for anyone that wants to develop a similar script for some other SMS gateway service or simply for someone that just needs the functionality and is happy to use the https://46elks.com/ gateway service used in this example.

Installation

You need a computer with a running blocks server with internet access and a web browser to test this application note.

We have prepared a PIXILAB-blocks-root folder containing everything you need to run the example. Download this ZIP file and unpack it. If you do not know how to do this, read the instructions in the general setup section.

Get your credentials

Goto https://46elks.com/ and register an account and fill the account with some credits. Follow the vendors documentation to obtain a user token and a secret token (password).

Configure the script

Before we can send a text we must set out credentials. They can be set as properties from a task. THis must be done before attempting to send texts. In production environment one may rather store the credentials in a file on the server. The script will look for script/files/SMS_46elks.json The credentials must be stores in JSON format like in the example:

{	
  "user": "u2c8cde7b8f7951bbc18124cf4XXXXXX",
  "password": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

Send a text message from a task

Use a task to send out the message, the phone number must be complete with countrycode like in the example.

Result

A text message is received!