Packages

Sends simple messages to Slack channel using webhook API.

Current section

Files

Jump to
slack_webhook lib slack_webhook.ex
Raw

lib/slack_webhook.ex

defmodule SlackWebhook do
@doc """
Sends message to default channel.
Remember to configure your webhook at config/config.exs:
config :slack_webhook, :url, "https://hooks.slack.com/services/*/*/*"
"""
def send(msg) do
__MODULE__.send(msg, Application.get_env(:slack_webhook, :url, ""))
end
@doc """
Sends message to selected webhook url.
Use if your application uses more than one hook.
"""
def send(msg, url) do
HTTPoison.post url, """
{
"text": "#{msg}"
}
"""
end
end