Skip to content
Tech blog

Send PLC alarms via Telegram or Threema

A fault in the plant, and you know about it right away on your phone. DataSuite sends alarms from your PLC via Telegram or Threema. Here is how to set it up.

Content overview

How the alert gets from the controller to your phone

DataSuite monitors the variables of your controller. A trigger reacts to a condition, such as a fault bit or a limit value, and then runs the action “Send message”. The message goes via Telegram or Threema to a person or a group and can contain current values from the controller, for example the fault code.

Like email and SMS, Telegram and Threema are part of DataSuite's alerting. It is included in the STANDARD, PRO and FLAT editions (prices). Which faults are worth an alert is covered in the article Respond faster to faults with factory alarms.

Setting up Telegram

Telegram sends the messages via a bot. Bots are free of charge, and creating one takes only a few minutes.

Create a bot with BotFather

  1. Search for “BotFather” in the Telegram app on your PC or smartphone and open the chat.
  2. Write /start to begin the dialogue.
  3. Write /newbot and enter a name. It will later appear as the sender in the chat.
  4. Choose a user name for the bot. It must end in “bot”, for example “Roller1Bot”.
  5. BotFather replies with the API token of your bot. Keep it safe: anyone who knows it can control the bot.
Chat with the Telegram BotFather: /newbot, name DataSuite, user name DataSuiteBot, reply with the API token (made unreadable)
Creating a bot in the chat with BotFather; the token has been made unreadable here

Create a group and add the bot

A bot writes to a group it is a member of. This way one message reaches everyone who is responsible for a machine, for example.

  1. Create a new group from the side menu of the Telegram app and add the bot as a member.
  2. Open “Manage group” via the three dots at the top right and set the “Group type” to “Public Group”.
  3. Enter a link name, for example the name of the group, and save in both dialogues.

You will later enter the link name of the public group in DataSuite as the recipient, preceded by @, for example @Walze1Halle4.

Using a private group

If the group should not be public, you need its chat ID. Run the trigger once with the public group and then open its log. In Telegram's reply, the ID is in the chat section, not in the from section. Copy it in full, including the minus sign at the beginning, as the recipient. You can then set the group to private.

DataSuite log entry with Telegram's reply; the ID -1001662134216 in the chat section is highlighted
The chat ID of the group is in the trigger log, in the “chat” section

Create a Telegram account in DataSuite

  1. In DataSuite, click “Create new account” under “Accounts”.
  2. Select “Telegram account” and click “Create”.
  3. Enter the token of your bot as the API key.

The time limit of the account sets the maximum number of messages per minute and per hour. This prevents a flood of messages if a condition keeps changing.

Jetzt kostenlos beraten lassen

In einem Videocall oder einem Telefonat mit einem unserer Experten werden Ihre Fragen beantwortet. Konkrete Anforderungen und Projekte können direkt besprochen werden.

Die Terminbuchung wird mit Microsoft Bookings durchgeführt, es gilt die Datenschutzerklärung von Microsoft.

Markus Bläser

Setting up Threema

Threema sends messages from software via the Threema Gateway. It is a paid service from Threema; each message costs gateway credits. DataSuite only forwards the request to the gateway, so make sure there is always enough credit.

What you need

  • a gateway ID as the sender: it always starts with an asterisk, for example *ABC1234
  • the secret for this gateway ID, which you receive after creating it in the Threema Gateway
  • the Threema app on the recipient's side; for companies, Threema Work lets you manage the accounts centrally

The name the app shows as the sender is the “public name” of the gateway. You set it on the gateway page.

Create a Threema account in DataSuite

Under “Accounts”, use “Create new account” to create a “Threema account” and fill in these fields:

  • Sender: your gateway ID with the asterisk at the beginning
  • API key: the secret of the gateway ID
  • Debug mode: while it is active, DataSuite does not send any requests to the gateway. This lets you test triggers and conditions without using credits.

The Threema account also has a time limit for messages per minute and per hour. With Threema in particular, it protects you from high costs caused by messages sent by mistake during commissioning.

Sending the message in a trigger

Create a trigger with the condition the alert should react to and add the action “Send message” for Telegram or Threema. The action has three fields:

  1. Account: the Telegram or Threema account used to send the message
  2. To: for Telegram, the link name of the group with @ or the chat ID of the private group; for Threema, the Threema ID of the recipient; variables are possible here too
  3. Message: the text of the alert; use “var+” to insert variables from the controller, such as the fault code
Action “Send message” for Telegram: account, recipient @Walze1Halle4 and the message “Malfunction in the system!” with the variable Steuer-DB.Errorcode
Telegram message with the error code from the controller
Action “Send message” for Threema: account, recipient ID 3WJU8WC7 and the message “Malfunction in the system!” with the variable Steuer-DB.Errorcode
The same alert via Threema to a Threema ID

You can test DataSuite free of charge and try out the alerting with the built-in PLC simulator before you connect a real controller.

Error codes

If a message cannot be sent, DataSuite reports an error code. Telegram uses the range 2000 to 2099, Threema 2100 to 2199. Details are in the trigger log.

TelegramThreemaMeaning
20002100Ok
20012101Unknown error
20102110Account invalid (see log)
20112111Sender invalid
20122112API key is invalid
20132113Account not found
20202151Too many messages in the last hour or minute (time limit)
–2160The request could not be executed (see log)
–2161Authorisation error (see log)
–2162The credit of the Threema Gateway is insufficient

If you get stuck, our support team will help you free of charge:
Phone: +49 2742 72927 80
Email: support@mb-datasuite.com

Conclusion

With DataSuite, fault alerts from the controller go straight to your phone. Telegram is quick to set up and free of charge: create a bot with BotFather, add it to a group and enter the token in DataSuite. Threema runs via the paid Threema Gateway; debug mode and the time limit keep costs under control during commissioning. In both cases the message can contain current values from the controller.

Download trial software

Test all functions free of charge for 30 days. You will receive an email with a download link for instant use.

Monitor showing “Download DataSuite 3”