Skip to main content

Connecting Lyzr Agents to Telegram: A Cookbook

This guide walks you through deploying a Lyzr AI agent as a Telegram bot. Once configured, users can message your bot directly and get responses from your agent — no code required.

Prerequisites

  • A Lyzr Studio account with at least one agent created
  • A Telegram account

How It Works


Step 1: Create a Telegram Bot

  1. Open Telegram and search for @BotFather
  2. Send /newbot
  3. Follow the prompts — choose a display name and a username (username must end in bot, e.g. my_lyzr_bot)
  4. BotFather will reply with a bot token that looks like:
  5. Copy and save this token
💡 Keep your bot token private — anyone with it can control your bot.

Step 2: Create the Channel in Lyzr

  1. Open the Agent Builder page in the Lyzr UI
  2. Click the Channels button (top-right toolbar, left of Executions)
  3. Click Configure next to Telegram
  4. Fill in the form:
  5. Click Create Channel
After creation, Lyzr automatically calls Telegram’s setWebhook API. The configured channel will appear in your Channels list.

Step 3: Test Your Bot

  1. Open Telegram and search for your bot by username (e.g. @my_lyzr_bot)
  2. Click Start or send /start
  3. Send any message — your agent should reply within a few seconds

Linking Multiple Agents to a Channel

You can link more than one agent to a single channel. Users can then switch between agents using built-in commands.

Via the Lyzr UI

  1. Open Channels in the Agent Builder
  2. Click Manage agents on your configured channel
  3. Toggle agents on/off to link or unlink them
  4. Each linked agent gets a name used with the /switch command

Via the API

Add an agent:
Remove an agent:
The default agent cannot be removed. To change it, delete the channel and recreate it with a different default agent.

Bot Commands

Once multiple agents are linked, users can interact using these built-in commands: Example:
Agent selection is per-user and persistent — each person’s active agent is remembered across messages until they switch again.

Troubleshooting

Bot doesn’t respond to messages

  • Confirm the webhook was registered by checking the Channels list in the Lyzr UI

Bot token invalid

  • Ensure you copied the full token from BotFather, including the numeric prefix before the colon
  • Send /token to BotFather to regenerate if needed