This project is a Telegram bot powered by OpenAI's GPT models and CrewAI's agent framework. Designed as a boilerplate, the structure is highly customisable, with detailed comments and configuration files for easy future development. The bot demonstrates advanced capabilities in handling general queries, performing web searches, and managing appointments through a multi-agent system.
- 💬 General Queries: Answer user questions using AI agents
- 🌐 Web Search: Search the web for the latest information
- 📅 Appointment Management: Schedule, reschedule, and cancel appointments with persistent storage in a local JSON file
- 🌦️ Current Weather: Provide real-time weather updates
Analyses user queries to determine which specialised agent should handle the task.
- General Agent: Handles general-purpose queries and information retrieval
- Appointment Agent: Manages all appointment-related operations
The system uses CrewAI's agent framework for task delegation and execution, with YAML-based configuration for easy customisation.
- Open Telegram and search for @BotFather
- Send
/newbotand follow the prompts - Save the API token you receive
- Clone the repository:
git clone https://github.com/mcallec1/telegram_bot_crewai.git
cd telegram-bot-crewai- Install the package:
pip install .- Configure environment variables:
Create a
.envfile with:
OPENAI_API_KEY=your_openai_api_key
SERPAPI_KEY=your_serpapi_key
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
OPENWEATHER_API_KEY=your_openweather_keyStart the bot using:
crewai run- /start: Initialise the bot
- /help: View available commands
What is the latest news in Japan
What is the capital of Japan?
What is the current Bitcoin price?
Who invented the telephone?
What's the weather like in New York?
Tell me the temperature in Paris
Is it raining in Tokyo?
Schedule a meeting tomorrow at 2 PM
Can you help me book an appointment for next week?
Reschedule my appointment from Monday to Tuesday
What appointments do I have scheduled?
I need to schedule a meeting, but first tell me the weather forecast
Can you find information about restaurants in London and help me book a table?
What's the best time to schedule a meeting in Tokyo considering the weather?
These examples demonstrate the bot's capabilities in:
- Routing between general and appointment agents
- Weather information retrieval
- Web search functionality
- Appointment management with local storage
- Handling complex, multi-step requests
telegram_bot_crewai/
├── src/
│ └── telegram_bot_crewai/
│ ├── config/
│ │ ├── agents.yaml # Agent definitions
│ │ └── tasks.yaml # Task configurations
│ ├── tools/
│ │ ├── appointment_tool.py
│ │ ├── weather_tool.py
│ │ └── web_search_tool.py
│ ├── bot.py # Telegram interface
│ ├── crew.py # CrewAI setup
│ └── main.py # Entry point
└── appointments.json # Appointment storage
The project uses:
- CrewAI for agent-based task management
- YAML configuration for easy customization
- Pydantic for data validation
- Local JSON file for persistent appointment storage
This project is licensed under the MIT License.
Note: This is a CrewAI adaptation of the original LangChain implementation, optimized for better agent coordination and task management.
This project is based on the original Telegram-Bot by @osamatech786, which was implemented using LangChain.