Skip to content

Instantly share code, notes, and snippets.

@carpeliam
Last active October 10, 2016 04:47
  • Select an option

Select an option

Revisions

  1. carpeliam revised this gist Oct 10, 2016. No changes.
  2. carpeliam created this gist Oct 10, 2016.
    9 changes: 9 additions & 0 deletions manifest.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    ---
    applications:
    - name: your-app-here
    command: node slack.js
    # no-route: true
    health-check-type: none
    domain: cfapps.io
    env:
    SLACK_API_TOKEN: your-token-here
    17 changes: 17 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    {
    "name": "wow, what a cool slack bot you just created",
    "version": "1.0.0",
    "description": "build whatever you can imagine",
    "scripts": {
    "test": "echo \"Error: no test specified... yet!\" && exit 1"
    },
    "keywords": [
    "slack",
    "bot"
    ],
    "author": "This is you",
    "license": "open source is good! open source your bot and add your license here",
    "dependencies": {
    "botkit": "^0.4.0"
    }
    }
    28 changes: 28 additions & 0 deletions slack.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    var Botkit = require('botkit');
    var token = process.env.SLACK_API_TOKEN || '';

    var controller = Botkit.slackbot({
    debug: process.env.NODE_ENV !== 'production'
    //include "log: false" to disable logging
    //or a "logLevel" integer from 0 to 7 to adjust logging verbosity
    });

    // connect the bot to a stream of messages
    controller.spawn({ token: token }).startRTM();

    // give the bot something to listen for.
    controller.hears('reserve', [
    'direct_message', 'direct_mention', 'mention'
    ],
    function(bot, message) {
    bot.reply(message, 'You just reserved a spot. Well, not really.');
    }
    );

    controller.hears('remove me', [
    'direct_message', 'direct_mention', 'mention'
    ],
    function(bot, message) {
    bot.reply(message, 'Thanks for letting me know! I\'ll remove you from the queue. Well, not really.');
    }
    );