Telegram bot that picks up messages from an input channel, translates them, and forwards them to an output channel.
- The Telegram bot is subscribed to a source channel. When a new post is published, Telegram sends it via a webhook to an AWS Lambda function.
- The Lambda function extracts the post's text and sends it to the OpenAI API to generate a translated version.
- Once translated, the bot sends the translated post to a designated output channel.
- OpenAI API key
- Telegram Bot Token
- AWS Account
- Set up environment variables in
terraform.tfvars
. - Deploy infrastructure with Terraform.
- Push code to trigger deployment.
- Test locally (optional) with
python main.py
and json test events.
The bot differentiates between single-media messages and media groups. This is because Telegram treats posts with multiple media attachments as media groups, splitting them into multiple events. To aggregate these related events and reconstruct them into a single message for reposting, DynamoDB is used as temporary storage.