Translate Slack message with flag emoji(e.g. 🇯🇵 🇺🇸 🇬🇧) reaction. 😄
This is implemented slack/reacjilator with aws/chalice.
You can easily translate Slack messages with flag emojiflag emoji(e.g. 🇯🇵 🇺🇸 🇬🇧) reaction.
The translated messages is sent back to the thread, so it does not interfere with other conversations.
- It works easily as Slack bot.
- Even when using other translation API you can easily respond.
- Since it is a serverless configuration, it is easy to operate.
- Python 2.7.x
- Packages in use
- aws/chalice: Python Serverless Microframework for AWS
- requests/requests: Python HTTP Requests for Humans™ ✨🍰✨
- slackapi/python-slackclient: Slack Developer Kit for Python
- boto/boto3: AWS SDK for Python
- Services in use
- Amazon API Gateway
- AWS Lambda – Serverless Compute - Amazon Web Services
- Amazon Simple Notification Service (SNS) | Event Notifications for Distributed Applications and Microservices | AWS
- Slack API | Slack
- Translate API — Yandex Technologies
Install this bot on "Slack". If you react to the message with the emoji of the flag, this bot translate the original message and post it under the message thread.
-
Refer to the following document and install this bot in "Slack".
- slackapi/reacjilator: A translation bot that translates a message when a user reacted with an emoji 🇨🇳 🇮🇹 🇹🇭 🇫🇷 🇯🇵 🇮🇳 🇺🇸 🇧🇬 🇹🇼 🇦🇪 🇰🇷
- [Japanese] Developing a bot for your workspace 翻訳ボットを作る!
-
Deploy bot using
aws/chalice
.
$ pip install chalice
$ chalice new-project reacjilator-chalice
$ cd reacjilator-chalice
$ git clone https://github.com/uchimanajet7/reacjilator-chalice
$ chalice deploy
Environment variables and so on need to be set individually. And prepare the resources of AWS necessary for execution.
- Environment variables settings are done with
./chalice/config.json
file.
{
"stages": {
"dev": {
"autogen_policy": true,
"api_gateway_stage": "api"
}
},
"environment_variables": {
"SLACK_VERIFICATION_TOKEN": "YOUR_SLACK_VERIFICATION_TOKEN",
"SLACK_TOKEN": "YOUR_SLACK_TOKEN",
"YANDEX_API_KEY": "YOUR_YANDEX_API_KEY",
"SNS_TOPIC_ARN": "YOUR_SNS_TOPIC_ARN",
"SNS_SUBJECT": "slack event data"
},
"lambda_timeout": 180,
"lambda_memory_size": 128,
"version": "2.0",
"app_name": "reacjilator"
}
- About setting items
SLACK_VERIFICATION_TOKEN
: String- Specify the token to use "Slack API".
SLACK_TOKEN
: String- Specify the token to use "Slack API". -
YANDEX_API_KEY
: String - Specify the API key to use "Yandex API".
- Specify the token to use "Slack API". -
SNS_TOPIC_ARN
: String- Specify ARN of "Amazon SNS".
SNS_SUBJECT
: String- Specify the subject of SNS to be sent.
If you want to limit the channels that respond to flag emoji reactions, you need to create a list of allowed channels.
- Allowed channels settings are done with
./chalicelib/filter.json
file.
{
"C1234567R": "random",
"C823A567R": "dev"
}
Specify the format channel ID
: channel Name
.
Refer to the following for how to check the channel ID
.
- Slack | APIに使う「チャンネルID」を取得する方法 - Qiita
- aws chaliceを使ってslackの翻訳botを作ってみた #aws #chalice #slack #bot #serverless - uchimanajet7のメモ