A serverless Telegram bot built on AWS that helps manage shared shopping lists. This project serves as a practical exploration of serverless architecture and AWS services.
This bot allows users to manage shopping lists through Telegram with features like:
- Creating and managing shopping lists
- Adding/Removing items
- Sharing lists with other Telegram users
- Managing user permissions
- Real-time updates and synchronization
The project uses a serverless architecture leveraging several AWS services:
- AWS Lambda - Handles bot commands and business logic
- Amazon DynamoDB - Stores shopping lists and user data
- Amazon API Gateway - Manages webhook endpoints for Telegram
- Telegram Bot API - User interface and interaction
- Python 3.9+
- AWS Account with appropriate permissions
- Terraform installed (v1.0.0+)
- Telegram Bot Token (obtained from @BotFather)
- AWS CLI configured with appropriate credentials
-
Clone the repository:
git clone https://github.com/yourusername/shared-shopping-list-bot.git cd shared-shopping-list-bot
-
Create and activate virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Create
.env
file:BOT_TOKEN=your_telegram_bot_token API_URL=your_api_gateway_url ADMIN_ID=your_telegram_user_id
-
Deploy infrastructure:
cd terraform terraform init terraform apply
/list
- Show current shopping list/add [item]
- Add item to the list/remove [item]
- Remove item from the list/add_user [user_id]
- (Admin only) Add new authorized user/myid
- Get your Telegram user ID
-
Install development dependencies:
pip install -r requirements-dev.txt
-
Run tests:
pytest
-
Format code:
black .
-
Run type checking:
mypy .
The project uses GitHub Actions for CI/CD. Every push to main will:
- Run tests
- Run linting and type checking
- Deploy to AWS using Terraform
Manual deployment:
cd terraform
terraform apply
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Please make sure to update tests and documentation as appropriate.
This project is licensed under the MIT License - see the LICENSE file for details.
Common issues and solutions:
-
Bot not responding:
- Check if the Lambda function is properly deployed
- Verify API Gateway endpoint is correct in
.env
- Check CloudWatch logs for errors
-
Permission issues:
- Ensure your Telegram ID is added to the users table
- Verify IAM roles and policies are correctly set up
-
DynamoDB errors:
- Check if tables are created correctly
- Verify Lambda has