Last active
October 30, 2017 20:21
-
-
Save willrax/7625ebe8aeaf63e369a15787135a5dd8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule AlphabotWeb.IntercomController do | |
use AlphabotWeb, :controller | |
def new(conn, %{"topic" => "conversation.user.created"} = params) do | |
%{payload: params["data"]["item"]} | |
|> send_notification | |
json conn, %{} | |
end | |
def new(conn, _params), do: json conn, %{} | |
def send_notification(state) do | |
# [Insert lots of pattern matching and pulling information | |
# from the darkest depths of a JSON payload here] | |
params = [ | |
{:channel, Alphabot.Channel.support}, | |
{:icon_url, @bot_image}, | |
{:username, "Intercom"}, | |
{:as_user, false}, | |
{:attachments, Poison.encode!([attachments])} | |
] | |
SlackClient.api("chat.postMessage", params) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment