This slackbot translates a message when a user reacts with an emoji. For example, when a message gets a :flag-de:
reacji, this bot translates the original message to German and posts it in the message thread.
This is baed on https://github.com/slackapi/reacjilator, modified to run on GCP cloud function.
- Create an app at your Slack App Settings page at api.slack.com/apps
- Choose "From an app manifest", select the workspace you want to use, then paste the contents of
manifest.yml
into the dialog marked "Enter app manifest below". - On the OAuth & Permissions page, install the app and get a Bot User OAuth Token - it begins with
xoxb-
. - On the Basic Information page, find your Signing Secret and copy it to your
.env
file asSLACK_SIGNING_SECRET
. - Under Event Subscriptions, enable events and set the Request URL to your deployed app URL (e.g., your Google Cloud Function URL).
- Subscribe to the
reaction_added
bot event.
Get your bot token at OAuth & Permissions and your Signing Secret at Basic Information.
Rename the .env.sample
to .env
and fill the env vars with your credentials. You also need Google credentials to use the Google translation API:
SLACK_BOT_TOKEN=
SLACK_SIGNING_SECRET=
GOOGLE_PROJECT_ID=
GOOGLE_APPLICATION_CREDENTIALS=
PORT=3000
To run the app locally:
npm start
You'll need to expose your local server to the internet using a tool like ngrok to receive events from Slack.
To deploy to Google Cloud Functions:
npm run deploy
After deployment, set the function URL as your Request URL in the Slack app's Event Subscriptions page.
This is fork of awesome project https://github.com/slackapi/reacjilator
Main differences are:
- reacjilator Socket Mode whereas this repo uses HTTP mode, which is easier to deploy and lower cost when usage is small
- This can be easily deployed to GCP Cloud Run Function