Skip to content

ventx/slack-pollapp

Repository files navigation

Pollapp

A basic serverless Slack polling app with

Prerequisites

Make sure that you have

Provision AWS Resources

We use Terraform to create our infrastructure

  • update terraform.tfvars
    • aws_region with our desired AWS target region
    • aws_profile with the AWS profile we're using
    • zone_name with the name of an already existing hosted zone, where the app's record and certificate validation records will be created and
  • run both terraform init and terraform apply.

You may have to wait for the DNS record to propagate for a little while, use nslookup by running the output of the terraform output -raw check_url_command command.

Installing the Slack App to your Workspace

Install the app to a Slack workspace using an app manifest file:

  • go to https://api.slack.com/apps
  • click on Create New App
  • click on From an app manifest
  • select your desired workspace and click on Next
  • run terraform output -raw app_manifest in the project's root folder and copy the output
  • select YAML, paste above's app manifest and click on Next
  • click on Create
  • navigate to Settings > Basic Information, click on Install to Workspace in the Install your app section and confirm by clicking on Allow in the following dialog

Next put the app's Signing Secret and Bot User OAuth Token into the secret so that the Lambda function can authenticate with Slack:

  • go to https://api.slack.com/apps
  • click on Your Apps and select our app
  • navigate to Settings > Basic Information and copy the Signing Secret's value
  • navigate to Features > OAuth & Permissions and copy the Bot User OAuth Token's value
  • run terraform output -raw set_slack_secret_command, copy the output command, replace <SLACK_BOT_TOKEN> and <SLACK_SIGNING_SECRET> with above's Signing Secret and Bot User OAuth Token so that the result looks like this
aws secretsmanager put-secret-value \
    --secret-id pollapp_slack_secrets \
    --secret-string "{\"SLACK_BOT_TOKEN\":\"<SLACK_BOT_TOKEN>\",\"SLACK_SIGNING_SECRET\":\"<SLACK_SIGNING_SECRET>\"}\" \
    --region us-east-1 \
    --profile default
  • run the above command
  • navigate to Features > App Manifest where you may find an info box stating that the URL isn't verified and click Click here to verify

Finally test that everything is working by initiating a poll with something like /poll "My polling app works" "Yes" "No" in your Slack workspace.

Cleanup

To delete your Slack app

  • go to https://api.slack.com/apps
  • click on Your Apps and select our app
  • navigate to Settings > Basic Information and click on Delete App

To delete all AWS resources

  • run terraform destroy

About

A basic Slack polling app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published