Twilio SMS

Description

ezvpn-mqtt-twilio listens on an MQTT broker and sends SMS using the Twilio service.

In IOhubTM architecture, ezvpn-mqtt-twilio subscribes to an MQTT topic (twilio/# by default) on the internal MQTT broker and sends SMS using Twilio.

Twilio schema

How to use it

ezvpn-mqtt-twilio is a Docker container image pre-configured for communication with ezvpn-mqtt and the Twilio SMS API. To use it, you first need a Twilio account with a Twilio phone number with SMS capabilities. When used in combination with ezvpn-fld-exchanger, you have a flexible system that sends SMS based on specific conditions triggered by events.

Twilio configuration

  • Create a Twilio account if you don't have it.

  • Buy a phone number with SMS capabilities.

Number capabilities
  • Open your Twilio Dashboard

  • Copy the ACCOUNT SID content into the TWILIO_ACCOUNT_SID environment variable.

  • Copy the AUTH TOKEN content into the TWILIO_AUTH_TOKEN environment variable.

Twilio dashboard

When a message is sent to the environment variable content MQTT_SUBSCRIBE_TOPIC, the twilio container will forward it as SMS to the destination number set in TWILIO_TO environment variable.

Environment variables

When you start the Twilio container, you can adjust the instance's configuration by passing one or more environment variables to the docker run command.

MQTT Connection

  • MQTT_HOST: MQTT host. Defaults to 127.0.0.1

  • MQTT_PORT: MQTT port. Defaults to 1883

  • MQTT_SUBSCRIBE_TOPIC: IOhubTM MQTT topic to subscribe. Defaults to twilio/#. Subscribe to multiple topics can be obtained by defining each topic on a separate line.

  • MQTT_WANT_QOS2: ask MQTT to upgrade each incoming message on MQTT_IN_TOPIC to QoS 2 (delivery guaranteed). MQTT will honor the request only if persistence is enabled.

  • SKIP_RETAIN: if true, discard all MQTT messages with retain flag set to true. Defaults to false.

With SKIP_RETAIN set to false, each client that subscribes to a topic pattern receives the retained message immediately after they subscribe.

The broker stores only one retained message per topic.

Twilio Connection

  • TWILIO_ACCOUNT_SID: Twilio Account Sid Must be provided.

  • TWILIO_AUTH_TOKEN: Twilio Auth Token Must be provided.

  • TWILIO_TEMPLATE: SMS template. ## DATA ## can be used as a placeholder for the value read from MQTT. ## TOPIC ## can be used as a placeholder for the incoming topic from MQTT. If empty, raw data is sent.

  • TWILIO_FROM: Your Twilio phone number Must be provided.

  • TWILIO_TO: Destination phone number Must be provided.

  • TWILIO_ONE_SMS: if true, messages are cut to 160 characters length. Otherwise message is sent in multiple segments by Twilio, producing multiple charges. Defaults to false.

  • TWILIO_MAX_FREQUENCY: Number of seconds before another messages can be sent. If 0, no limits are set. Default to 30;

  • TWILIO_DRY_RUN: if true, messages are not sent; the message is instead logged on the console. Defaults to false.

Docker container details

Image: us-central1-docker.pkg.dev/ez-shared/iohub/iohub-mqtt-twilio

Supported architecture: amd64

Changelog

v1.0.0
  • First Release