Files
fn-serverless/examples/slackbot/guppy
Guilherme Rezende 179c659cc8 Add slackbot guppy example (#342)
* Add slackbot guppy example

* Add json dependence to slackbot Gemfile
2016-11-28 08:50:11 -02:00
..
2016-11-28 08:50:11 -02:00
2016-11-28 08:50:11 -02:00
2016-11-28 08:50:11 -02:00

Quick Example for a SlackBot command in Ruby

This example will show you how to test and deploy a SlackBot command to IronFunctions.

# create your func.yaml file
fn init <YOUR_DOCKERHUB_USERNAME>/guppy
# install dependencies, we need the json gem to run this
docker run --rm -v "$PWD":/worker -w /worker iron/ruby:dev bundle install --standalone --clean
# build the function
fn build
# test it
cat slack.payload | fn run
# push it to Docker Hub for use with IronFunctions
fn push
# Create a route to this function on IronFunctions
fn routes create slackbot /guppy
# Change the route response header content-type to application/json
curl -X PUT http://127.0.0.1:8080/v1/apps/slackbot/routes/guppy -d '{ "route": { "headers": { "Content-type": ["application/json"] } } }'

Create a Slash Command integration in Slack

In Slack, go to Integrations, find Slash Commands, click Add, type in / as the command then click Add again. On the next page, take the IronFunctions route URL and paste it into the URL field then click Save Integration.

If running in localhost, use ngrok.

Try it out!

In slack, type / [options] and you'll see the magic!