Telegram is a great alternative to SMS alerts, and is also available within Ubidots Events Engine actions.

To provide Telegram notifications delivery at scale, while complying with their API usage guidelines, Ubidots has implemented a Telegram Bot to deliver the thousands of messages that are sent every day using this type of action.

DISCLAIMER: Ubidots adheres to Telegram’s API guidelines and best practices, which might translate into occasional delays in message delivery, and even message loss during peak usage periods. Telegram notifications are provided under a “best-effort” policy and come with no warranty of delivery. WE STRONGLY ADVISE AGAINST USING TELEGRAM FOR MISSION-CRITICAL IOT NOTIFICATIONS.

In this article, you’ll learn how to send Telegram notifications using Ubidots’ Events Engine.

Requirements

  • Ubidots account: trial or licensed.
  • Notification recipients must have an active Telegram account, and the Telegram app installed in their phone. NOTE: Please note that every attempt to deliver messages to numbers not yet registered in Telegram, increases the chance of our service being penalized by Telegram’s API.

Table of Contents

  1. Create a new Telegram Event
  2. Configure the Event "If trigger"
  3. Configure the Telegram "Action"
  4. Start receiving Telegram notifications
  5. Service health and message delivery

1. Create a new Telegram Event

To begin, create a new event from the "Events" section of the "Data" tab in your Ubidots Navbar.

2. Configure the Event "If Trigger"

Next, configure the Event logic using Ubidots’ “ANDs” / “ORs” operators. For additional details on how to configure conditional and complex Event triggers, check out our Creating Conditional Events and Alerts user guide.

3. Configure the Telegram "Action"

With the "If trigger" event logic configured, it is now time to create the action - in this case a Telegram notification:

  • Step 1: Select Send Telegram
  • Step 2: Select the correct country code of the destination number.
  • Step 3: Enter the phone number associated with the Telegram account you wish to notify. Please note that this Telegram user will be set as the admin of a Telegram group called “IoT Notifications”, where all notifications will be sent. This admin may invite further members to the group, allowing for extended communication and discussion around what your IoT Application is notifying everyone about. NOTE: Please note that every attempt to deliver messages to numbers not yet registered in Telegram, increases the chance of our service being penalized by Telegram’s API.
  • Step 4: Customize the “Active trigger” message, which is to be delivered a few seconds after the “If triggers” logic is true.
  • Step 5: (Optional) Customize the “Back to normal” message, which is to be delivered a few seconds after the “If triggers” logic is false, meaning the Event conditions are back to normal.
  • Step 6: Save the Action configuration
  • Step 7: Assign an Event Name and Activity window, then save the Event.

4. Start receiving Telegram notifications

The first time a Telegram notification is sent to the specified recipient, the Telegram user will see 2 new chats pop-up:

1. A direct message from an Ubidots-owned number: The first message indicates the user has been added to a group called “IoT Notifications”. This chat also contains a rejoin link in case the user ever leaves the group by accident. PLEASE KEEP THIS LINK as it is your way back into the group and back to receiving further notifications from Ubidots over Telegram.
NOTE: In case you, or one of your users, leave the group, and lose the rejoin link, feel free to contact us at support@ubidots.com.

2. A group message in the “IoT Notifications” group: The specified Telegram recipient will be named the admin of a new group, where all future Ubidots notifications will be sent to. As an admin, the Telegram user will be able to add other Telegram users, so they are also notified.

5. Service health and message delivery

DISCLAIMER: Ubidots adheres to Telegram’s API guidelines and best practices, which might translate into occasional delays in message delivery, and even message loss during peak usage periods. Telegram notifications are provided under a “best-effort” policy and come with no warranty of delivery. WE STRONGLY ADVISE AGAINST USING TELEGRAM FOR MISSION-CRITICAL IOT NOTIFICATIONS.

We do have, however, a mechanism to mitigate the risk of message loss. When the Telegram API is not available, be it due to a general outage, or a selective banning caused by increased traffic from our side, Ubidots applies the following rules to re-attempt the delivery:

  1. Message will be retried after 60 seg for 5 times. If failed, then:
  2. Message will be retried every 15 minutes for the next 12 hours. If failed, then:
  3. Messages will be dropped and a corresponding note will be reflected in the Event’s log. Also, every re-attempt to send the message will be reflected in the Event’s log.


NOTE: Please note that every attempt to deliver messages to numbers not yet registered in Telegram, increases the chance of our service being penalized by Telegram’s API.

Did this answer your question?