ZBrain Documentation
  • ZBrain Documentation
    • ZBrain XPLR
      • ZBrain XPLR modules
      • Get started with ZBrain XPLR
      • Simulation XPLR
      • Solution XPLR
      • Portfolio XPLR
      • Functional Design XPLR
    • ZBrain Builder
      • Components of ZBrain Builder
      • πŸ“šKnowledge base
        • How to create a knowledge base?
        • Knowledge source
        • Information schema
        • File summary
        • Automated reasoning
        • Retrieval testing
        • Knowledge base settings
      • πŸ“±App
        • How to leverage knowledge base for app creation
        • How to set up and customize your app?
        • How to access the app reporting dashboard?
      • πŸ€–ZBrain AI agents
        • Get started with agents on ZBrain Builder
        • Deploying pre-built agents
        • Creating custom AI agents
          • Agent setup
          • Define input sources
          • Define Flow
            • Key elements of a Flow
            • Flow Components
              • Activepieces Platform
              • AITable
              • Airtable
              • Amazon S3
              • Amazon SNS
              • Amazon SQS
              • Amazon Textract
              • Apify
              • Apollo
              • Approval
              • Asana
              • Azure Communication Services
              • Azure Cosmos DB
              • Azure Document Intelligence
              • Azure OpenAI
              • Azure Translation
              • Bannerbear
              • Baserow
              • Beamer
              • Bedrock Claude
              • Bettermode
              • Binance
              • Bing Search
              • Blackbaud
              • Bonjoro
              • Box
              • Brevo
              • Brilliant Directories
              • Bubble
              • CSV
              • Calendly
              • Certopus
              • Clearout
              • Clockodo
              • Code
              • Confluence
              • Connections
              • Constant Contact
              • Contiguity
              • Contentful
              • Customer.io
              • Crypto
              • Databricks
              • Data Mapper
              • Date Helper
              • DeepL
              • Delay
              • Discord
              • Discourse
              • Drip
              • Dropbox
              • Dust
              • Facebook Pages
              • Figma
              • Files Helper
              • Flowise
              • Flowlu
              • Formbricks
              • Frame
              • Freshdesk
              • Freshsales
              • GCloud Pub/Sub
              • GenerateBanners
              • GhostCMS
              • GitHub
              • GitLab
              • Gmail
              • Google Calendar
              • Google Contacts
              • Google Docs
              • Google Drive
              • Google Forms
              • Google Gemini
              • Google My Business
              • Google Search
              • Google Search Console
              • Google Sheets
              • Google Tasks
              • Groq
              • Hacker News
              • Heartbeat
              • HubSpot
              • HTTP
              • Image Helper
              • Inputs
              • Instagram for Business
              • Intercom
              • Invoice Ninja
              • Jira Cloud
              • Jotform
              • Kimai
              • Kizeo Forms
              • LeadConnector
              • Line Bot
              • Linear
              • LinkedIn
              • LinkedIn Actions
              • LLMRails
              • Lusha
              • MailerLite
              • Mailchimp
              • Mautic
              • Microsoft Dynamics 365 Business Central
              • Microsoft Dynamics CRM
              • Microsoft Excel 365
              • Microsoft OneDrive
              • Microsoft Outlook Calendar
              • Microsoft Teams
              • Mixpanel
              • MongoDB
              • Notion
              • Odoo
              • OpenAI
              • OpenRouter
              • Pastebin
              • PDF
              • Postgres
              • PostHog
              • Pushover
              • Qdrant
              • Queue
              • Razorpay
              • Router
              • Salesforce
              • SendGrid
              • ServiceNow
              • SFTP
              • SharePoint
              • Slack
              • SMTP
              • Snowflake
              • SOAP
              • Spotify
              • Stability AI
              • Stable Diffusion Web UI
              • Storage
              • Stripe
              • SurrealDB
              • SurveyMonkey
              • Taskade
              • Telegram Bot
              • Text Helper
              • Trello
              • Twilio
              • Twitter
              • Utilities
              • WhatsApp Business
              • WordPress
              • XML
              • YouTube
              • ZBrain
              • Zendesk
              • ZeroBounce
              • Zoho Books
              • Zoho CRM
              • Zoho Invoice
              • Zoom
            • How to Define a Flow?
            • How to Test Each Step in the Flow?
          • Configure Additional Settings
          • Test and Deploy Agents
          • How to access, monitor, and manage agent performance and tasks?
      • Settings
      • πŸ“–API tutorials
        • πŸ“šKnowledge base
          • Automated reasoning
        • πŸ“±APP
        • πŸ€–Agents
