Skip to content

SMS notifications

It is possible to send SMS messages from the bot to notify users of important events that require attention.

Programmatically sending SMS messages is done using the sms_notify() function.

Installation

Sending SMS messages is integrated via Twilio programmable SMS, so you need a Twilio account set up. Additionally, you need to create an SMS service resource using the Twilio console. This will give you the service ID that you need.

To integrate into DialoX, create a YAML file called twilio in your bot, and add the credentials from Twilio:

sms_notify:
  account_sid: "ACa70df98e790a87d98a7fd98d79fae876"
  service_sid: "MG805ad87f5d907f5e9a875d97a5f70aed"
  token: "78ffff87aed07a0d868976a0d896fda8"

Usage

After you have set up your bot with the Twilio credentials you can use the sms_notify() function. It takes a phone number and a message:

dialog sms_test do
  sms_notify("+31641234567", "I have a message for you!")
end

The phone number must be specified in full international format, e.g. +31641345678. The sender of the SMS is configured by your Twilio SMS service.

Linking back to the chat

Using the shorten_url() function combined with chat_link(), you can create a link back into the conversation:

dialog sms_test do
  url = shorten_url(chat_link("web_pwa", user_id: user.user_id))
  sms_notify("+31641234567", "I have a message for you, read it here: #{url}")
end