This bot can echo messages between specified channels.
This bot runs as a web app within a Google app script.
You can make this bot work by registering it as an endpoint for Slack API event subscriptions.
npm
- clasp
npm install -g @google/clasp
make
To use it, you need to set up Google apps scripts and Slack API.
- Enable Google Apps Script API
https://script.google.com/home/usersettings - make push
- make deploy
- Grant the necessary privileges
make open
Publish > Deploy as web app.. > Update
Grant access
- Create New App
https://api.slack.com/apps
Please make a note ofApp Credentials
displayed after registration.
In order to run the application and change its behavior, you need to set the following Google Apps scripts property.
Property name | Required | Setting Value | Description |
---|---|---|---|
VERIFICATION_TOKEN | ○ | Basic Information > App Credentials > Verification Token | A token that easily authenticates the source of a hooked request |
CLIENT_ID | ○ | Basic Information > App Credentials > Client ID | Use with OAuth |
CLIENT_SECRET | ○ | Basic Information > App Credentials > Client Secret | Use with OAuth |
SLACK_WORKSPACE_NAME | optional | your workspace's name. e.g.) https://example .slack.com |
|
ACCESS_TOKEN | optional | Set automatically by oauth authentication | Access token issued after oauth authentication. |
CHANNEL_NAME | optional | Set automatically by oauth authentication | Channel name specified during oauth authentication. |
BOT_USER_ID | optional | Set automatically by oauth authentication | ID of bot user registered with slack api. |
- Open Project
$ make open
- Add Scirpt properties
File > Project properties > Scirpt properties > Add row
Setting Property & Value
- Redirect URLs
Add New Redirect URL
> Add Redirect URL >Save URLs
ex) https://script.google.com/macros/s/miserarenaiyo/usercallback
You can check the Redirect URL in the following way. TheRedirectUri
of the displayed page.
$ make application
- Bot Token Scopes
ClickAdd an OAuth Scope
to select the following permissions - Install App to Workspace
You must specify a destination channel that bot can post to as an app.
- Open web application
$ make application
The browser will be launched with the following URL:
ex) https://script.google.com/macros/s/miserarenaiyo/exec - Click
Authorize.
You must specify a destination channel that bot can post to as an app. - Click
Allow
The following message is displayed when OAuth authentication is successful
Success!
Setting EventSubscriptions
When prompted, click the Setting EventSubscriptions
to set up an Event Subscriptions.
Turn on.
Setting Request URL.
ex) https://script.google.com/macros/s/miserarenaiyo/exec
Add Workspace Event.
Select message.channels
.