ChatbotAssistant

Chatbot Integration with Telegram Bot

This guide will walk you through the process of integrating our chatbot with the Telegram Bot API. After completing all the steps, your users will be able to communicate with the chatbot directly through the Telegram application. The guide also covers configuring special commands for the bot.

Important prerequisites: To complete the integration, you need to have an account on the ChatbotAssistant platform with an active subscription, as well as access to the Telegram application (mobile or desktop) to create a bot through BotFather.

Select Your Starting Point

0

Integration Process Overview

Integrating a chatbot with Telegram Bot is a process that consists of several main stages:

  1. Creating a bot in Telegram - creating a new bot using BotFather and obtaining an access token.
  2. Configuring the chatbot on the platform - creating a new chatbot with Telegram Bot functionality, entering the token, and automatic webhook configuration.
  3. Managing commands - configuring special commands for the bot that will be available in the Telegram menu.
  4. Testing and optimization - verifying the bot's operation and adjusting settings.
Estimated time: The entire integration process usually takes 15 to 30 minutes, depending on your experience with the Telegram platform. The guide below will walk you through all stages step by step.
Tip: Before starting the integration process, make sure you have access to:
  • The Telegram application on your phone or computer
  • An account on the ChatbotAssistant platform with an active subscription
  • Basic knowledge of how Telegram works (optional)
1

Creating a Bot in Telegram via BotFather

The first step is to create a new bot in Telegram through the official BotFather. BotFather is a special Telegram bot used to manage all bots on the platform.

BotFather
The official bot for managing Telegram bots

Detailed instructions:

  1. Open the Telegram application on your phone or computer.
  2. Search for BotFather - in the search field, type @BotFather and select the official bot (it will have a blue verification icon).
  3. Start a conversation with BotFather by clicking the "Start" button or sending the /start command.
  4. Create a new bot by sending the command:
    /newbot
    Command to create a new bot
  5. Provide a bot name - BotFather will ask you to provide a name for the bot. The name can contain spaces and special characters. Examples:
    Example names: - Shop Assistant - World Flavors Restaurant Bot - Customer Service Center
  6. Provide a bot username - next, you need to provide a unique username for the bot. The username must:
    • End with the word "bot" (e.g. myshopbot or my_restaurant_bot)
    • Be unique across the entire Telegram system
    • Contain only letters, numbers, and underscores
    • Be between 5 and 32 characters long
    Example usernames: - myshopbot - restaurant_flavors_bot - techsupport_assistant_bot
  7. Copy the bot token - After successfully creating the bot, BotFather will send you a message containing the access token. The token looks similar to this:
    1234567890:AAEhDOM50CUBO9QIugrsgHP2g61FE15LAVwbdbIx
Token security: The Bot Token is very sensitive information that provides full control over your bot. Do not share it with anyone and do not place it in publicly accessible locations. Treat it like a password to your account.
Tip: If the entered username is already taken, BotFather will inform you and ask you to provide a different one. You can add numbers or additional words to create a unique username.

Common issues at this stage:

Bot username is already taken

If the entered username is already taken, try the following solutions:

  • Add numbers at the end (e.g. myshopbot2024)
  • Add an additional word describing the industry (e.g. myshopfurniturebot)
  • Use underscores to separate words (e.g. my_shop_bot)
  • Add a location (e.g. myshoplondonbot)
BotFather does not respond to commands

If BotFather does not respond to your commands:

  • Make sure you are writing to the official @BotFather (with the blue verification icon)
  • Check that the command starts with the / (slash) character
  • Try sending the /start command to restart the conversation
  • Check your internet connection and try again
2

Configuring the Chatbot on the ChatbotAssistant Platform

Now configure the chatbot in our system to connect it with your Telegram bot and give it AI intelligence.

Detailed configuration instructions:

  1. Go to the chatbot form - Log in to your account on the ChatbotAssistant platform and navigate to the dashboard.
  2. Start creating a new chatbot - Click the "Create New Chatbot" button.
  3. Select the Telegram Bot functionality - In the "Select chatbot functionality" section, check the "Telegram Bot" option.
