Twilio SMS

Introduction

Twilio is a web service that can be used to send SMS.

Prerequisites

  • A Twilio account is required.
  • From your Twilio account console, note Account SIDAuth Token, and Phone number.

Configure Twilio within the NETx Core Studio

  • In the Core Studio, open Modules > Messenger > [Live] Twilio SMS.
  • Right-click to open the context menu and select Insert new definition to add a new profile.
  • Fill the following fields:

    • Profile: profile name
    • AccountSidAccount SID as in your Twilio console
    • AuthTokenAuth Token as in your Twilio console
    • SenderPhoneNumer: the Phone number as in your Twilio console
  • Save the definition table. Changes are immediately applied.

Send a message via XLogic

Use a Twilio SMS messenger profile in combination with the Messenger.SendSms XCommand.

Testing

To test the profile from the Core Studio,

  • Go to Tools > Run XCommand.
  • Select XCommand MESSENGER.SENDSMS and fill the required fields:
    • Profile: the name of the configured profile
    • Recipient: recipient phone number
    • Message: message text as string
  • Click Execute to send the message.

You will receive the message on the device with the provided phone number, shortly.

Send a message from an action

In order to send an SMS triggered by an alarm or a conditional event,

  • Set up an action that uses the MESSENGER.SENDSMS XCommand.
  • Select the configured Twilio profile and provide Recipient and Message.
  • Save the action.
  • Use this action in the desired alarm or conditional event.

Send a message via LUA

To send an SMS within LUA scripts, use the XMessage LUA function.

XMessage is general LUA function that can be used to send notification and visualization message via LUA. For sending telegram messages, use the following parameter values:

  • Device: not used for sending SMS. Leave empty.
  • UserOrGroup: not used for sending SMS. Leave empty.
  • MessageType: "TwilioSms"
  • Parameter1: name of the Twilio SMS messenger profile
  • Parameter2: recipient phone number
  • Parameter3: message text as string

The following example uses the Twilio SMS messenger profile "tw" to send an SMS:

nxa.XMessage("","","TwilioSms","tw", "+436641234567", "This is an SMS sent by LUA.")