Skip to content

actionhero/ah-slack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ActionHero Slack Plugin

CircleCI

A Slack server for ActionHero v18+. It will listen to all messages in all the rooms it is a member of, and do stuff.

Does you action have a response? It will be send back to slack. Don't want to respond in Slack? Set data.toRender = false in your action's run method.

To see a full ActionHero project example which uses this plugin, try here: https://github.com/actionhero/actionhero-slackbot-template

Configuration

In your ActionHero project: npm install --save ah-slack-plugin

Make a new bot for your slack team: https://my.slack.com/apps -> manage -> custom integrations -> bots -> new Note the TOKEN

// config/plugins.js
const path = require('path')

exports['default'] = {
  plugins: (api) => {
    return {
      'slack': {path: path.join(__dirname, '..', 'node_modules', 'ah-slack-plugin')}
    }
  }
}
// config/servers/slack.js
exports['default'] = {
  servers: {
    slack: (api) => {
      return {
        enabled: true,
        token: process.env.SLACK_BOT_TOKEN,
        // which messages should we try to parse as actions?  (could be a /command, @ a user, etc)
        // be sure to have a capture, as what you capture will be the action's name we try
        // for example `/^action\s(\w*).*$/i` would match `action thing otherThing`, trying the action "thing"
        messageActionRegexp: [
          /^action\s(\w*).*$/i,
        ]
        // how many messages should we store a history of receiving
        // messages can be accessed in `api.servers.servers.slack.messages`
        messagesToSave: 100
      }
    }
  }
}

About

Make slack robots with ActionHero

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published