Chapter 19. Connect to Telegram
As a business user, you can create an integration that connects to Telegram. A connection to Telegram can do either one of the following:
- Trigger execution of the integration when a Telegram bot that you specify receives a message. The integration passes the message to the next step in the integration. For example, after an integration receives a message there might be a filter step that watches for keyword instances such as product names. Upon finding messages that contain those product names, the integration can notify the appropriate contact in a Gmail connection or in a different Telegram connection.
- Deliver a message to a particular Telegram chat. For example, this behavior is useful when an integration downloads a file from an FTP server and processes it in some way. You can finish an integration by notifying a Telegram chat that the process was successful.
To connect to Telegram in an integration, create a Telegram connection and then add the connection to an integration. Details are in the following topics:
19.1. Create a Telegram connection
In an integration, a Telegram connection can receive messages that have been sent to a particular chat. A chat bot that you create forwards the messages to Fuse Online. A Telegram connection can also send messages to chats that the connection has access to. You can use the same Telegram connection:
- In any number of integrations that use the connection to send messages to a chat.
- In addition, you can use it in one integration that uses the connection to receive messages from a Telegram chat.
In other words, you cannot use the same Telegram connection in more than one integration if you want that connection to receive Telegram chat messages in both integrations. This is a Telegram limitation.
- In Telegram, you created a bot for the chat that you want to obtain messages from and send messages to. For help with this, see Bots, an introduction for developers.
- You obtained a bot authorization token from the Telegram BotFather.
- In Fuse Online, in the left panel, click Connections to display any available connections.
- In the upper right, click Create Connection to display Fuse Online connectors.
- Click the Telegram connector.
- In the Authorization Token field, enter the Telegram authorization token for the bot that you want to get messages from and send messages to.
- Click Next.
In the Connection Name field, enter your choice of a name that helps you distinguish this connection from any other connections. For example, enter
Telegram for Product Mentions.
- In the Description field, optionally enter any information that is helpful to know about this connection.
- In the upper right, click Create to see the updated list of available connections, including the connection that you just created. If you entered the example name, you would see that Telegram for Product Mentions appears as a connection that you can choose to add to an integration. You can add this connection to any number of integrations.
19.2. Add a Telegram connection to trigger integration execution upon receiving messages
A Telegram connection that starts an integration triggers execution of the integration each time that the connection receives a message from a Telegram chat bot that you specify.
- You created a Telegram connection.
- You are creating an integration and Fuse Online is prompting you to choose how you want to start the integration.
- Click the Telegram connection that you want to use to start the integration.
Click the Read Messages action to receive all messages that are sent to the chat bot.
The connection identifies the chat bot that you want to receive messages from. No other configuration is required.
19.3. Add a Telegram connection to send a message to a Telegram chat
In an integration, you can send a message to a Telegram chat to finish an integration or in the middle of an integration.
- You created a Telegram connection.
- You are creating or editing an integration. If you are creating an integration, then Fuse Online might be prompting you to choose a finish connection. To add a middle connection, hover over the plus sign in the left panel in the location where you want to add the connection and select Add a connection.
- Click the Telegram connection that you want to add to the integration.
- Click the Send a Text Message action.
In the Chat Id field, enter the ID for the Telegram chat that you are sending a message to.
If you leave this field blank, and if there is an earlier Telegram connection that receives messages, then Fuse Online uses the chat ID that is in an incoming message.
To obtain the ID for a chat:
- In Telegram, add a bot to the chat that you want to send a message to. The BotFather response includes a bot access token.
- Copy the access token to the clipboard.
- In Telegram, send a message directly to that chat. Do not use the bot to send the message.
Read messages that are sent to that chat by invoking a
curlcommand in the following format. Replace
bot-access-tokenwith the access token in the clipboard.
The response is in JSON format. The JSON
chatobject contains the chat ID.
- Click Done to add the connection to the integration.