The Sakhi Telegram Bot is a Python-based bot that interacts with the Sakhi API Server via Telegram. It allows users to perform various actions and access information from the API Server through the convenience of a Telegram chat interface.
- Python 3.8+
- Starlette
- Redis (for user session)
- python-telegram-bot library
- Telegram bot token
- Secure public domain to configure webhook URL. (use ngrok for local setup)
-
Clone the repository
git clone https://github.com/Sunbird-AIAssistant/sakhi-telegram-unified-service.git cd sakhi-telegram-unified-service
-
Install required python dependencies
pip install -r requirements.txt
-
Set up your Telegram bot:
-
Create a new bot on Telegram and obtain the bot token.
-
Set up a webhook URL (using a public domain with SSL/TLS support)
If you're having any trouble setting up webhooks, please check out this amazing guide to webhooks.
-
-
Set up environment variables:
- Create a .env file in the project root and add the following variables:
SERVICE_ENVIRONMENT=dev TELEGRAM_BASE_URL=https://your-telegram-callback-url.com TELEGRAM_BOT_TOKEN=your-telegram-bot-token TELEGRAM_BOT_NAME=your-telegram-bot-name ACTIVITY_API_BASE_URL=https://your-activity-api-url.com STORY_API_BASE_URL=https://your-story-api-url.com TELEMETRY_ENDPOINT_URL=https://your-telemetry-endpoint-url.com TELEMETRY_LOG_ENABLED=true # true or false LOG_LEVEL=DEBUG # INFO, DEBUG, ERROR SUPPORTED_LANGUAGES=en,bn,gu,hi,kn,ml,mr,or,pa,ta,te REDIS_HOST=your-redis-host REDIS_PORT=your-redis-port REDIS_INDEX=your-redis-index
Note: This telegram bot only supports the following languages: en, bn, gu, hi, kn, ml, mr, or, pa, ta, te.
-
Ensure Redis is running. If not installed, you can download it from official Redis website.
-
Start the Starlette app:
python3 telegram_webhook.py
-
Once the Telegram bot is up and running, you can interact with it through your Telegram chat. Start a chat with the bot and use the available commands and features to perform actions and retrieve information from the API Server.
-
The bot provides the following commands:
/start: Start the conversation with the bot
-
Select preferred language
-
Select the bot
-
Start querying questions
-
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.