This article talks about a way to expand Hotline Telegram CRM functionality using your own helper bot (the so-called assistant bot) working on the side of your topic group using Hotline Topics API.
Using a bot assistant, you can significantly improve the convenience and productivity of working with the system:
implement your own commands on the topic group side
obtain user information from external systems
create deals or call arbitrary commands in external systems
connect an AI bot to the group to interact with users
Attention: This page contains fragments with automatic translation. If you have difficulty understanding this information, try switching the language to English or Russian and use your trusted system for translating websites.
Also in Hotline There are other approaches to expanding functionality, which are described in separate articles:
Adding an official extension bot with commands for mass sendings, marks for users, quick replies, assigning a topic to a manager, templates with message chains, export of the client database
You are creating a new one Telegram bot via @botfather, program its behavior
The bot is added to the backend group, from where it can process commands intended only for it, respond to specified events in the group, or supplement existing standard commands
The software part of the bot interacts with Topics API (reports the address of the topic and receives available information about the user with whom the dialogue is being conducted)
When connected to Hotline user account, the bot can also see user messages (the corresponding message forwarding mode through the account is activated upon request in Support Service)
Hotline reaction for unknown custom commands is disabled via the parameter @CUSTOM_COMMANDS@ in the installation bot
You can implement the assistant bot yourself or request paid development from our support service. Our team has already accumulated a number of standard solutions that can be quickly adapted to different tasks.
We often use the platform as a constructor for the assistant bot N8N. The free version of this platform is quite functional and is not limited in the number of executions, the system can be installed on your own server, allows you to visualize the bot’s operation algorithm, and has many ready-made API connections with external systems.
Special settings for the assistant bot in @botfather
In order for a bot assistant added to a topic group to see all messages from system operators, it needs to specify special parameters in @botfather:
Disable Privacy Mode in the section Group Privacy (by default it is active)
Allow adding a bot to groups with the parameter Allow Groups
Case 1: Obtaining additional information about the user from external systems
The assistant bot can monitor operators messages on the side of the backend group and supplement the command output /info with additional information about the user, or respond to any other custom command.
If you enter the required command in a topic with the user, the assistant bot can call Topics API , provide the address of the topic and receive information about the user in the format JSON (user_id, language_code, first_name, last_name, username, phone).
Next, the assistant bot can request additional information about the user from the external system according to his user_id and display it in a topic for the system operator.
For example, through the command extension /info In our support, we have implemented a quick display of a list of the user’s active instances and whether he has a paid subscription.
A similar principle can also be used to obtain any other available information about the user, for example:
list of user transactions by his user_id
current balance, connected user tariffs
list of shared groups with the user
Case 2: Creating a deal or lead with a user in an external system
The assistant bot can monitor operators messages on the side of the backend group and supplement the command output /info with additional information about the user, or respond to any other custom command.
Such tasks can be solved by an external system, while Hotline can act as a super-convenient native interface for communicating with Telegram users (to be a kind of front office).
Example of integration with Notion
At the support service Hotline We use Notion as a system for storing and structuring our client database (notion.so).
When sending a command /notion on the group topic side, client data is written to the Notion database and a link to the created client card is returned. By clicking on the link, you can quickly go to the client card, fill out tags for the client, and give him priority.
Notion can conveniently present your customer base in the form of a table, board with cards, filters, and sortings. If necessary, you can filter the required users on the Notion side, get a list of their identifiers and, for example, then use it in your newsletter.
By calling the command /notion in the user's topic again, the assistant bot, in addition to the link to the card, returns a list of specified tags for the user.
Similar integration via API is possible with many other systems: Google Sheets, AMO, Bitrix, SalesForce, etc.
Case 3: Quick connection of a tariff in an external system for the user
If the users with whom you communicate through Hotline are also users of any system, then the operator Hotline can use the assistant bot to activate the necessary methods.
Example 1: After agreeing and receiving payment from the user via Hotline, you can send a command like /activate t1 m6, which will activate conditional Tariff 1 for 6 months for this user and send him a notification about it. The command is implemented in a similar way /deactivate.
Example 2: Command / admin Administrator mode is launched in the external bot to manage the settings of the corresponding user who contacted the support service.
Case 4: Creating a link with a user in an external system
If it is necessary to establish a connection between the user Telegram by his user_id with the corresponding account identifier in the external system, then it is possible to implement a command like /link N005
A similar command can bind a user (or several users) to account number N005. After establishing a connection with the user, the command /info (Case 1) can be supplemented by displaying information about his account from an external system.
This is often useful when implementing a corporate help desk, when several users can write to the help desk from one client.
Case 5: Saving messages from a topic group in an external system
In order for the assistant bot to see messages from users and be able to process them, messages to the topic group must come on behalf of the user account, and not the bot. Due to Telegram restrictions, bots cannot see messages from other bots in groups.
Activate a special mode of messages forwarding to a topic group through a user account (userbot) is possible through our Support Service.
When messages from users are forwarded to a topic group through an account is enabled, these messages become available to the assistant bot for processing.
This makes it possible to save messages in an external system, for example, to backup correspondence with clients or use fragments of correspondence to train artificial intelligence.
Note about saving messages: You can also make backup copies of messages from a group at any time manually through the function Export Chat History in the group topic properties.
Case 6: Adding an AI consultant to your Telegram account or bot
When forwarding messages from users to a topic group through an account is enabled (userbot) the assistant bot can see user messages.
Then you can transmit user messages with the desired AI context via the API and receive a response, which you can then display in the topic group as a comment or send directly to the user.
For example, you can invite the user to ask his question while waiting for the operator to answer the artificial intelligence so that he can try to solve his problem on his own.
It is good form to ask questions to artificial intelligence by starting your question with the AI’s mention, for example: ai what commands are there in the system?
You can also teach AI to understand that if it is asked a question starting with a comment, then this is a question from the system operator and the answer must also be given in the form of a comment.
Alternatively, you can send all messages from the user for AI analysis (this is more expensive in terms of AI tokens) and issue a response or not according to the required logic. For example, answer the user only when the AI believes that the question exactly matches what is in its knowledge base.
For flexible control of AI operation, you can enter special restrictions and auxiliary commands that turn AI on/off in a given topic or switch the mode of communication with the user.
Read more about cases of using AI in connection with Telegram CRM Hotline (soon)
See also other ways to expand functionality Hotline:
Extension bot with commands for bulk mailings, user tags and customer database export