davidmerrick / micronaut-slack-starter

Starter project for building Slack apps with Micronaut

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Micronaut Slack Starter

Starter project for a Micronaut Slack app, written in Kotlin. This is forked from my quarantinebot project.

Includes:

  • Dockerfile for building with GraalVM for blazing-fast cold start time on AWS Lambda.
  • Terraform configs for deploying infrastructure.
  • Netty server for running locally.
  • Health check endpoint.

screenshot

Creating a Slack bot

Create an app via https://api.slack.com/. Add it to your workspace.

Event subscriptions

Subscribe to bot events: app_mention, message.channels, and message.im.

Permissions

Add scopes for app_mentions:read, im:history, and chat:write.

Bots

Enable Always Show My Bot as Online.

Running tests locally

  1. Do a ./gradlew build to generate kapt annotations
  2. Run tests as usual in IntelliJ

Running application locally

Included in the build is Micronaut's Netty server. Invoke ./gradlew run to start it on port 8080. Make sure to set the SLACK_TOKEN environment variable to your Slack app's token.

Compilation and deployment with GraalVM

  1. Run docker build . -t quarantinebot
  2. After build, run the container, then exit. docker run -ti quarantinebot /bin/bash
  3. Copy the function.zip out of the container. docker cp $(docker ps --last 1 --quiet):/home/application/function.zip ./
  4. On AWS Lambda, set the runtime to "Custom runtime". Use ./bootstrap as the handler.
  5. Enjoy your insanely fast lambda.

References

About

Starter project for building Slack apps with Micronaut


Languages

Language:Kotlin 77.9%Language:HCL 17.0%Language:Dockerfile 4.7%Language:Shell 0.4%