Integrating with the Telegram Bot API Using Appsmith. Allow users to send messages directly to a Telegram group.
Prerequisite:
- Telegram Bot Token
- Telegram chat ID
- Appsmith Account
Topic Covered
- Create Telegram Bot Token
- Creating Authenticating Data source in Appsmith
- Creating an API to Send Messages via the Bot
- Send Telegram Message to bot using Appsmith UI
______________________________________________________________________
- Create Telegram Bot Token
- Open Telegram and search for the BotFather.
- Start a chat with BotFather and use the /newbot command.
- Follow the prompts to create your bot and copy the bot token provided. It will look like this:
-
123456788:ABCDefghIJKlmnoPQRStuvWXyz
2. Creating Authenticating Data source in Appsmith
- Navigate to Data Sources in Appsmith.
- Select Data source as Authenticated REST API
Fill out the form as follows:
- URL: https://api.telegram.org
- Authentication Type: None
- Click SAVE. Your Datasource is now connected and ready to use.
3. Create API query to Send Bot chat message
- Method: POST
- URL: https://api.telegram.org/bot<yourbottoken>/sendMessage
- Body: JSON Format body
{
"chat_id": "123456888”,
"text": "{{MessageInput1.text}}"
}
- Replace your Telegram chat ID
-
Name your API query, save it, and test the connection.
4. Send Telegram Message to bot using Appsmith UI
- Create a simple UI in Appsmith using widgets like a text input and a button.
-
Bind the button's click action to your API query.
{{SendBotMessage.run().then(() => { showAlert('Bot Message sent!', 'success'); });}}
-
Customize the input field to dynamically accept text and send it to the Telegram bot when the button is clicked.
With this setup, your Appsmith app is integrated with Telegram Bot API and ready to send messages dynamically!