The Translator Slackbot translates messages between users' languages in real time. The Slackbot is useful for teams that transcend native language boundaries.
Translation services are provided by the Google Translate API.
- choose different languages per Slack channel
- auto-detects the source language and skips it in translated messages
- if authorized, modifies translated message with the corresponding translations
- if not authorized, posts translations as the bot user
Add to Your Slack Team
Any team member can authorize the bot and allow it to modify their messags.
This is prototype code so it might not be available all the time.
After you add it to your team, invite the bot to a channel with /invite @borges . You will need to present your Google Translate API credentials using the /borges configure command only once per Slack team.
The iplementation is in Java and uses AWS Lambda, AWS API Gateway, AWS DynamoDB, AWS S3, and AWS Route53 along with Google Translate API . Notice that EC2 is not on the list. This application does not reqire any dedicated VM. All logic is implemented in Lambda.
There are three handlers, one each for the OAuth flow, Slack events, and Slack slash commands.
This is prototype all the way. Most of the time spent developing this application was experimenting with the Lambda, API Gateway and Slack services and getting them to play nicely together. So you will see a lot of duplicate logic and refactoring opportunities in the source. Since it wasn't test driven, it needs to be redesigned using TDD to make it production-ready. Depending on the feedback I get, I will decide whether to productionalize it.
Run it Yourself
All the code to deploy to AWS is in the deploy sub-project. Be sure
to configure your workstation with the necessary AWS credentials. The easiest way to
do that is with the AWS CLI
aws configure command.
You may have to mess with a code path and the domain name to get it running for yourself but in broad strokes, run the main methods from these classes:
- DeployDatabase#main provision a DynamoDB table
- DeployCommandHandler#main provision the Lambda Function and API Gateway for handling slash commands
- DeployEventHandler#main provision the Lambda Function and API Gateway for handling Slack events
- DeployOauthHandler#main provision the Lambda Funcation and API Gateway for the OAuth flows
- DeployWebsite#main provision bucket and Route53 domain, and upload web pages