This project demonstrates how to use DeepL's document translation API in Slack. With this app, you can translate the documents uploaded in Slack just by adding a national flag reaction emoji. When the translation is done, the app uploads the generated files in the original message's thread.
If you are looking for a solution to translate chat message text in Slack, try https://github.com/seratch/deepl-for-slack out for the purpose. You can use both apps together.
This app provides two features as below.
When a user adds a reaction to a message with files, this app calls DeepL's document translation API. When the translation is done, this app uploads the result as a new file in the message's thread.
Anyone in the Slack workspace can check the remaining amount of the DeepL API calls by accessing the app's Home tab.
If you don't have any of the following accounts, create your accounts first.
All you need to do to run this app are DeepL API key and Slack app's tokens. Follow the below steps to get the credentials.
- Select "for Developers" plan at https://www.deepl.com/pro/ (be careful not to choose any other)
- Go to your DeepL Pro Account page
- Save the Authentication Key for DeepL API value
You will use this token as DEEPL_AUTH_KEY
env variable later.
Also, if your app allows your end-users to translate PDF files too, go to Translation Settings and enable the "Allow PDF files to be sent to Adobe for all your future translations" option.
Refer to the following resources for more details:
Create a new Slack app from https://api.slack.com/apps?new_app=1
display_information:
name: DeepL Document Translator
description: Generates translated documents from the ones uploaded in Slack
background_color: "#0b1f5c"
features:
app_home:
home_tab_enabled: true
messages_tab_enabled: true
messages_tab_read_only_enabled: false
bot_user:
display_name: DeepL Document Translator
always_online: true
oauth_config:
scopes:
bot:
- chat:write
- channels:history
- groups:history
- mpim:history
- im:history
- files:read
- files:write
- reactions:read
settings:
event_subscriptions:
bot_events:
- app_home_opened
- reaction_added
interactivity:
is_enabled: true
socket_mode_enabled: true
Go to Settings > Install App and click the Install to Workspace button.
You will use this xoxb-
prefix token as SLACK_BOT_TOKEN
env variable later.
Go to Settings > Basic Information > App-Level Tokens and click the Generate Tokens and Scopes button.
Create a new App-Level token with connections:write
scope.
You will use this xapp-
prefix token as SLACK_APP_TOKEN
env variable later.
If you haven't installed Poetry in your local machine, install the build tool first. Once you install the tool, run the following commands.
git clone [email protected]:seratch/deepl-document-translator-for-slack.git
cd deepl-document-translator-for-slack/
# Python 3.9 required
poetry shell
poetry install
export DEEPL_AUTH_KEY=...
export SLACK_APP_TOKEN=xapp-1-...
export SLACK_BOT_TOKEN=xoxb-...
python app.py
If you encounter "We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy." error with the above button, please fork this repository and use your own URL like
https://heroku.com/deploy?template=https://github.com/{your account}/deepl-document-translator-for-slack/tree/main
.
If you are looking for more functionalities, take a look at the following projects:
- https://github.com/seratch/deepl-for-slack
- https://github.com/monstar-lab-oss/deepl-for-slack-elixir
The MIT License