Erlang Real Time Messaging API client for Slack.
- Erlang (>= R17) - because
maps
- rebar
$ rebar get-deps compile
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.
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).
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).
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