Skip to content

chr1sjf0x/standup-bot-serverless

 
 

Repository files navigation

Welcome to statndup-bot 👋

Version License: ISC

A Slack bot to post daily standup status. It launches a modal, prompting users for Yesterday, Today, Parking Lot Items, and Parking Lot Participants

Install

Add bot to channels where you wish to use it.

Slack Integration

Or invite the bot to the channel with @Standup.

Usage - Slack

/standup help
/standup [parking-lot | parking_lot | parkinglot | -p] - display ephemeral parking lot items
/standup post [parking-lot | parking_lot | parkinglot | -p] - post parking lot items to chat

Deployment

SLS makes it easy to deploy to AWS

Install with the command

npm install -g serverless
sls deploy --stage (prod | dev) [--aws-profile profile-name] [--region us-east-2]

To inspect the size and content of the deployment without deploying anything to AWS

sls package --stage (prod | dev) [--aws-profile profile-name]

You can also check configuration substitutions. This is useful for checking things like the target region.

sls print --stage (prod | dev)

Secrets

Create a secret in SecretsManager named SlackStandup-secret-dev or SlackStandup-secret-prod, depending on the target environment, with the values

  • SLACK_STANDUP_BOT_TOKEN
  • SLACK_STANDUP_SIGNING_SECRET

These can be found on the Slack website. Copy-paste the following values.

SLACK_STANDUP_BOT_TOKEN

In the app's OAuth & Permissions:

Oauth

SLACK_STANDUP_SIGNING_SECRET

In the app's Basic Settings copy the value for Signing Secret:

Signing secret

Local Development

Testing locally requires Docker, and setting the following environment variables in a .env file. These are the same values found in the Secrets section of this document.

  • SLACK_STANDUP_BOT_TOKEN
  • SLACK_STANDUP_SIGNING_SECRET

Deploy to Docker with the following command:

npm run serverless-localstack

This retrieves the local environment variables and creates secrets and a DynamoDB table in the Localstack instance.

Localstack runs on port 4566.

Script Permissions

Localstack is loaded with scripts in src/test/scripts. These may need updated permissions to execute.

chmod 755 src/test/scripts/*

Slack -> Locally running Lambda

To connect Slack to this running instance, start ngrok with either of these commands. This assumes ngrok is installed in the user's home directory.

npm run ngrok

~/ngrok http 5000

This will create a URL to enter into Slack's Slash Command interface for this app.

Querying DynamoDB

The context.ts file sets up some fake credentials, and we need these to query the DynamoDB instance using the aws cli.

AWS_ACCESS_KEY_ID=not-a-real-access-key-id AWS_SECRET_ACCESS_KEY=not-a-real-access-key aws dynamodb scan --table-name local_STANDUP_STATUS  --endpoint-url http://localhost:4566

Slack Configuration

This bot uses a Slash Command and enabled Interactivity. Slash Commands

Interactivity

  • Slash Commands and Interactivity use the same Request URL, which ends in /slack/events
  • For local testing, set these to the URL generated by ngrok
  • When the app is live, set these to the lambda URL

The app needs permissions to interact with the Slack workspace. Enable OAuth scopes in Slack.

Slack Scopes

  • chat:write
  • chat:write.customize
  • commands
  • groups:read
  • users.profile:read
  • users:read

Author

👤 Steve Thompson

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.0%
  • JavaScript 2.3%
  • Dockerfile 0.7%