Git Product home page Git Product logo

slackbots's Introduction

All of the examples in this repository follow the same pattern for testing and uploading to IronWorker. Just cd into the bots directory and do the following:

1) Create an Incoming Webhook URL in Slack, then create a config file, config.json, that looks like this:

{
  "webhook_url": "https://hooks.slack.com/services/abc/123/xyz"
}

You can reuse this same incoming URL for all your bots so you don't have to keep making new ones.

2) Install dependencies

docker run --rm -v "$(pwd)":/worker -w /worker iron/images:ruby-2.1 sh -c 'bundle install --standalone --clean'

3) Test

Each bot directory has a slack.payload file that is an example file so you can run a quick test that will post a message to slack. Run it with this command:

docker run --rm -v "$(pwd)":/worker -w /worker iron/images:ruby-2.1 sh -c 'ruby <BOTNAME>.rb -payload slack.payload -config config.json'

4) Upload to IronWorker

zip -r <BOTNAME>.zip .
iron worker upload --stack ruby-2.1 --config-file config.json <BOTNAME>.zip ruby <BOTNAME>.rb

Grab the URL that will be printed after you run the previous command and surf to it in your browser, it will look something like this:

https://hud.iron.io/tq/projects/4fd2729368/code/50fd7a3051df9225ba

On that page, you’ll see a Webhook URL, it will look something like this:

https://worker-aws-us-east-1.iron.io/2/projects/4fd2729368/tasks/webhook?code_name=hello&oauth=abc

Copy that URL, we'll use it in the next step.

5) 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 IronWorker’s webhook URL you got in the step above and paste it into the URL field then click Save Integration.

6) Try it out!

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

slackbots's People

Contributors

treeder avatar

Watchers

 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.