A basic example of interactive message flows in Slack, this skeleton app responds to a slash command invocation with an action block containing a select menu and button. Out of the box, it simply allows users to select/deselect members from their workspace.
The purpose of this repo is to reduce boilerplate when starting up a new Slackbot project. Build on/change the existing response logic to create your own personal interactive message flow.
Blocks are Slack's replacement for the now-deprecated message attachments. Read more about them here.
Follow the steps below to get the bot up and running:
- After you've cloned the app, visit the Slack API dashboard and select
Create New App
. - Once the app is created, jump inside and select
Add features and functionality
. - Select
Interactive Components
and turn on interactivity for your app. - You will be prompted for a request URL: this is the API endpoint to which Slack will forward any callback messages your bot receives. While in the development process I highly recommend using ngrok. Once you have your URL, append
/callback
and input it on theInteractive Components
page. - Setup two slash commands for the
/add-users
and/help
endpoints from the Slash Commands tab of the dashboard - Next, select
Bot Users
from the sidebar and add a bot user to your app. - Visit the
Oauth & Permissions
tab and install the app to your workspace. This will generate access tokens for both you and the bot user. - Obtain your signing secret from the
Basic Information
tab and set it as an environment variable (required). - Obtain your bot's access token from the
Oauth & Permissions
page and set it as an environment variable (required). - Build the binary and start your server.
- This project uses modules, which were first introduced in Go
1.11
. Use of modules is optional in1.11
, so if you are working within yourGOPATH
you will need to enable the use of modules by running:export GO111MODULE=on
- This project uses modules, which were first introduced in Go
You're done! The bot is now installed to your workplace and capable of responding to the registered slash commands from any channels you invite it to.
The project includes a basic deploy script for use with Google's App Engine. You will need to have the gcloud CLI installed to utilize this locally, otherwise you can deploy via the cloud shell.
By default, the app will be deployed to the GCP project specified via gcloud config set core/project PROJECT
.
You can confirm your current project by running the following command: gcloud config get-value project