Slack application to translate automatically messages from a given channel to another. It use the slack API for connection to slack DeepL API for translation.
First we need to create a Slack API on the Slack API website by clicking on "Create New App" after login and selecting your Slack workspace where you want ot install your app.
The Slack API require some authorization to be able to receive and send messages on the Slack workspace.
- go to the "Socket Mode" page
- Click on "Enable Socket Mode" button
- Give a name to your app token
- Copy and paste your token in a text file name
.env
placed in the the repository like this:
SLACK_APP_TOKEN = 'xapp-1-XXXXXXXXXXXXXXXXXX'
- On the "Basic Information" page, click on "Add features and functionality" menu.
- Then click on "Event Subscriptions"
- Click on the "Enable Events" button
- On the "Subscribe to bots events" click on "Add Bot User events" and add "message.channels" event
- Save your changes by clicking on the button at the bottom of the page
- On the "Basic Information" page, click on "Add features and functionality" menu.
- Then click on "Permissions"
- On the "Scopes" menu, "Bot Token Scopes" sub menu, click on "Add an OAuth Scope"
- Add the following scopes:
channels:history
app_mentions:read
channels:read
chat:write
chat:write.customize
users:read
- Click on "Install to Workspace" button on the top of the page
- Copy and paste your "Bot User OAuth Token" in the
.env
file like this:
SLACK_APP_TOKEN = 'xapp-1-XXXXXXXXXXXXXXXXXX'
BOT_TOKEN = 'xoxb-XXXXXXXXXXXXXXXXXX'
- Create a DeepL API account on their web site
- Go to your account settings
- copy and paste your Authentication Key in the
.env
file like this:
SLACK_APP_TOKEN = 'xapp-1-XXXXXXXXXXXXXXXXXX'
BOT_TOKEN = 'xoxb-XXXXXXXXXXXXXXXXXX'
DEEPLKEY = 'XXXXXXXXXXXXXXXXXX'
- Complete SlackAutotranslate.service file and copy it into
/etc/systemd/system
. - Change lines
8 ~ 12
of the fileindex.js
to specify the channels you want to track - Start it with
systemctl start SlackAutotranslate
. - Enable it to run on boot with
systemctl enable SlackAutotranslate
. - See logs with
journalctl -u SlackAutotranslate
.