Telegram is one of the best platforms for running AI-powered bots. Its Bot API is mature, well-documented, and offers features that most other messaging platforms lack. In this guide, we will cover everything you need to create a Telegram bot powered by Moltbot and managed through Molty by Finna.
Why Telegram for AI Bots?
Before diving into the setup, it is worth understanding what makes Telegram particularly well-suited for AI assistants:
- No approval process - Unlike WhatsApp Business API, you can create a bot instantly
- Rich formatting - Markdown support, inline buttons, and media handling
- Group support - Bots can participate in group conversations
- No rate limits for small bots - Telegram is generous with API limits for most use cases
- Privacy features - Users choose to interact with your bot, and you can configure privacy modes
These advantages make Telegram the go-to choice for many bot developers, and Moltbot's integration takes full advantage of them.
Step 1: Create Your Bot with BotFather
Every Telegram bot starts with BotFather, Telegram's official tool for managing bots.
- Open Telegram and search for
@BotFather. - Start a conversation and send the command
/newbot. - BotFather will ask for a display name. Choose something descriptive like "My AI Assistant" or your company name.
- Next, provide a username. This must end in "bot" - for example,
my_company_assistant_bot. Usernames are unique across all of Telegram, so you may need to get creative. - BotFather will respond with your bot token. It looks something like
7123456789:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw.
Important: Keep this token secret. Anyone with the token can control your bot. Do not share it in public repositories, screenshots, or chat messages.
Optional BotFather Configuration
While you are in BotFather, consider setting up a few extras:
/setdescription- Set what users see before they start the bot/setabouttext- The text shown in the bot's profile/setuserpic- Upload a profile photo for your bot/setcommands- Define command suggestions (we will revisit this later)
These are not required for the bot to work, but they make it look more professional.
Step 2: Set Up Your Gateway on Molty
If you do not already have a Molty by Finna account, sign up at finna.cloud. Then:
- From the dashboard, click "Create Gateway."
- Name your gateway. This is an internal name for your reference - users will see the bot name you set in BotFather.
- Select a region. Choose one close to where most of your users are located.
- Wait for the gateway to finish provisioning (about 60 seconds).
Your gateway is a dedicated virtual machine running on Fly.io. It handles all the AI processing, conversation management, and channel connections in an isolated environment.
Step 3: Connect Telegram to Your Gateway
With your gateway running and your bot token in hand:
- Open your gateway in the Molty dashboard.
- Navigate to the "Channels" tab.
- Find Telegram in the channel list and enable it.
- Paste your BotFather token into the Telegram token field.
- Save the configuration.
Moltbot will establish a connection to Telegram's servers using your bot token. Within seconds, you should see the channel status change to "Connected."
Testing the Connection
Open Telegram and find your bot by searching for the username you created. Send a message - something like "Hello!" The bot should respond through Moltbot's AI, confirming the connection is working.
Step 4: Configure Bot Behavior
Now that the basic connection works, let us fine-tune how your bot operates.
System Prompt
The system prompt is the most important configuration for your bot's personality and capabilities. Navigate to the Skills tab in your gateway settings to set it up. A good system prompt might include:
- Who the bot is and what organization it represents
- What topics it should be helpful with
- What tone to use (formal, casual, friendly, technical)
- Any boundaries or topics to avoid
- Specific knowledge or context about your business
For example, a customer support bot might have a prompt like: "You are the support assistant for Acme Corp. Help customers with product questions, order status, and troubleshooting. Always be friendly and professional. If you do not know something, say so honestly and suggest contacting human support."
AI Model Selection
Moltbot supports multiple AI providers. Through Molty, you can select:
- Anthropic Claude - Excellent for nuanced, detailed responses
- OpenAI GPT - Strong general-purpose option
- Other providers as they become available
Choose based on your use case. For customer-facing bots, Claude's careful and thorough style often works well. For quick utility bots, a faster model might be preferable.
Understanding Group vs DM Modes
Telegram bots can operate in both direct messages (DMs) and group chats. The behavior differs significantly.
Direct Messages
In DMs, the bot responds to every message. This is the default and most common setup. The conversation is private between the user and the bot, and context is maintained throughout the session.
Group Chats
Group behavior requires more nuance. By default, Telegram bots in groups only receive messages that:
- Start with a
/command - Directly mention the bot using
@yourbotname - Are replies to the bot's messages
This is controlled by Telegram's "privacy mode," which is enabled by default. You can disable it through BotFather with /setprivacy, but we recommend keeping it on. Nobody wants a bot that reads every message in every group.
Configuring Group Behavior
In your Molty dashboard, you can configure how the bot handles group interactions:
- Reply mode - Bot only responds when directly mentioned or replied to
- Command mode - Bot only responds to slash commands
- Mixed mode - Bot responds to mentions and commands
For most use cases, reply mode strikes the best balance between helpfulness and not being intrusive.
Setting Up Bot Commands
Telegram supports slash commands - those /start, /help, /settings prompts that appear when users type / in the chat. These make your bot more discoverable and easier to use.
Defining Commands in BotFather
- Open BotFather and send
/setcommands. - Select your bot.
- Send a list of commands in this format:
start - Start the assistant
help - Show available commands
reset - Clear conversation history
These commands will appear as suggestions when users type / in the chat.
How Moltbot Handles Commands
Moltbot processes slash commands as regular messages. When a user sends /help, the AI receives it as text and responds accordingly. Your system prompt should include instructions on how to handle common commands.
For example, add to your system prompt: "When users send /help, provide a brief overview of what you can do and how to interact with you. When they send /reset, acknowledge that the conversation has been cleared."
Tips for Good Telegram Bot Design
Keep It Conversational
The best Telegram bots feel like chatting with a knowledgeable friend, not interrogating a database. Configure your system prompt to encourage natural, flowing dialogue.
Use Formatting Thoughtfully
Moltbot will automatically format responses for Telegram, including:
- Bold and italic text
Code blocksfor technical content- Numbered and bulleted lists
- Links with proper previews
Use these to make responses scannable, but do not overdo it. A wall of bold text is just as hard to read as a wall of plain text.
Handle Errors Gracefully
Sometimes things go wrong - the AI model might be slow, a tool call might fail, or the user might send something unexpected. Configure your assistant to handle these situations with helpful, non-technical messages.
Set Response Length Expectations
Telegram messages can be long, but mobile screens are small. Aim for responses that are informative without being overwhelming. For complex topics, break information into digestible chunks and offer to elaborate on specific points.
Profile and Branding
Take advantage of Telegram's bot profile features:
- A clear, recognizable profile picture
- A concise "About" text explaining what the bot does
- A description that appears before users start the bot
- A relevant username that is easy to remember and share
Troubleshooting
Bot Not Responding
- Check the channel status in Molty - it should show "Connected."
- Verify the bot token is correct and has not been regenerated in BotFather.
- Make sure the gateway is in the "Running" state.
- Check gateway logs for error messages.
Bot Responds Slowly
- Try a different AI model (some are faster than others)
- Check if tools like web search are being triggered unnecessarily
- Ensure your gateway region is close to your users
Token Issues
If you regenerate your bot token in BotFather (using /revoke), you must update it in the Molty dashboard as well. The old token will stop working immediately.
Group Permissions
If the bot is not responding in groups:
- Verify it has been added to the group with appropriate permissions
- Check if privacy mode is blocking message access
- Make sure users are mentioning the bot or using commands
Advanced Configuration
Webhook vs Polling
Moltbot uses long polling by default for Telegram connections. This is reliable and works without any special network configuration. For high-traffic bots, the system automatically manages connection efficiency.
Multi-Channel Setup
One of Moltbot's strengths is running across multiple channels simultaneously. After setting up Telegram, consider adding WhatsApp, Discord, or Slack. Each channel connects to the same gateway, sharing the same AI configuration but adapting to each platform's conventions.
Monitoring and Analytics
Keep an eye on your bot's usage through the Molty dashboard. You can review conversation logs, monitor response times, and track connection health. This data helps you refine your system prompt and configuration over time.
Wrapping Up
Setting up a Telegram bot with Moltbot through Molty by Finna is a process that takes minutes rather than days. The combination of Telegram's excellent bot platform and Moltbot's AI capabilities gives you a powerful assistant that can handle everything from casual conversation to complex task automation.
Start with a simple configuration, test it thoroughly, and iterate based on real user interactions. The best bots are built through continuous refinement, not a single perfect setup.