Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nolim1t/slack-webhook-utils
Helper utilities for doing slack webhooks. And can be used to create slackbots.
https://github.com/nolim1t/slack-webhook-utils
Last synced: 2 days ago
JSON representation
Helper utilities for doing slack webhooks. And can be used to create slackbots.
- Host: GitHub
- URL: https://github.com/nolim1t/slack-webhook-utils
- Owner: nolim1t
- License: mit
- Created: 2015-06-05T01:58:19.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-30T02:12:17.000Z (over 9 years ago)
- Last Synced: 2024-04-14T14:30:11.610Z (7 months ago)
- Language: CoffeeScript
- Size: 176 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Slack Webhooks Utilities
## About
These are utilities to create your own slack bot.## TODO
* Create utlity for processing incoming webhooks
* Make an NPM package
* Create an example bot
* Write unit tests## Usage
### How to use the incoming webhooks API
This will eventually change```code
o = require "./lib/incoming.coffee"
o {channel: "#random", botusername: "blah", msgtext: "This is a message", url: "https://slack.webhook.url"}, (cb) ->
console.log(cb)
```## Slash Commands
Here are some examples of implementing slash commannds in your app### Example Usage in Express 4.X router speak
```coffeescript
router.post '/slack', require('./lib/slashcmd.coffee')
```Which also requires the following middleware to be loaded. See examples folder for what sort of middleware needs to be included.
```coffeescript
# Middleware to load slack function
router.use (req, res, next) ->
req.slackfunction = require './slacker.coffee'
next()
```### Contents of slacker.coffee (which perhaps exist in the same folder as the router)
```coffeescript
module.exports = (info, cb) ->
result = {meta: {code: 200, msg: 'OK'}}
console.log info.text # User text
console.log info.user_name # User name
console.log info.command # command
cb(result)
```