Freddy is a Telegram bot in Python, designed to be a friendly AI assistant that cheerfully responds to incoming user messages on behalf of you. It is directly connected to the user business chat (for premium Telegram users only). The implementation is straightforward and conveys the purpose of sending and receiving text messages from Telegram direct chat. The code uses the python-telegram-bot library for Telegram API communication and is connected to the Google Gemini API for AI magic.
You need to have a business Telegram account (Premium) to connect a bot to your chat. Follow these steps:
- Create your bot from @BotFather on Telegram and enable business mode from bot settings.
- Go to
Settings > Telegram Business > Chatbotsand integrate your bot into your chat.
More details about Telegram Business can be found here.
- Clone the repository:
git clone https://github.com/7azmi/Freddy.git
- Install the required dependencies:
pip install -r requirements.txt
- Add environment variables:
export BOT_TOKEN=<obtain it from @BotFather on Telegram. Do not forget to enable business mode!> export GEMINI_API_KEY=<Gemini API key, you can get it for free from https://ai.google.dev> export BUSINESS_CHAT_ID=<your telegram chat id>
- Personalize your AI instructions in
ai_instructions.txt. - Run the app locally:
python app.py
This project is complete as it serves its purpose. It demonstrates that bots can be integrated with Telegram business chats and interact with users.