Skip to content

A simple Slack bot for managing multiple-choice polls, written in Go

License

Notifications You must be signed in to change notification settings

chris-hamper/go-slack-poll

Repository files navigation

Go-slack-poll

Go Report Card

A simple Slack app that provides multiple-choice polling functionality. Users can vote for one or more choices by clicking on buttons in an interactive Slack message created by the bot using a Slack slash command.

Adding the pollbot to your Slack workspace

Before you begin, you'll need to have the bot running at a publicly accessible domain. Prefereably, you would have a reverse proxy or load balancer with HTTPS support in front of the bot.

  1. As a Slack admin, browse to https://api.slack.com/apps and click on [Create New App]
  2. Give the app a name (ex. "Poll Bot") and select the Slack workspace it should be connected with. Click [Create App]
  3. Under "Features" select "Interactive Components"
  4. Turn on "Interactivity" and fill in the "Request URL" with your bot's domain name, followed by /interaction:
    https://yourdomain.com/interaction
    
    and [Save Changes]
  5. Under "Features" select "Slash Commands" and [Create New Command]
  6. Pick a clear name for the command (ex. "/pollbot") and for the Request URL enter your bot's domain, followed by /command:
    https://yourdomain.com/command
    
    For "Short Description", enter "Creates a poll". For "Usage Hint" enter:
    "Title" "Choice 1" "Choice 2" ...
    
    Make sure "Escape channels, users, and links sent to your app" is enabled, and [Save]
  7. Under "OAuth & Permissions", make sure your app has chat:write:bot and commands permissions. Click [Save]
  8. Under "Settings" select "Install App" and [Install App to Workplace]

Starting the pollbot

Go-slack-poll uses Redis for persistence of its polls. If you have Docker and the docker-compose utility installed, you can easily spin up all of the necessary infrastructure from the command line. From the root of this repo, run:

$ SLACK_SIGNING_SECRET=YourAppSigningSecret docker-compose up

Starting the pollbot with Kubernetes and Helm

The pollbot and supporting Redis cluster can easily be installed on an existing Kubernetes cluster using Helm from the chart included in this repo. Once you have helm installed, run:

$ helm install ./helm/go-slack-poll \
    --name go-slack-poll \
    --set env.slackSigningSecret=`echo "YourAppSigningSecret" | base64`

Creating a poll in Slack

You can create a poll in Slack using the /pollbot command (or whatever slash command you have configured in your Slack app settings):

/pollbot "Is this pollbot just the best?" "Yes 🎉" "No 🙁"

About

A simple Slack bot for managing multiple-choice polls, written in Go

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published