Slack translation bot
ToC
Dependencies
-
Slack client library
pip3 install slackclient -
Google translate library
pip3 install googletrans
Translation map
-
Slack-transbot supports M-N translation map:
channel_1 --> trans_channel_1
channel_2 --> { trans_channel_1, trans_channel_2 }
Install new slack bot & Obtain slack bot's token
Create home channel for slack-transbot
Create a private channel (named home-transbot -- e.g). Let use this channel as home channel for slack-transbot. We will do all settings for slack-transbot in the home channel.
Invite slack-transbot (named transbot) to the channel.
Find slack-transbot user ID
In the home channel, click "View member list" -> Right-click on transbot -> Copy Link -> The copied link should look like https://...slack.com/team/UXXXXXXXX. The last part (UXXXXXXXX) is BOT_ID of slack-transbot.
Start slack-transbot
-
exportfollowing params as environment variables.BOT_TOKEN: Slack-transbot token (xoxb-xxxxxx..., e.g)BOT_ID: Slack-transbot user ID (UXXXXXXXX, e.g)BOT_NAME: Slack-transbot name (transbot, e.g)HOME_CHANNEL: Home channel for slack-transbot (home-transbot, e.g) -
Start slack-transbot
python3 /path/to/transbot.py path/to/transmapWhere:
path/to/transmappoints to where to save translation map. If launching from scratch, simply points to a non-existing file. -
Go to the home channel. If slack-transbot has started well you will see
transbotis shown with a green circle under Apps section.
Configure slack-transbot
-
To configure slack-transbot, post command messages in the home channel.
-
@transbot help: Say hello and provide you some help. -
@transbot list: Show translation map. -
@transbot add src:dst: Add a pair of channels to translation map. -
@transbot rm src:dst: Remove a pair of channels from translation map.
Test slack-transbot
-
Create two channels named
test-srcandtest-dst. Invite slack-transbot to both channels. -
In the home channel, post
@transbot add test-src:test-dst.
- Now, go to
test-srcchannel and post some Korean messages. Check out translated messages intest-dstchannel.

















