Skip to content

Lita handler for sending notifications to Slack users through the bot

License

Notifications You must be signed in to change notification settings

mbainter/lita-dm-notifier

Repository files navigation

lita-dm-notifier

Gem Version Build Status Coverage Status

This is a simple handler to allow leveraging Lita to send direct messages to users via webhooks. Historically email is usually how we send out notifications from our systems, but with modern authentication systems and often dynamic ip addressing this can be a headache. With this handler you can instead send a simple post call to Lita and send rich messages to users for notifications instead.

Note: At the moment this only works with the Slack adaptor.

Installation

Add lita-dm-notifier to your Lita instance's Gemfile:

gem "lita-dm-notifier"

Configuration

There is no configuration necessary for this plugin as of yet.

Usage

Send a post call with a JSON blob to your Lita's HTTP endpoint, such as http://lita:8080/dm/notify/. At a minimum it needs the text, fields, type and user fields. Beyond that you can add any field from the Slack attachment API except color and it will honor it.

If the type field is set to "info", "good", "warning", or "danger" it will set the color accordingly using slack's options, otherwise the color will be "black". The type will also be included as a field added to whatever fields are passed in. If no fallback field is included then fallback will be set to the same content as the text field.

The user field should be the mention_name for the user in slack.

So, with a message of:

{
    "fields": [],
    "footer": "http cli test of lita-dm-notifier",
    "text": "This is a test of lita-dm-notifier",
    "title": "THIS IS A TEST. THIS IS ONLY A TEST",
    "title_link": "http://github.com/mbainter/lita-dm-notifier",
    "type": "info",
    "user": "markb"
}
http --all --verbose POST http://localhost:8080/dm/notify @/tmp/dm-notifier-test.json
POST /dm/notify HTTP/1.1
...
HTTP/1.1 200 OK
Transfer-Encoding: chunked

Example output in Slack

License

Simplified BSD

About

Lita handler for sending notifications to Slack users through the bot

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published