A Telegram bot with AI integration (via OpenRouter) for generating text responses in the persona of any character.
- Generating meaningful responses according to the character's personality defined in your prompt
- Image recognition
- Context understanding (private messages, comments, group chats, different reactions to specific users in chats)
- Configurable response frequency/chance in different contexts
- Whitelists for security and request economy
Note: It's recommended to run the bot on hosting, as any Telegram bot requires continuously running code for constant operation.
-
Prerequisites
- Python 3.8+
- Your Telegram bot token (Where to get)
- OpenRouter API key (Sign up on the website -> Create API Key -> Copy)
-
Clone repository
git clone https://github.com/N0Fanru/ai-character-telebot
or
download as ZIP file and extract -
Install dependencies
In command line:pip install -r requirements.txt -
Configuration setup
Modify the contents of the bot_config.py file to suit your needs following the comments in the file.
Note: You can find user or group IDs using various Telegram bots (e.g., Get Any ID) -
Create prompts
Rename prompts_exaple.py file to prompts.py and modify its content according to your needs.
Note: Experiment with prompts! In the main prompt, you can define everything you consider necessary. It's recommended to primarily include examples of the character's messages. -
Run the bot
python bot.py
- For private messages: make sure you're in the whitelist or the whitelist is disabled. Send a message to the bot.
- For comments/messages in chats: make sure the chat is in the whitelist or the whitelist is disabled. Ensure the bot's response chance is set correctly. Write a post or message in the chat.
The project uses free AI models that worked best in my case. You can choose any other AI model on OpenRouter and change to it in the .env file.
- Code 429 - request limits. (For free models this is 20 requests per minute, 50 requests per day)
- About other errors
- Audio recognition
- Analysis of certain files
- Context memory with database