tinyspeck/hubot-slack — pull request #32 by balbeko (2014-02-16 21:36:47+00:00)
Title: Rich "Attachment" Notifications Implemented (Re: #24)

I've finally implemented Attachment notifications, as suggested in #24

After a short discussion on IRC with @technicalpickles we've found probably a best way to implement this without extending core hubot functionality.

I've also wrote an example script that represents, how to use this feature. The code below will result with such message in a chat room:

![screenshot1](http://d.pr/i/fHyE+)

```coffeescript
# Description:
# Demonstrating Slack Attachments.
#
# Commands:
# hubot demo-attachment - Demo Attachement

module.exports = (robot) ->
robot.respond /demo-attachment$/i, (msg) =>
fields = []
fields.push
title: "Field 1: Title"
value: "Field 1: Value"
short: false

fields.push
title: "Field 2: Title"
value: "Field 2: Value"
short: false

payload =
message: msg.message
content:
text: "Attachement Demo Text"
fallback: "Fallback Text"
pretext: "This is Pretext"
color: "#FF0000"
fields: fields

robot.emit 'slack-attachment', payload
```