Skip to main content

How to Connect Telegram to AI Agent

Connect your Flametree AI agent to Telegram to automatically process and respond to messages sent to your Telegram bot. This integration uses the Telegram Bot API and a bot token issued by @BotFather.


Prerequisites

  • Access to Telegram mobile app or web version
  • A Flametree account with agent creation permissions
  • Admin access to the Flametree integration settings

Creating and Configuring Telegram Bot

Step 1: Create a Telegram Bot

  1. Find BotFather

    • Open Telegram and search for @BotFather (official bot)
    • Send the /start command to begin
  2. Create New Bot

    • Send /newbot command
    • Follow the setup wizard:
      • Bot Name: Choose a display name (for example, "My Company Support")
      • Username: Must end with bot (for example, mycompany_support_bot)
    tip

    You can customize your bot later using @BotFather commands such as /setuserpic, /setdescription, and /setcommands

  3. Save Your Token

    • BotFather will provide an access token in format: 123456789:AAH...XYZ
    • Keep this token secure — you’ll need it for Flametree integration
    • If the token is invalid, compromised, or belongs to another bot, check it in @BotFather using /mybots or generate a new token

Step 2: Configure Integration in Flametree

  1. Navigate to Settings

    • Go to Settings > Channels
    • Open Telegram
    • Select Add +
  2. Fill Configuration

    FieldDescriptionRequiredDefault
    NameCustom name for this integration-
    DescriptionOptional description for internal reference-
    Bot UsernameBot username in Telegram. Will be displayed on the Flametree platform-
    Telegram Bot TokenToken received from @BotFather-
    Enable telegram streamingShows AI responses as they are generated instead of waiting for the complete responseTrue
  3. Click Save to create the integration

  4. Click Start in the upper-right corner to start the channel.

Step 3: Connect to AI Agent

  1. Open Agent Configuration

    • Navigate to your target AI agent's settings
    • Go to Communication channels section
  2. Assign Channel

    • Select your Telegram integration from the list
    • Save the agent configuration

Configuration Options

Customize features through Set Environment Variables:

VariableDescriptionDefault
SHOW_VOICE_TRANSCRIPTIONShow transcription text for voice messages. Requires Speech-to-Text support for voice message processingTrue
TELEGRAM_SHOW_KEYBOARD_REPLYDisplay control buttons such as clear, thoughts, and stopTrue

Testing Your Integration

  1. Find Your Bot

    • Search for your bot username in Telegram
    • Start a conversation with /start
    tip

    Telegram bots are marked with the BOT label and do not show online status — this is expected behavior

  2. Send Test Message

    • Type any message to your bot
    • Verify the AI agent responds appropriately
  3. Test Voice Messages

    • Send a voice message
    • Check if transcription appears (if SHOW_VOICE_TRANSCRIPTION is true)
    important

    If voice messages are not processed, make sure Speech-to-Text integration is configured in your agent

  4. Check supported message types

    • The integration supports text, voice messages with transcription, images, and basic interaction features
    • Documents and video calls are not supported

Security Considerations

  • Protect the bot token. Anyone with this token can control the bot
  • Rotate the token in @BotFather if it is compromised
  • Configure bot privacy settings in @BotFather using /setprivacy
  • Review group chat permissions if the bot is used in groups
  • Review message retention policies in your Flametree account

Was this article helpful?