Selecting Telegram Bot functionality
Selecting the "Telegram Bot" functionality in the chatbot creation form
  1. Fill in the basic configuration:
    • Chatbot name - enter a name that will be used internally on our platform (e.g. "Telegram Bot - Clothing Store")
    • Short description - optionally add a short description of the chatbot to help you identify it
  2. Enter company information: This is the most important part of the configuration - the more detailed information you provide, the better the chatbot will respond to user questions.
    • Company name - the full name of your company
    • Location - company address, opening hours, parking information, etc.
    • Product/service offering - a detailed description of what you offer along with prices
    • Business description - information about the company, specialties, delivery conditions, payment methods, warranties
Basic chatbot configuration
Basic chatbot configuration form with name and description fields
  1. Telegram Bot configuration:
    • Telegram Bot Token - paste the token received from BotFather in the previous step
  2. Save the chatbot - After filling in all fields, click the "Create Chatbot" button.
Telegram Bot token configuration
Telegram bot token configuration section with automatic webhook setup information

Automatic webhook configuration:

After entering a valid bot token and saving the configuration, our system will automatically configure the webhook that enables communication between Telegram and your AI chatbot.

Full automation: The system automatically configures the webhook for your Telegram bot after creating or updating the configuration! You don't need to do anything manually.

What happens automatically after saving the chatbot:

  • 🔗 Webhook URL configuration - the system automatically sets the correct webhook address in the Telegram API
  • 🔐 Security secret generation - automatic generation and configuration of a secure authentication token
  • ⚙️ Settings optimization - configuration of only necessary update types (text messages)
  • 🧹 Queue cleanup - removal of unprocessed updates from previous configurations
Configuration status: After saving the chatbot, check the messages at the top of the page. If the automatic configuration was successful, you will see a confirmation in the form of a green message. In case of an error, you will receive problem details in a red message.
Company information - the key to success: The quality of chatbot responses depends directly on the amount and detail of information you enter in the "Company information" section. Take the time to fill in these fields accurately - it's an investment in your customers' satisfaction.
Industry context examples: The platform offers ready-made context templates for various industries (online store, restaurant, service company). You can use them as a starting point and customize to your needs.
3

Managing Telegram Commands

Telegram commands are special instructions that users can send to the bot. They provide quick access to specific functions and information. Our platform enables easy command management through a web interface.

Accessing command management:

  1. In the dashboard, find your Telegram chatbot and click Options then "Telegram Commands".
  2. You will be redirected to the command management panel.
Telegram Commands Dashboard
Telegram command management panel with statistics overview
What are Telegram commands: Commands are quick responses delivered by AI. Commands are always available in the menu and will show welcome messages and chatbot settings. They allow users quick access to frequently needed information without having to formulate questions.

Adding a new command:

  1. In the commands panel, click the "Add Command" button.
  2. Fill in the command form:
Add Telegram Command Form
Form for adding a new Telegram command

Command configuration - field details:

Command name

Format: Enter the name without the "/" character (the slash will be added automatically)

Rules:

  • Only letters, numbers, and underscores
  • Length from 1 to 32 characters
  • No spaces or special characters

Examples of valid names:

help contact pricing opening_hours about_us reservation menu
Command description

An optional description displayed in the command list in the Telegram application. It helps users understand what the command is for.

Description examples:

/help - "Displays a list of available commands" /contact - "Contact information and company address" /pricing - "Current product and service prices" /hours - "Opening hours and working days"
Command response

The content of the message that the bot will send in response to the command. You can use variables to personalize responses.

Available variables:

  • {user_name} - User's first and last name
  • {user_id} - Telegram user ID
  • {username} - Username (@username)
  • {chat_id} - Chat ID

Example response using variables:

Hello {user_name}! 👋 Here is a list of available commands: /help - List of commands /contact - Our contact details /pricing - Current prices /hours - Opening hours If you have any questions, just write to me! 😊

Examples of useful commands:

/help
List of all available commands and their descriptions
📞
/contact
Company contact details, address, phone number, opening hours
💰
/pricing
Current product or service prices
🏪
/shop
Link to online store or product offering information
Best practices for commands: Create commands for the most frequently asked questions. Analyze conversations with the chatbot to identify what information users need most often, and create dedicated commands for them.

Managing existing commands:

In the commands panel, you can:

  • Edit commands - Click on a command to change its name, description, or response
  • Delete commands - Remove unused or unnecessary commands
  • Monitor usage - View statistics showing which commands are used most often
4

Testing the Integration

After configuring all the necessary elements, it's time to test the integration and make sure the chatbot works as expected.

