A Telegram bot that lets you interact with different AI models.
- Text/Voice chat
- Text/Voice translation
- Speech-to-Text (Transcription)
- Text-to-Speech
- Image generation
- Image analysis
- Python
Steps:
pip install -r requirements.txt- Set the environment variables below:
TELEGRAM_API_KEYTELEGRAM_ADMIN_IDOPENAI_API_KEYDATABASE_URL- E.g.sqlite:///chats.db
python bot.py
NOTE: The bot relies on the files ending with .default.json to get default settings.
Non-default configuration files will be created automatically once a setting is edited through the bot interface.
There are two types of configuration files:
bot(config.json) - Contains the bot settingsai(ai_options.json) - Contains the options to be sent when calling the AI APIs
To change a setting use the /config command.
NOTE: AI options are shared between chats, while the AI system message is set per chat.
To change the system message for a chat use the /sysmsg command.
The bot reads a whitelist to determine who can send certain commands, each line in the whitelist must be the Telegram ID of either a user or a group chat.
Without a whitelist, only the bot's admin can interact with the bot.
You can find the full list of commands here.
NOTE: When chatting with the AI, there's no need to use the commands /chat or /achat each time, simply reply to a bot's message with text or voice.
NOTE: The command /help displays the bot version only if the .git directory is present in the root.
Although multiple AI platforms can be implemented through the AIManager class, currently only the OpenAI platform is implemented.
Telegram added support for message streaming on 2026-12-31. You can try it out by setting streaming to true in the bot configuration file (config.json) tho, the feature provided by the API is still experimental.