This is a simple Slack Bot that when added to a channel, generates a message pairing all channel members every Monday at 9 AM Australia Time (configurable)
Using serverless framework + Slack Bolt JS library, an AWS lambda function is creted that's triggered according to the cron expression in serverless.yml
file.
The lambda function when invoked, checks all the channels it's invited to and for each one gathers the channel members, pairs them and generates a message with those pairs.
yarn install
yarn test
- Create a Slack App (https://api.slack.com/apps?new_app=1)
- Create a Bot user with the following scopes
channels:join
- Join public channels in a workspace - This is required so that the bot can be added to a channel
channels:read
- View basic information about public channels in a workspace - This is required so the bot can find all the users in the channel
chat:write
- Send messages as @random_coffee_bot - this allows the bot to send messages to the channel
- Get the Signing Secret and Bot User OAuth Token from the Slack app configuration page.
- Set them as ENV vars
$ export SLACK_BOT_TOKEN=<slack bot token>
(starts withxoxb-
)$ export SIGNING_SECRET=<signing secret>
- Setup AWS CLI (https://www.serverless.com/framework/docs/providers/aws/guide/credentials/)
- Deploy using
$ npx serverless deploy
-
Install the AWS CLI
-
Export
-
Boot the the serverless framework offline
npx serverless offline
-
Invoke the lambda function
aws lambda invoke /dev/null --endpoint-url https://localhost:3002 --function-name serverless-bolt-js-dev-slack
- The schedule of the message is configurable only by editing the cron expression in the serverless.yml
- Doesn't use OAuth so it cannot be installed on other Slack workspaces.
- Limited testing