Hosting a Slack Slash Command on Google App Engine
This sample shows you how to build a Slack internal
integration with a slash
command running on Google App
Engine.
This tutorial uses the Go programming language. See the Google Cloud Platform
Slack Samples repository
for a list of samples in other languages.
Objectives
- Deploy a Slack slash command server to App Engine.
- Configure an internal Slack app to call an App Engine application for slash
commands.
Costs
This tutorial uses billable components of Cloud Platform including Google App
Engine standard environment. Use the Pricing
Calculator
to estimate the costs for your usage. Note that a portion of your usage is
covered by the App Engine free
tier.
Slack is free for up to 10 apps and integrations. Check the Slack pricing
page for details.
Before you begin
- Install and configure Go.
- Set up App Engine and your development
environment.
- Create a new Slack app.
Getting the sample code
-
Get the latest sample code.
go get -u github.com/GoogleCloudPlatform/slack-samples/go/command/1-happy-clouds
-
Change to the sample code directory.
cd $GOPATH/src/github.com/GoogleCloudPlatform/slack-samples/go/command/1-happy-clouds
Setup Slack
Configure a new slash command for your
Slack app.
- Go to the Slack app that you created from your apps page.
- Create a new slash command.
- Click Slash commands under the Features header on the left-hand
side of the Slack app configuration page.
- Click the Create new command button.
- Enter the command name, like
/happycloud
.
- For the Request URL, enter
https://YOUR-PROJECT.appspot.com/quotes/random
, replace
YOUR-PROJECT
with your Google Cloud Project
ID.
- For the description, enter "Displays a happy quote".
- Click the Save button in the lower right-hand corner.
- Copy the verification token.
- Click Basic information under the Settings header on the
left-hand navigation.
- Copy the Verification token to your clipboard.
Be careful with your token. Treat it
like you would any other secret token. Do not store tokens in version control
or share them publicly.
-
Open config.go
in a text editor.
-
Set the token field to the value you copied. Change the line
token string
to
token = "YOUR-TOKEN-VALUE"
Build and Deploy
-
Deploy the app to App Engine.
goapp deploy -application your-project app.yaml
Replace your-project
with your Google Cloud Project ID.
-
If this is not the first App Engine application you have deployed to this
project, go to the Google Cloud Platform
Console, select
version 1 in the App Engine versions and click Migrate traffic to send
requests to the deployed version.
Try It Out
In your Slack team, write a message with the text /happycloud
. You should see
a happy little quote in response.
Next steps