Chapter 25. Connecting 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 a simple integration when a Telegram bot that you specify receives a message. The integration passes the message to the next step in the flow. For example, after a simple 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 add a Telegram connection that notifies 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 flow. Details are in the following topics:
25.1. Creating 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.
- 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 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.
- Click Save 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.
25.2. Adding 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 a simple 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.
Select the Read Messages action to receive all messages that are sent to the chat bot.
The connection configuration identifies the chat bot that you want to receive messages from. No other configuration is required.
25.3. Adding a Telegram connection to send a message to a Telegram chat
In an integration, you can send a message to a Telegram chat in the middle of a flow or to finish a simple integration. To do this, add a Telegram connection to the middle of a flow or as a simple integration’s finish connection.
- You created a Telegram connection.
- You are creating or editing a flow and Fuse Online is prompting you to add to the integration. Or, Fuse Online is prompting you to choose a finish connection.
- On the Add to Integration page, click the plus sign where you want to add the connection. Skip this step if Fuse Online is prompting you to choose the finish connection.
- Click the Telegram connection that you want to add to the flow.
- Select 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 Next to add the connection to the flow.