Detailed testing instructions:

  1. Find your bot in Telegram:
    • Open the Telegram application
    • In the search field, enter your bot's username (e.g. @myshopbot)
    • Click on the bot from the results list
  2. Start communicating with the bot:
    • Click the "Start" button or send the /start command
    • The bot should respond with the welcome message configured in the settings
  3. Testing AI communication:
    • Send a simple test message, e.g. "Hello" or "Hi"
    • The bot should respond according to the AI configuration and company information
    • Ask a question related to your business to check if the bot provides accurate answers
  4. Testing special commands:
    • Send the /help command (if it was configured)
    • Test all the commands you added in the previous step
    • Check that the responses contain correctly substituted variables (e.g. user name)
  5. Test the commands menu:
    • Click the menu icon (/) in the message input field
    • Check that your commands are visible in the list
    • Click on a command from the menu to make sure it works correctly
What to check during testing: Make sure the bot responds to messages in a reasonable time (usually up to 5 seconds), responses are consistent with the company information, and all configured commands work correctly.

Advanced testing:

Testing different types of questions

Test the bot with different types of questions:

  • Product/service questions: "What products do you have?", "How much does ... cost?"
  • Hours questions: "When are you open?", "What are your working hours?"
  • Location questions: "Where are you located?", "What is the address?"
  • Contact questions: "How can I contact you?"
  • Out-of-scope questions: Check how the bot reacts to questions outside its scope
Performance and limits testing

Check how the bot handles intensive communication:

  • Send several messages quickly one after another
  • Test long messages (several hundred characters)
  • Check response time at different hours
  • Verify rate limiting behavior (if the limit is reached, the bot will inform about the need to wait)
Testing from different devices

Check the bot's operation on different platforms:

  • Mobile app: Telegram on Android/iOS
  • Desktop app: Telegram on Windows/Mac/Linux
  • Web version: Telegram Web (web.telegram.org)

The bot should work identically on all platforms.

Testing tip: Ask a few people around you to test the bot. A fresh perspective can help identify issues that you may not notice as the bot creator.

Monitoring and analyzing chatbot performance:

After launching the chatbot, it's important to monitor its performance and analyze user interactions:

Conversation analysis and statistics

Our platform offers comprehensive analytical tools:

  • General statistics: Total number of queries and sessions, average conversation length, average response time
  • User activity: Interactive charts with traffic distribution by day of the week and hour
  • User behavior: Session length and return rate
  • Popular topics analysis: Top 5 most discussed topics
  • Command statistics: Which commands are used most often
  • Optimization suggestions: Automatically generated recommendations
Accessing analytics
  1. Log in to the chatbot administration panel
  2. Go to the "Dashboard" section
  3. Select your Telegram bot and click the "Analytics" button
  4. Browse detailed data and usage statistics
5

Advanced Bot Settings (Optional)

After the basic configuration, you can further customize your Telegram bot using additional features available in BotFather.

Optional settings in BotFather:

Bot description and profile picture

To set the bot description and profile picture:

  1. Open a conversation with @BotFather
  2. Use the /setdescription command to set the bot description
  3. Select your bot from the list
  4. Enter the description that will be visible on the bot's profile

To add a profile picture:

  1. Use the /setuserpic command
  2. Select your bot
  3. Upload the image that should be the bot's avatar
Tip: A good description should be short (max 120 characters) and clearly explain what the bot is for. The profile picture should be high quality and represent your company or service.
Commands menu configuration

You can set up a list of commands in the Telegram menu:

  1. Use the /setcommands command in BotFather
  2. Select your bot
  3. Enter the list of commands in the following format:
help - List of available commands contact - Company contact details pricing - Current product prices hours - Opening hours

Important: Commands set in BotFather will be visible in the menu, but their functionality is controlled by the commands configured on our platform.

Privacy settings

You can configure the bot's privacy settings:

  1. Use the /setprivacy command in BotFather
  2. Select your bot
  3. Choose the appropriate setting:
  • Disable: The bot will receive all messages in groups
  • Enable: The bot will only receive messages starting with "/" or directly addressed to it
Note: This setting only affects the bot's behavior in groups. In private conversations, the bot always receives all messages.
Bot domain setup

You can assign a custom domain to your bot:

  1. Use the /setdomain command in BotFather
  2. Select your bot
  3. Enter the domain in the format: example.com

