Simple Telegram Bot
Last updated
Last updated
A simple relay communication between Rocket.Chat and Telegram is possible by configuring a basic bot. The guide below shows a community example of how this can be achieved with webhooks.
This gives you the possibility of relaying messages between Telegram and Rocket.Chat in a specified room of your choice.
This integration is not suitable for Omnichannel Conversations. Consult the Telegram App for managing your Omnichannel conversations with Telegram. Workspaces subscribed to any of Rocket.Chat's can install the , which comes with additional functionalities and Omnichannel features.
Log in to your account on your mobile or using a browser.
Add and open a conversation with the user .
Click start.
Send /newbot
to start creating a new bot.
Follow the instructions to continue.
Set the bot's username. Telegram successfully creates the bot and shows how to access it.
Copy the token provided, it is needed for the configuration.
To create an incoming webhook:
Go to Administration > Workspace > Integrations in Rocket.Chat
Enable the integration
Set the webhook integration name.
Set the Post to Channel as the channel created above.
Set Post as, as the user created above.
Enable the script and paste the following code.
Save the integration.
This creates a new incoming integration with a webhook URL and token provided.
Copy the incoming webhook URL provided by Rocket.Chat after saving.
Change the following URL with yourTelegramBotToken
and Incoming webhookURL
and open it on your browser.
A response indicating success is sent which looks like this:
Test your incoming Webhook by sending a telegram message to the Telegram bot.
The message sent gets posted in channel
by the user
you specified in the incoming webhook configuration page.
A Telegram group can be configured to send and receive messages to and from Rocket.Chat.
Create a Telegram group and grant bot access.
Create a new Telegram group.
Get the group chat id. This can be gotten by:
Adding the user RawDataBot
to the group
On joining, a response like below is seen with the chat id
Change the bot group privacy settings so it can listen to all messages by:
Choosing the bot you want to edit.
Setting the status to Disable.
The outgoing integration is used to relay messages back from Rocket.Chat to Telegram.
Go to Administration > Workspace > Integrations in Rocket.Chat.
Select the Message sent as the Event Trigger.
Enable the integration.
Set any Trigger Words which messages must have before they get relayed if needed.
Specify the channel to listen to.
Set the URL following this format:
Enable Script and paste the following code
Save the integration.
Add your bot to the telegram group and enjoy cross-platform communication between Rocket.Chat and Telegram.
Multiple Outgoing Triggers can be configured to cover all use cases.
The incoming webhook is responsible for relaying messages from Telegram into Rocket.Chat into a specific .
Create a new Incoming Webhook following the guide
Sending the message /setprivacy
to .
Create an outgoing webhook following this guide .
The scripts can be customized as needed. Learn more here