Powered by GitBook
On this page
  • How to Integrate Telegram Bot with ZBrain Flow
  • How to Create a Telegram Bot Connection in ZBrain
  • How to Get a Bot Token for Your Telegram Bot
  • How to Get the Chat ID and User ID in Telegram
  • Actions Available in Telegram Bot Integration
  1. ZBrain Documentation
  2. ZBrain Builder
  3. ZBrain AI agents
  4. Creating custom AI agents
  5. Define Flow
  6. Flow Components

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

  1. Click the β€˜+’ Button in ZBrain Flow: Start a new integration.

  2. Search for Telegram Bot: Type "Telegram Bot" in the search bar.

  3. 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

  1. Provide a Connection Name: Assign a unique name to identify the connection.

  2. Enter the Bot Token: This token grants API access to your Telegram bot.

  3. 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:

  1. Open Telegram: Launch the Telegram app.

  2. Search for BotFather: Type @BotFather in the search bar and select it.

  3. Start a Chat with BotFather:

    • Send the command /start to begin.

    • To create a new bot, send /newbot.

  4. Follow the Prompts:

    • Provide a name for your bot.

    • Assign a unique username ending with "bot" (e.g., MyAwesomeBot).

  5. 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

  1. Open Telegram and search for @getmyid_bot.

  2. Start a chat with the bot by tapping β€˜Start’ or sending the command /start.

  3. The bot will reply with a message containing your Chat ID.

Method 2: Using a Telegram Bot

  1. Create or Use an Existing Bot

    • If you don’t have a bot, create one using BotFather.

    • Get the bot token from BotFather.

  2. Send a Message to Your Bot

    • Open a chat with your bot and send any message.

  3. Use the getUpdates API Method

    • Open your browser and enter the following URL, replacing <YourBOTToken> with your bot’s API token:

https://api.telegram.org/bot<YourBOTToken>/getUpdates
  1. Check the API Response

    • The response will contain user details, including the chat ID and user ID.

    • Example response:

{
  "ok": true,
  "result": [
    {
      "update_id": 123456789,
      "message": {
        "message_id": 1,
        "from": {
          "id": 987654321,  // User ID
          "is_bot": false,
          "first_name": "John",
          "username": "john_doe",
          "language_code": "en"
        },
        "chat": {
          "id": 987654321,  // Chat ID
          "first_name": "John",
          "username": "john_doe",
          "type": "private"
        },
        "date": 1618325643,
        "text": "Hello, bot!"
      }
    }
  ]
}

Method 3: Using @userinfobot

  1. Open Telegram and search for @userinfobot.

  2. Start a chat with the bot.

  3. It will display your user ID and chat ID.

  4. 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

  1. Search for @RawDataBot in Telegram.

  2. Start a chat with the bot.

  3. 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:

https://api.telegram.org/bot<YourBOTToken>/sendMessage
  • Get Chat Details:

https://api.telegram.org/bot<YourBOTToken>/getChat
  • Relative Path Example:

/bot<YourBOTToken>/getUpdates

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:

{
  "Content-Type": "application/json",
  "Accept": "application/json"
}

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:

GET https://api.telegram.org/bot<YourBOTToken>/getUpdates?limit=5
  • To specify a particular user in a group:

GET https://api.telegram.org/bot<YourBOTToken>/getChatMember?chat_id=-123456789&user_id=987654321

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:

{
  "chat_id": "123456789",
  "text": "Hello, this is a test message!",
  "parse_mode": "Markdown"
}

Example JSON Body for Sending Media:

{
  "chat_id": "123456789",
  "photo": "https://example.com/image.jpg",
  "caption": "Here is an image",
  "parse_mode": "HTML"
}

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:

Timeout: 15 seconds

Note: Click 'f' to insert dynamic values for flexible configurations.

PreviousTaskadeNextText Helper

Last updated 1 month ago

πŸ€–