Telegram Channel Setup
Connect your AI agent to Telegram, enabling users to chat with your agent through Telegram's messaging platform either individually or in groups.
Overview
A Telegram channel allows your agent to:
Receive messages from users in direct messages or group chats
Send text, images, videos, and other media
Support rich media content in conversations
Work seamlessly across Telegram's web, mobile, and desktop apps
Prerequisites
Before you begin, you'll need:
A Telegram account - You'll need a Telegram account to create a bot
A published agent in your Stage5 project that you want to connect to Telegram
Step 1: Create a Telegram Bot
Open Telegram and search for @BotFather (Telegram's official bot for creating bots)
Start a conversation with BotFather
Send the command
/newbotBotFather will ask for a name for your bot - choose a descriptive name (e.g., "Customer Support Assistant")
Next, choose a username for your bot. It must end with
bot(e.g.,my_customer_support_bot)If the username is available, BotFather will confirm and provide you with a bot token
Save this token - you'll need it in Step 3 (it looks like:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz. See the image below. You need the copy all of the line marked in the red arrow)

Step 2: Configure Bot Settings (Optional)
You can customize your bot with BotFather:
Set bot description: Use
/setdescriptionto tell users what your bot doesSet bot picture: Use
/setuserpicto add a profile pictureSet about text: Use
/setabouttextto add a short "About" message
Step 3: Save the token as a secret in Stage5
Required Secrets
You'll need to store the bot token as a secret in your project's Secret Vault:
Bot Token Secret Key - The expected value is the name of the secret storing your Telegram bot token (from Step 1). The assistant will use a placeholder name like
telegram-bot-token, which you can change if needed.
Inside a project, click on the cog sign in order to access the project settings:

Once in the project settings, click on the Secrets menu item and add a new secret by following these instructions:
Click the Add Secret button in the top-right corner
Fill in the secret information:
Secret Key (Required): A unique identifier for your secret (e.g.,
telegram-bot-token)Secret Value (Required): The actual secret value (the token)
Description (Optional): A note about what this secret is used for and extra relevant information for your team members (for example, how to get this value in case that's needed).
Click Create Secret to save
Step 4: Configure the Channel in Stage5
In your Stage5 project, in order to create or edit a channel manifest file, just instruct the assistant. For example: "Connect the Customer Support Agent to a Telegram channel. Make sure to have placeholders for all of the Secrets that are needed and I'll add them later." Behind the scenes the Stage5 Assistant will create it all, leaving you just to set the secrets.
What Gets Created
When you instruct the assistant, it will create a channel manifest file similar to this:
Required Secrets
You'll need to store the bot token as a secret in your project's Secret Vault:
Bot Token Secret Key - The name of the secret storing your Telegram bot token (from Step 1). The assistant will use a placeholder name like
telegram-bot-token, which you can change if needed.
Configure the required secrets. For more information see the "Storing Secrets" section.
Step 4: Publish Your Channel
Publish your channel to the desired environment (Production, Staging, etc.)
Stage5 will automatically configure the webhook with Telegram
Your bot is now ready to receive messages!
Step 5: Test Your Channel
Open Telegram and search for your bot using its username (the one ending in
bot)Start a conversation with your bot by clicking "Start" or sending
/startSend a test message
Your agent should respond within a few seconds
If you don't receive a response, check:
Your bot token is correctly stored in the Secret Vault (see "Storing Secrets" section)
The channel was successfully published
Configuration Options Reference
Channel Name
Type: String
Required: Yes
Description: A descriptive name for your Telegram channel (e.g., "Customer Support Bot")
Channel Description
Type: String
Required: Yes
Description: Brief explanation of what this channel is for
Agent Manifest Path
Type: String
Required: Yes
Description: Path to your agent manifest file (e.g., "agents/support-agent.json")
Bot Token Secret Key
Type: String (secret key name)
Required: Yes
Description: The name of the secret in your Secret Vault that stores your Telegram bot token (obtained from BotFather)
Self-Registration Options
See the main Channels documentation for details on:
selfRegistrationForExistingUsersEnabledselfRegistrationForNewUsersEnabledselfRegistrationForExistingUsersDisabledMessageselfRegistrationForNewUsersDisabledMessageuserDisabledMessageuserDeletedMessage
Troubleshooting
Bot Not Responding
Check bot token: Verify your bot token is correctly stored in the Secret Vault and matches the token from BotFather (see "Storing Secrets" section)
Check agent: Verify your agent is correctly configured and published
Test with BotFather: Use
/getmecommand with BotFather to verify your bot token is still valid
Can't Find Bot in Telegram
Check username: Make sure you're searching for the correct username (ending in
bot)Bot may be disabled: If you disabled your bot with BotFather, re-enable it with
/unfreezeTypo in username: Double-check for typos in the username
Bot Not Receiving Messages
Webhook configuration: Stage5 automatically configures the webhook when you publish. If messages aren't coming through, try republishing the channel
Check bot status: Use BotFather's
/getmecommand to ensure your bot is activeGroup permissions: In group chats, verify the bot has permission to read messages
Invalid Token Error
Token format: Ensure your token looks like
123456789:ABCdefGHIjklMNOpqrsTUVwxyz(numbers, colon, letters/numbers)Token expiry: Bot tokens don't expire, but double-check you copied the entire token correctly
Regenerate if needed: You can always generate a new token with BotFather using
/tokenif needed
Best Practices
Clear bot description: Set a helpful description so users know what your bot does
Welcome message: Consider setting an about text that welcomes users and explains what the bot can help with
Handle
/startcommand: Your agent should handle the/startcommand, which users typically send when first chatting with a botTest in private first: Test your bot in direct messages before adding it to group chats
Monitor usage: Keep an eye on how users interact with your bot to improve responses
Security Considerations
Never share your bot token: Keep your bot token secure and only store it in your Secret Vault
Token regeneration: If you suspect your token is compromised, you can regenerate it with BotFather using
/revokeand/tokenGroup chat moderation: In public groups, consider implementing moderation to prevent abuse
Rate limiting: Telegram has rate limits - Stage5 handles these automatically, but be aware of them for high-traffic bots
Advanced Features
Webhooks vs Long Polling
Stage5 uses Telegram's webhook API for real-time message delivery. This provides:
Faster message delivery
More reliable connections
Automatic webhook management
The webhook is automatically configured when you publish your channel, so you don't need to worry about this technical detail.
Getting Help
If you encounter issues:
Check the Troubleshooting section above
Verify your configuration matches the examples
Test with BotFather commands to ensure your bot token works
Ensure your agent is correctly configured and published
Check Stage5 logs for any error messages. If needed you can also reach out to us in our Slack Community.
Last updated