Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
blocks:app-note:sms42elks [2025-05-22 09:48]
mattias [Send a text message from a task]
blocks:app-note:sms42elks [2025-05-30 08:43] (current)
admin
Line 1: Line 1:
 =====Send texts to mobile===== =====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 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. +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 serviceor simply just needs the functionality and is happy to use the https://46elks.com/ gateway service from this app note as is.
-===== Installation =====+
  
 +===== Installation =====
 You need a computer with a running blocks server with internet access and a web browser to test this application note. 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. 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}}+{{ :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====
-If you do not know how to do this, read the instructions in the [[blocks:app-note:start|general setup section]]. This zip archive is a bit different from the other application notes, it has a blocks server config file and the root folder. The Blocks config file is a sample file showing the format of the mail settings that need to be set in your own blocks config file to enable the email feature in Blocks.  +
- +
-====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).  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==== +====Configuring the User 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. +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|}} {{:blocks:app-note:sms42elks:screenshot_2025-05-22_084621.png?800|}}
-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:+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 JSON file with contents like this (but with your credentials, of course): 
 <code> <code>
 {  {
Line 31: Line 29:
 ====Send a text message from a task==== ====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.+Use a task to send 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|}} {{: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==== ====Result====
  
-{{:blocks:app-note:sms42elks:screenshot_20250522_114557_messages.jpg?400|}}+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.