Skip to content

Simple Slack webhook notification pusher, with attachement generation and color level.

Notifications You must be signed in to change notification settings

delight-data/elixir_slack_notification

Repository files navigation

SlackNotification

A simple wrapper to asynchronously push slack notifications wit attachement generated from an elixir map with [error, warn info, success] level and color.

Installation

Add to your list of dependencies in mix.exs:

def deps do
  [
    {:slack_notification, git: "git://github.com/delight-data/elixir_slack_notification.git", tag: "v1.2.0"}
  ]
end

Typical usage:

  SlackNotification.notify(
    :info,
    "User `[email protected]` created an account",
    %{id: "01D3KF1K6SSZBMKXQ5NGQGX23M"}
  )

You will receive:

info sample

or with:

  SlackNotification.notify(
    :error,
    "User `[email protected]` tried to hack you !",
    %{id: "01D3KF1K6SSZBMKXQ5NGQGX23M", method: "the worst one!"}
  )

You will receive:

info sample

configuration:

config :slack_notification, url: "https://hooks.slack.com/services/<yours>/<yours>/<yours>"

to disable the actual push (in test environment for instance), you can disable it:

config :slack_notification, enabled: false

Multiple channel slack notifications

  SlackNotification.notify_channel(
    :com,
    :info,
    "Wonderful notification title",
    %{
      size: 12,
      name: "george"
    }
  )

configuration:

config :slack_notification,
  url: "https://hooks.slack.com/services/<yours>/<yours>/<yours>",
  channels: %{
    com: "https://hooks.slack.com/services/<yours>/<yours>/<yours>"
  }

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/slack_notification.

About

Simple Slack webhook notification pusher, with attachement generation and color level.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages