Telegram Bot
A Telegram Bot is an automated program that interacts with users and groups on Telegram. These bots can perform various functions such as sending messages, managing groups, processing commands, and integrating with third-party services. They operate through the Telegram Bot API, allowing businesses, developers, and individuals to automate workflows, provide customer support, and enhance communication.
How to Integrate Telegram Bot with ZBrain Flow
Steps to Integrate Telegram Bot
Click the β+β Button in ZBrain Flow: Start a new integration.
Search for Telegram Bot: Type "Telegram Bot" in the search bar.
Choose an Action: Select the action you want the bot to perform, such as sending messages or managing group members.
How to Create a Telegram Bot Connection in ZBrain
To establish a connection between Telegram and ZBrain Flow, follow these steps:
Steps to Connect Telegram Bot
Provide a Connection Name: Assign a unique name to identify the connection.
Enter the Bot Token: This token grants API access to your Telegram bot.
Click βSaveβ to finalize and establish the connection.
How to Get a Bot Token for Your Telegram Bot
To obtain a bot token, follow these steps:
Open Telegram: Launch the Telegram app.
Search for BotFather: Type
@BotFather
in the search bar and select it.Start a Chat with BotFather:
Send the command
/start
to begin.To create a new bot, send
/newbot
.
Follow the Prompts:
Provide a name for your bot.
Assign a unique username ending with "bot" (e.g.,
MyAwesomeBot
).
Receive Your Token:
BotFather generates and provides a unique API token.
Copy and securely store this token for authentication.
How to Get the Chat ID and User ID in Telegram
Method 1: Using @getmyid_bot
Open Telegram and search for
@getmyid_bot
.Start a chat with the bot by tapping βStartβ or sending the command /start.
The bot will reply with a message containing your Chat ID.
Method 2: Using a Telegram Bot
Create or Use an Existing Bot
If you donβt have a bot, create one using BotFather.
Get the bot token from BotFather.
Send a Message to Your Bot
Open a chat with your bot and send any message.
Use the getUpdates API Method
Open your browser and enter the following URL, replacing
<YourBOTToken>
with your botβs API token:
Check the API Response
The response will contain user details, including the chat ID and user ID.
Example response:
Method 3: Using @userinfobot
Open Telegram and search for
@userinfobot
.Start a chat with the bot.
It will display your user ID and chat ID.
To get a group chat ID, add
@userinfobot
to the group and send a message. The bot will reply with the group chat ID.
Method 4: Using @RawDataBot
Search for
@RawDataBot
in Telegram.Start a chat with the bot.
The bot will provide your chat ID and user ID, along with additional raw data.
Actions Available in Telegram Bot Integration
1. Send Text Message
Sends a text message to users, groups, or channels.
Steps:
Enter the Bot Token.
Enter the Chat ID (identifies the recipient).
Enter the Message Thread ID (for forum supergroups only).
Select the Format β Markdown or HTML for message styling.
Enable/Disable Web Page Preview β Controls link previews in messages.
Enter the Message to be sent.
Enter Reply Markup β Optional, used for buttons or keyboard options.
2. Send Media
Sends images, videos, stickers, or GIFs.
Steps:
Enter the Bot Token.
Enter the Chat ID.
Enter the Message Thread ID (for forum supergroups only).
Select the Media Type β Choose from image, video, sticker, or GIF.
Select the Format β Markdown or HTML for captions.
Enable/Disable Web Page Preview β Controls link previews.
Enter the Message to accompany the media.
Enter Reply Markup β Optional, used for interactive buttons.
3. Get Chat Member
Retrieves information about a user in a group, supergroup, or channel.
Steps:
Enter the Bot Token.
Enter the Chat ID of the group or channel.
Enter the User ID of the member to retrieve details.
4. Create Invite Link
Generates a new invite link for a chat or group with specific access parameters.
Steps:
Enter the Bot Token.
Enter the Chat ID where the invite link should be created.
Provide the Name of the invite link (max 32 characters).
Specify the Expiration Date (point in time when the link will expire).
Enter the Member Limit β Maximum users who can join via this link (1-99,999).
5. Custom API Call
Allows you to send customized API requests to Telegram Bot's API for advanced functionality.
Steps:
1. Enter the Bot Token
The bot token is essential for authenticating API requests.
2. Provide the API Endpoint
The API endpoint is the specific URL where the request is sent. You can either:
Use the full URL for direct API calls.
Use the relative path if working within a system that appends the base URL.
Example API Endpoints:
Send a Message:
Get Chat Details:
Relative Path Example:
3. Select the HTTP Method
The HTTP method determines the type of action performed:
Method
Description
GET
Retrieve chat, user, or message details.
POST
Send new messages, media, or commands.
PATCH
Modify existing data, like editing messages.
PUT
Update bot settings or configurations.
DELETE
Remove messages, revoke access, or delete chat data.
HEAD
Fetch response headers without retrieving full data.
4. Add Headers
Headers provide additional metadata and authentication details for requests.
Authorization headers are automatically included when using the bot token.
You can add custom headers by clicking β+ Add Itemβ for additional functionality.
Example Headers:
5. Add Query Parameters
Query parameters allow you to filter results, set options, or customize API calls.
Example Query Parameters:
To limit the number of updates retrieved:
To specify a particular user in a group:
How to Add Query Parameters:
Click
+ Add Item
to include multiple parameters.Ensure values are correctly formatted to avoid request failures.
6. Enter JSON Body
For POST, PUT, and PATCH requests, structured data must be sent in JSON format.
Example JSON Body for Sending a Message:
Example JSON Body for Sending Media:
7. Set Timeout
The timeout setting ensures that requests do not run indefinitely.
Define the timeout in seconds to prevent API stalling.
Example Timeout Configuration:
Note: Click 'f' to insert dynamic values for flexible configurations.
Last updated