Slack translation bot
-
Slack client library
pip3 install slackclient
-
Google translate library
pip3 install googletrans
-
Slack-transbot supports M-N translation map:
channel_1 --> trans_channel_1
channel_2 --> { trans_channel_1, trans_channel_2 }
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.
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.
-
export
following 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/transmap
Where:
path/to/transmap
points 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
transbot
is shown with a green circle under Apps section.
-
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.
-
Create two channels named
test-src
andtest-dst
. Invite slack-transbot to both channels. -
In the home channel, post
@transbot add test-src:test-dst
.
- Now, go to
test-src
channel and post some Korean messages. Check out translated messages intest-dst
channel.