With the Telegram plugin you’ll be able to easily set up events in Ubidots that trigger messages in a Telegram group. This is possible thanks to an HTTPS URL provided by the plugin that receives messages and sends them to the group using your own Telegram bot.
1. Creating a Telegram bot
For this plugin to work, we’ll first have to create a bot in Telegram. Follow these steps to do so:
Open the Telegram app.
Tap on the search icon in the upper right corner.
Type "botfather" in the search bar and tap on the BotFather result to start a chat.
In the chat with BotFather, type "/newbot" and send the message.
BotFather will ask you to choose a name for your bot, pick one and send it as a message.
Choose a unique username for your bot. This username must end with the word "bot" (e.g., "myexamplebot"). Send the username as a message.
If the chosen username is available, BotFather will create the bot and provide you with a token. This token will be used as input for this plugin.
2. Setting the plugin up
Go to “Devices” → “Plugins”. Click on the “+” button in the upper right corner, choose the Telegram option, and follow these steps:
Enter your bot’s token.
Name your plugin.
Fill in a description (optional).
3. Telegram group setup
Now it’s time to invite the bot to the group where we want to receive the messages from our plugin/event. Follow these steps:
Open the Telegram app.
Click on the hamburger button and then click on “New Group”. Give it a distinctive name (e.g., "Weather Alerts").
Invite your bot to the group.
Send an initial command-like message to the group (even if the command does nothing). Commands in Telegram start with “/”, so this initial message can be something like “/help”.
4. Creating an event that triggers the Telegram plugin
In this case, the type of action we have to use for our event is the “trigger webhook”. To set up this type of event, follow this guide and remember to introduce the following inputs accordingly:
Place the HTTPS endpoint URL of your plugin in the “URL” field during the “actions” configuration. You can locate this URL by going into your plugin and then heading into its “decoder” section.
Change the default payload with this JSON:
{"groupname": "<GROUPNAME>", "message": "<MESSAGE>"}
Where:
<GROUPNAME>
is the name of the target Telegram group. This input is case sensitive, so make sure to type/copy it exactly as it appears on Telegram.<MESSAGE>
is the content of the message to be sent.
Note: It’s better if you manually type all the double quotes in the payload to avoid any potential format issues.
5. Troubleshooting
You can check the status of the message delivery by reviewing the plugin’s logs. You may also test your bot by sending a direct HTTPS POST request to this plugin's URL using an HTTP tool such as Postman. This request must also have a payload as indicated earlier.