quotebot

package
v0.0.0-...-249a33d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

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

  1. Install and configure Go.
  2. Set up App Engine and your development environment.
  3. Create a new Slack app.

Getting the sample code

  1. Get the latest sample code.

    go get -u github.com/GoogleCloudPlatform/slack-samples/go/command/1-happy-clouds
    
  2. 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.

  1. Go to the Slack app that you created from your apps page.
  2. Create a new slash command.
    1. Click Slash commands under the Features header on the left-hand side of the Slack app configuration page.
    2. Click the Create new command button.
    3. Enter the command name, like /happycloud.
    4. For the Request URL, enter https://YOUR-PROJECT.appspot.com/quotes/random, replace YOUR-PROJECT with your Google Cloud Project ID.
    5. For the description, enter "Displays a happy quote".
    6. Click the Save button in the lower right-hand corner.
  3. Copy the verification token.
    1. Click Basic information under the Settings header on the left-hand navigation.
    2. 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.

Configure the Go app

  1. Open config.go in a text editor.

  2. Set the token field to the value you copied. Change the line

    token string
    

    to

    token = "YOUR-TOKEN-VALUE"
    

Build and Deploy

  1. Deploy the app to App Engine.

    goapp deploy -application your-project app.yaml
    

    Replace your-project with your Google Cloud Project ID.

  2. 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

Documentation

Overview

Package quotebot demonstrates how to create an App Engine application as a Slack slash command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL