Giter Club home page Giter Club logo

slack-interactivity-example's Introduction

Overview

This is an example project showing how to handle interactivity from slack. It uses Slack Block Kit to add a button to a message and Slack app interactivity to receive a webhook and post a message back to the user.

Setup

Local machine

You'll need to install ruby 2.6.5 and bundler on your machine. I use rbenv which isn't entirely terrible.

$ rbenv install 2.6.5
$ gem install bundler

Then, install the gems in Gemfile

$ bundle install

Finally, you're ready to start the test server

$ bundle exec ./server.rb

Change slack url

Modify server.rb and change the SLACK_URL to your applcation's webhook url.

Get a development URL

In this example I use localhost.run to expose my local development instance to the internet to that Slack can invoke my app under development. You may have to do some fancy footwork to install ssh if you're running on a windows box:

$ ssh -R 80:localhost:4567 ssh.localhost.run
Connect to http://xxxxx.localhost.run or https://xxxxx.localhost.run

Make note of your localhost.run https url, it'll change every time you start a new tunnel.

Setup slack webooks

Set the Request URL for your app (as described here) to the localhost.run https URL above with /slack-webhook appended. For example, if your localhost.run https URL is https://awesome-123.localhost.run you'll set RequestURL to https://awesome-123.localhost.run/slack-webhook.

Running the example

Finally, test it out:

$ curl -X POST -d '{"name": "Gregg"}' -H 'Content-Type: application/json' http://localhost:4567/hello

slack-interactivity-example's People

Contributors

hawknewton avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.