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"}
]
endTypical usage:
SlackNotification.notify(
:info,
"User `john@delight-data.com` created an account",
%{id: "01D3KF1K6SSZBMKXQ5NGQGX23M"}
)You will receive:
or with:
SlackNotification.notify(
:error,
"User `john@delight-data.com` tried to hack you !",
%{id: "01D3KF1K6SSZBMKXQ5NGQGX23M", method: "the worst one!"}
)You will receive:
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: falseMultiple 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.