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 account with an agent already created
- A Telegram account
How It Works
Step 1: Create a Telegram Bot
- Open Telegram and search for @BotFather
- Send
/newbot - Follow the prompts — choose a display name and a username (username must end in
bot, e.g.my_lyzr_bot) - BotFather will reply with a bot token that looks like:
- Copy and save this token
💡 Keep your bot token private — anyone with it can control your bot.
Step 2: Create the Channel in Lyzr
- Open the Agent Builder page in the Lyzr UI
- Click the Channels button (top-right toolbar, left of Executions)
- Click Configure next to Telegram
-
Fill in the form:
Field Value Bot Token Paste the token from BotFather Default Agent Select the agent you want to handle messages - Click Create Channel
setWebhook API. The configured channel will appear in your Channels list.
Step 3: Test Your Bot
- Open Telegram and search for your bot by username (e.g.
@my_lyzr_bot) - Click Start or send
/start - 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
- Open Channels in the Agent Builder
- Click Manage agents on your configured channel
- Toggle agents on/off to link or unlink them
- Each linked agent gets a name used with the
/switchcommand
Via the API
Add 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:| Command | Description |
|---|---|
/agents | List all agents linked to this channel |
/list | Same as /agents |
/switch <name> | Switch to a different agent by name |
Troubleshooting
Bot doesn’t respond to messages
- Confirm the webhook was registered by checking the Channels list in the Lyzr UI
- Make sure your server is publicly accessible — Telegram cannot reach
localhost. Use ngrok for local development - Check your server logs for errors
Bot token invalid
- Ensure you copied the full token from BotFather, including the numeric prefix before the colon
- Send
/tokento BotFather to regenerate if needed