Categorygithub.com/kn-lim/slackingway-bot
module
0.0.0-20250103222616-755c5cc75662
Repository: https://github.com/kn-lim/slackingway-bot.git
Documentation: pkg.go.dev

# README


I'm a 🤖!

slackingway-bot

Go GitHub Workflow Status - Build GitHub Workflow Status - Test Coverage Status Go Report Card License

A personal Slack bot to handle miscellaneous tasks hosted on AWS Lambda.

Packages Used

Using the Slack Bot

Slack Slash Commands

CommandDescription
/coinflipFlips a coin
/delayed-pingPing with a delay
/echoOpens a Slack modal to echo a text to the output channel
/menuOpens a Slack modal to select options and sends the result to the output channel
/pingPing
/rollRolls a dice with modifiers

How to Build

From the project home directory:

  • Endpoint Function: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags lambda.norpc -o binary/bootstrap ./cmd/endpoint/
  • Task Function: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags lambda.norpc -o binary/bootstrap ./cmd/task/

Zip the bootstrap binaries and upload it to the Lambda functions.

Environment Variables

Endpoint Lambda Function

NameDescription
DEBUGEnable debug mode
TASK_FUNCTION_NAMEName of the Task Lambda Function
SLACK_SIGNING_SECRETSlack App's Signing Secret
SLACK_OAUTH_TOKENSlack App's OAuth Token
SLACK_HISTORY_CHANNEL_IDSlackingway's History Channel ID
SLACK_OUTPUT_CHANNEL_IDSlackingway's Output Channel ID
ADMIN_ROLE_USERSComma-delimited string of Slack User IDs with admin roles

Task Lambda Function

NameDescription
DEBUGEnable debug mode
SLACK_OAUTH_TOKENSlack App's OAuth Token
SLACK_HISTORY_CHANNEL_IDSlackingway's History Channel ID
SLACK_OUTPUT_CHANNEL_IDSlackingway's Output Channel ID

AWS Setup

To quickly spin up slackingway-bot on AWS, use the Terraform module.

  1. Create the endpoint Lambda function on AWS.
    • For the Runtime, select Amazon Linux 2023.
    • For the Architecture, select x86_64.
  2. Add an API Gateway triger to the endpoint Lambda function.
    • Use the following settings:
      • Intent: Create a new API
      • API type: REST API
      • Security: Open
  3. Create the task Lambda function on AWS.
    • For the Runtime, select Amazon Linux 2023.
    • For the Architecture, select x86_64.
  4. Build the endpoint and task binaries.
  5. Archive the bootstrap binaries in .zip files and upload it to the Lambda functions.
  6. In the Configuration tab, add in the required environment variables to the Lambda functions.
  7. Change the Timeout of the task Lambda function to a value greater than 3 seconds.
    • The Timeout of the endpoint Lambda function can stay as 3 seconds to follow Slack's requirements.

Slack Setup

Slash Commands

Get the endpoint Lambda API Gateway triggers's API endpoint and add it to the Slack apps's Request URL in each Slack Slash Command in the Slack API page.

OAuth & Permissions

OAuth Tokens

Save the Bot User OAuth Token as the SLACK_OAUTH_TOKEN environment variable in the task Lambda function.

Scopes

Enable the following Bot Token Scopes:

  • channels:history
  • chat:write
  • chat:write.customize
  • commands
  • im:history
  • users.profile:read
  • users:read

Event Subscriptions

Enable Events

Get the endpoint Lambda API Gateway triggers's API endpoint and add it to the Slack apps's Request URL. It should be verified after a second.

Subscribe to Bot Events

Add the following bot user events:

  • app_home_opened

# Packages

No description provided by the author