After setting the domain, users will be able to find your bot at: https://t.me/example.com

Requirements: The domain must belong to you and you must be able to add the appropriate TXT record in your DNS settings.
System limitations: Currently, the system only supports text messages. Messages with files, images, voice recordings, or other media are ignored by the AI chatbot.
6

Rate Limiting

Rate limiting is a mechanism that restricts the number of messages a user can send to the chatbot within a specified time period. It protects the system from excessive load and ensures fair use of resources.

How Rate Limiting works:

  • Per-user limit: Each user has their own limit (not shared with others)
  • Time window: 60 seconds
  • Automatic reset: The counter resets every minute
  • Configurable limit: Each user can have a different limit set by the administrator

What this means for users:

When a user reaches their message limit within a minute, the chatbot will display a message informing them of the need to wait before sending another message. After one minute from the first message in the given time window, the counter automatically resets.

Rate limiting and service quality: Rate limiting does not affect the quality of service for users during normal usage. Standard limits are set at a level that allows natural conversations while protecting against automated attacks or excessive system usage.

Increasing rate limits:

If the standard rate limits are not sufficient for your use case (e.g. for high-traffic chatbots or specialized applications), you can request an increase.

How to increase limits: To increase the rate limits for your chatbot, contact the ChatbotAssistant site administration. In your message, describe your use case, expected traffic, and justification for higher limits.
7

Troubleshooting

Despite carefully following all integration steps, problems with the chatbot's operation may sometimes occur. This section presents solutions to the most common issues.

Common issues and their solutions:

Bot does not respond to messages

Possible causes:

  • The Bot Token is invalid or has expired
  • The webhook is not properly configured
  • The bot is already being used by another system
  • Subscription issues on the platform
  • Temporary network problems

Solution:

  1. Check the bot token - make sure it was correctly copied from BotFather
  2. Verify the subscription status on the ChatbotAssistant platform
  3. Check for error messages in the chatbot administration panel
  4. Try generating a new token in BotFather and update it in the configuration
  5. Make sure the bot is not being used by other systems
Error "Webhook not configured" or "Bot not found"

Possible causes:

  • The Bot Token is invalid
  • The bot was deleted from BotFather
  • Issues with automatic webhook configuration

Solution:

  1. Check if the bot still exists - search for it in Telegram
  2. Make sure the token has not been changed or reset
  3. Go to the chatbot configuration and save it again to trigger a webhook reconfiguration
  4. If the problem persists, delete the chatbot and create it from scratch
Bot responds but incorrectly

Possible causes:

  • Insufficient or imprecise company information
  • Lack of context for specific industry questions
  • Issues with AI language understanding

Solution:

  1. Expand and refine the company information in the chatbot configuration
  2. Add more details about products, services, and business processes
  3. Add frequently asked questions with answers to the company description
  4. Create dedicated commands for the most important information
  5. Monitor conversations and systematically improve the configuration based on actual user questions
Commands do not work or are not visible

Possible causes:

  • Commands were not properly configured on the platform
  • The commands menu in BotFather was not set up or is inconsistent
  • Errors in command name syntax

Solution:

  1. Check the command configuration in the ChatbotAssistant panel
  2. Make sure that command names contain only allowed characters
  3. Synchronize the commands menu in BotFather with the commands on the platform
  4. Test commands by typing them manually (e.g. /help)
  5. Check that the commands have properly configured responses
Bot is slow or sometimes does not respond

Possible causes:

  • High AI system load
  • Complex questions requiring longer processing
  • Rate limiting thresholds reached
  • Network connection issues

Solution:

  1. Check if you have reached the rate limiting thresholds
  2. Wait a moment and try again - temporary delays are normal
  3. If the problem persists, contact our support team
  4. Consider optimizing your questions - shorter, more specific questions are processed faster
Checking webhook status

You can independently check the webhook configuration status of your bot:

curl "https://api.telegram.org/botYOUR_BOT_TOKEN/getWebhookInfo"

Replace YOUR_BOT_TOKEN with your bot's actual token. This call will return information about the current webhook configuration, including:

  • Webhook URL
  • Connection status
  • Recent errors (if any)
  • Number of pending updates
Technical Support: If you encounter problems that you cannot resolve on your own, contact our technical support team through the administration panel. Prepare a detailed description of the problem, the bot username, and information about when the problem first occurred.