SlackApp-SwiftServerlessTemplate

Template repository for bootstrapping Serverless Slack Apps using Swift & AWS Lambdas.

Using this Template

To get started using this template, I recommend using GitHub CLI and issuing the following command to create & clone a new public repo based off this template.

gh repo create <AppName> \
  --template spydercapriani/SlackApp-SwiftServerlessTemplate \
  --public \
  --clone

Environment Variables

There is a shared scheme for SlackApp executable product with a few environment variables necessary for running the app.

  • (!) SLACK_ACCESS_TOKEN
    • This can be found in your Slack's App Dashboard under OAuth & Permissions > Bot User OAuth
  • (?) SLACK_VERIFICATION_TOKEN1
    • This can be found in your Slack's App Dashboard under Basic Information

(!) denotes required

(?) denotes optional

Dependencies

See Brewfile for tool dependencies.

SwiftBlocksUI

SwiftBlocksUI leverages MacroApp under the hood to provide a declarative "SwiftUI" like approach to creating interactive Slack "applications" using Swift.

MacroApp layers on top of MacroExpress which focuses on generating API endpoints in a fast, typesafe way.

MacroLambda

MacroLambda acts as a middleware component for running MacroExpress apps as AWS Lambda Runtime executables.

Plugins

AWSLambdaPackager

Plugin for creating an AWS Lambda binary .zip using an AmazonLinux2 container via Docker.

Usage: swift package --disable-sandbox archive

This will create a <ProductName>.zip file located at:

.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager//.zip which can be used for uploading to AWS Lambda.

Requires Docker to be installed/running

brew install docker

Resources

Footnotes

  1. This will soon be deprecated in favor of SLACK_SIGNING_SECRET