=====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 as a boilerplate for anyone that wants to develop a similar script for some other SMS gateway service, or simply just needs the functionality and is happy to use the https://46elks.com/ gateway service from this app note as is. ===== 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. {{ :blocks:app-note:sms42elks:smsgateway46elks.zip |Download this ZIP file and unpack it}}. If you do not know how to do this, read the instructions in the [[blocks:app-note:start|general setup section]]. ====Getting 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). ====Configuring the User Script==== Before we can send a text we must apply our credentials obtained in the previous step. They can be set as properties from a task. This must be done before attempting to send texts. {{:blocks:app-note:sms42elks:screenshot_2025-05-22_084621.png?800|}} In production environment one may instead store the credentials more securely in a file on the server. The script looks for the file script/files/SMS_46elks.json, expected to be a JSON file with contents like this (but with your credentials, of course): { "user": "u2c8cde7b8f7951bbc18124cf4XXXXXX", "password": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" } ====Send a text message from a task==== Use a task to send a message, the phone number must include the country code, as shown in this example. {{:blocks:app-note:sms42elks:screenshot_2025-05-22_094859.png?800|}} Aternatively, call this function from a another user script, e.g. if your building a [[blocks:advanced_scripting:visitor_identity_tracking|Personal Visitor Experience]]. ====Result==== A text message should be received. {{:blocks:app-note:sms42elks:screenshot_20250522_114557_messages.jpg?200|}} If not, check your log file for any error messages related to the SMS service, such as incorrect credentials.