Implementing this Slack library in Phoenix?

I’m trying to get this Slack library working in a Phoenix project. I’ve got the handles set up in a channel, I’ve got the channel listed in the user_socket.ex file, but I’m not sure how the start_link method would be different.

{:ok, rtm} = Slack.Bot.start_link(SlackRtm, [], "token")
send rtm, {:message, "External message", "#general"}

Could someone show me how those lines of code would fit into a Phoenix 1.3 project?

Well I would put the start_link part in a supervisor like so:

worker(Slack.Bot, [SlackRtm, [], "token"]), # or something like that

And I’d give it a {:local, Blah} name too so I could reference it from anywhere.
And the ‘send’ call to be in whatever should send it using that Blah local name. ^.^

Or just put it all in a GenServer.

I have a discord bot in elixir, I should put it on github sometime as it would work pretty similar as a tutorial’ish for a slack bot too…

1 Like

Thank you! Seeing some code for your bot would be great too! Let me know if you decide to put that up somewhere.

Went ahead and uploaded it. It is not a shining beacon of code design, everything there was written in about an hour ‘just to get it done’ since it was for a personal project. ^.^;

But I start the discord library as a worker in my project at:

I also start up an IRC connection worker before it (I needed an IRC bridge) and a Command worker below it (to handle bot commands).

1 Like

Thanks! This is really helpful

1 Like

We’re you able to get this to work? I’m looking to do the same. Thanks

I think I figured out a short while later that I wanted to do with Slack at the time was not possible and ended up dropping the whole thing. I don’t believe I ever did figure it out, tried looking for the project but seems I deleted it. Sorry I can’t be of more help.