AI Telegram Twin: How to Separate Stylometry of Communication from Knowledge Base
In today’s world, where artificial intelligence (AI) is becoming increasingly integrated into daily life, creating bots for messengers like Telegram has become a popular task. However, standard ChatGPT bots often give themselves away by using template phrases and responses that do not always fit the context. This causes frustration among clients and reduces the effectiveness of interaction.
Why Standard ChatGPT Bots Give Themselves Away
The main reason why standard ChatGPT bots give themselves away is their use of template responses. Phrases like «I’m glad to help you! Here are 5 points…» and standard response structures make the conversation with the bot unnatural and mechanical. Clients expect more personalized and natural interaction, especially in the context of personal messages.
Another important aspect is the lack of consideration for the stylometric features specific to a particular user or brand. Standard bots cannot adapt to an individual communication style, making their responses less convincing and more predictable.
Additionally, the absence of dynamic pauses in responses makes the interaction with the bot less realistic. Users are accustomed to people taking time to think before responding or typing messages with delays.
Separation of Concerns Architecture
To solve these problems, we developed a Separation of Concerns (SoC) architecture that separates stylometry of communication and knowledge base. This allows for more natural and realistic interaction with the bot.
Stylometry Core
The stylometry core is responsible for creating a realistic communication style. It includes several key components:
- Parsing real exports: Files result.json and Telethon are used to analyze real user messages.
- Calculating average reply length: Determining the optimal response length based on historical data analysis.
- Breaking a single thought into 2-4 short messages: Dividing long responses into several shorter ones, creating a «machine gun» effect and making the conversation more dynamic.
- Specific punctuation and slang: Considering individual punctuation features and using slang characteristic of a specific user or brand.
# Example code for parsing result.json
import json
with open('result.json', 'r') as file:
data = json.load(file)
for message in data['messages']:
print(message['text'])
Knowledge Base and Price List
The knowledge base and price lists are stored strictly separately from the stylometry core. This avoids situations where the model might «make up» prices or information for a nice phrase.
Anti-Detect and Human-in-the-Loop
To increase the realism of interaction, we implemented several additional mechanisms:
Smart Typing
This mechanism introduces a pause and «typing…» status proportional to the length of the response. This makes the conversation more natural as users are accustomed to delays when typing text.
# Example code for Smart Typing
import time
def smart_typing(message):
typing_status = True
for char in message:
print(char, end='', flush=True)
time.sleep(0.1) # Delay to simulate typing
print() # New line after printing is complete
smart_typing("Example message with delay")
Smart Pause
If the owner writes in the chat, the bot instantly falls silent for N hours. This avoids conflicts and gives the owner the opportunity to personally respond to important messages.
Lead Radar and Escalation Triggers
Lead Radar is a system for tracking key phrases such as «ready to pay» or «where to send prepayment.» These triggers allow instant transfer of control to a human, increasing the efficiency of handling important requests.
Practical Problems
The development and operation of AI Telegram Twin are not without problems. Let’s consider some of them:
- Risk of Telegram MTProto Flood Limits: Telegram has limitations on the number of messages that can be sent within a certain period. This can lead to account blocking or reduced message sending speed.
- Switching from Local RTX 3090 to Cloud API: In case of power outages, it is necessary to quickly switch between local and cloud API to avoid downtime in bot operation. This requires careful configuration and monitoring.
To solve these problems, the following approaches can be used:
- Optimizing Message Sending Speed: Evenly distributing message sending over time to avoid flood limits.
- Automated Switching Between Local and Cloud API: Using monitoring systems and scripts for automatic switching in case of power outages.
Conclusion
Separating the stylometry of communication from the knowledge base allows creating a more realistic and natural AI Telegram Twin. Using Separation of Concerns architecture, Smart Typing and Smart Pause mechanisms, as well as Lead Radar makes interaction with the bot more pleasant and effective.
However, developing such systems is associated with several problems, such as Telegram MTProto flood limits and the need to switch between local and cloud API. Solving these problems requires careful configuration and monitoring.
The full project code is available at: https://github.com/Lancer0076-prog/ai-telegram-twin
Добавить комментарий