tgrk / slacker-rtm

Erlang Real Time Messaging API client for Slack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

slacker-rtm

Erlang Real Time Messaging API client for Slack.

Dependencies

  • Erlang (>= R17) - because maps
  • rebar

Fetch dependencies and compile

$ rebar get-deps compile

Authentication

The Slack RTM API uses custom implementation of oAuth 2.0 for authentiaction. Authorization process is not part of this library and you have to manually register your application and obtain valid token.

Quick start

Include library in your rebar.conf.

{'slacker-rtm', "",
   {git, "https://github.com/tgrk/slacker-rtm.git", {branch, "master"}}}

Connect to API using obtained token:

{ok, Pid} = sr:connect(BinToken).

Sending messages

Slack RTM API supports only plain text messages. Rich formatted messages (aka attachmets) using JSON structures that follow specific formatting are not supported. Please refer to Sending messages section of oficial Slack RTM API documentation. For sending rich formatted messages (aka attachments) you have to use slacker - Slack Web API client.

Simple message can be created using following helper:

JsonMsg = sr:format_message(1, <<"foo">>, <<"Hello world!">>).
ok = sr:send(Pid, JsonMsg).

Testing

You have to setup API token file in order to use tests. Please add your valid token into template (replace .template) file test/api_token.term.

Tests are executed as usual:

$ rebar co eunit skip_deps=true

About

Erlang Real Time Messaging API client for Slack

License:MIT License


Languages

Language:Erlang 83.8%Language:Makefile 14.5%Language:Shell 1.7%