It is a serverless BOT which receives Slack's public channel message and reply if there includes a specific keyword.
DEMO:
Using Slack's BOT and Subscribe to receive all the public messages toward Lambda via API-Gateway. If there includes a specific keyword, call the Slack API and send a message back to the same channel. Slack BOT needs to be create manually, but AWS side automates environment construction by using Serverless Framework.
- AWS Account
- Serverless Framework
- serverless-plugin-aws-alerts (optional)
- Slack Account
-
Create Slack BOT from Here
- Bot User
- Display Name
- Default Username
- Permissions
- OAuth & Permissions
- Scopes
- channels:history
- channels:write
- Scopes
- OAuth & Permissions
- Bot User
-
Get two tokens
- Permissions
- OAuth & Permissions
- OAuth Access Token
- Bot User OAuth Access Token
- OAuth & Permissions
- Permissions
-
Clone this repo.
$ git clone https://github.com/saitota/SlackReplyBot.git
- Modify environment_dev.yml 's two TOKENs to your token.
OAUTH_TOKEN: 'xoxp-000000000000-000000000000-000000000000-0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x'
BOT_TOKEN: 'xoxb-000000000000-0x0x0x0x0x0x0x'
- Deploy with Serverless Framework (you must aws-cli initialize before)
$ sls deploy
...
api keys:
None
endpoints:
POST - https://0x0x0x0x0x.execute-api.ap-northeast-1.amazonaws.com/dev/
functions:
fnc: SlackReplyBot-dev-fnc
-
Set Slack BOT endpoint and event subscribe settings
- Event Subscriptions
- Request URL:
set your endopint url(you can see in your deploy log)
- Request URL:
- Subscribe to Workspace Events
- message.channels
- Event Subscriptions
-
Done! try to say
poop
at Slack.
I wrote article about this BOT.