Using Attachments to Format Slack Messages

In addition to sending simple text-based messages, you can use the Slack
attachment mechanism to send formatted
messages. Watcher leverages Slack attachments to enable you to dynamically
populate templated messages from the execution context payload.

To define an attachment template that is dynamically populated from the payload,
you specify dynamic_attachments in the watch action. For example, a dynamic
attachment could reference histogram buckets in the payload and build an
attachment per bucket.

In the following example, the watch input executes a search with a date histogram
aggregation and the Slack action:

Transforms the payload to a list where each item in the list holds the month,
the user count for that month, and the color that represents the sentiment
associated with that count (danger or bad).

Defines an attachment template that references items in the list generated by
the transform.