An open API service indexing awesome lists of open source software.

https://github.com/actionhero/ah-slack-plugin

Make slack robots with ActionHero
https://github.com/actionhero/ah-slack-plugin

Last synced: 8 months ago
JSON representation

Make slack robots with ActionHero

Awesome Lists containing this project

README

          

# ActionHero Slack Plugin

[![CircleCI](https://circleci.com/gh/actionhero/ah-slack-plugin.svg?style=svg)](https://circleci.com/gh/actionhero/ah-slack-plugin)

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](www.actionheroj.com) 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

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

exports['default'] = {
plugins: (api) => {
return {
'slack': {path: path.join(__dirname, '..', 'node_modules', 'ah-slack-plugin')}
}
}
}
```

```js
// 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
}
}
}
}

```