A simple wrapper to asynchronously push slack notifications wit attachement generated from an elixir map with [error, warn info, success] level and color.
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
SlackNotification.notify(
:info,
"User `[email protected]` created an account",
%{id: "01D3KF1K6SSZBMKXQ5NGQGX23M"}
)
You will receive:
or with:
SlackNotification.notify(
:error,
"User `[email protected]` tried to hack you !",
%{id: "01D3KF1K6SSZBMKXQ5NGQGX23M", method: "the worst one!"}
)
You will receive:
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
SlackNotification.notify_channel(
:com,
:info,
"Wonderful notification title",
%{
size: 12,
name: "george"
}
)
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.