#A script to post back to Slack via the webhooks API
##why this exists?
Slack's own hubot adapter needs the hubot installation to be accessible via web. This can be problematic in some cases, as a security risk.
This hack let's you run your Hubot behind a firewall, and connect to Slack via the IRC gateway.
To respond, Hubot uses the incoming webhooks end-point of Slack.
###Setup
- Enable the irc gateway in slack (https://slack.zendesk.com/hc/en-us/articles/201727913-Connecting-to-Slack-over-IRC-and-XMPP)
- Connect your hubot to that gateway using the Hubot Irc adapter
- Define your slack gateway with HUBOT_SLACK_WEBHOOK_URL
- Put slack-hubot-api.js inside the scripts directory
###Example Usage
## Listen on incoming message as usual
robot.respond /ping$/i, (msg) ->
plain_message = "Your fallback message for notifications and slack clients who don't support rich messages"
## Sending a notification to slack-hubot-api.js that we have a new message to send
robot.emit "push_slack_webhook",msg, {
fallback : plain_message,
attachments: [
{
fallback: plain_message,
text: "Some text here",
color: "#19BC9C",
fields: [
{
title: "Title of fist field",
value: "Text of irst field",
short: true
}
]
}
]
}
does this mean i will have to modify every coffee script to emit push_slack_webhook which in turn gets caught by slack-hubot-api.js which post the msg to HUBOT_SLACK_WEBHOOK_URL ? @altryne