Ruby SDK for Satori RTM

RTM is the realtime messaging service at the core of the Satori.

Ruby SDK makes it more convenient to use Satori RTM from Ruby programming language.


Ruby SDK works on Ruby >= 2.0 and JRuby.

Install it with RubyGems

gem install satori-rtm-sdk --pre

or add this to your Gemfile if you use Bundler:

gem "satori-rtm-sdk", ">= 0.0.1.rc1"


Getting started

Here's an example how to use Satori RTM SDK to write publish / subscribe logic:

require 'satori-rtm-sdk'

endpoint = 'YOUR_ENDPOINT'
appkey = 'YOUR_APPKEY'

client =, appkey)


client.subscribe 'animals' do |_ctx, event|
  case event.type
  when :subscribed
    puts "Subscribed to the channel: #{[:subscription_id]}"
  when :data[:messages].each { |msg| puts "Animal is received #{msg}" }
  when :error
    puts "Subscription error: #{[:error]} -- #{[:reason]}"

loop do
  client.publish 'animals', who: 'zebra', where: [34.13, -118.32]
  client.sock_read_repeatedly duration_in_secs: 2


Ruby SDK for Satori RTM doesn't lock you into using threading or event loop frameworks, but it's ready to be used with any of those.

The example of using Ruby SDK with EventMachine can be found in examples/eventmachine_quickstart.rb


You can enable dumping of all PDUs either from your code


or by setting DEBUG_SATORI_SDK environment variable prior to running your application

$ DEBUG_SATORI_SDK=true ruby myapp.rb

Testing Your Changes

Tests require an active RTM to be available. The tests require credentials.json to be populated with the RTM properties.

The credentials.json file must include the following key-value pairs:

  "endpoint": "YOUR_ENDPOINT",
  "appkey": "YOUR_APPKEY",
  "auth_role_name": "YOUR_ROLE",
  "auth_role_secret_key": "YOUR_SECRET",
  "auth_restricted_channel": "YOUR_RESTRICTED_CHANNEL"
  • endpoint is your customer-specific endpoint for RTM access.
  • appkey is your application key.
  • auth_role_name is a role name that permits to publish / subscribe to auth_restricted_channel. Must be not default.
  • auth_role_secret_key is a secret key for auth_role_name.
  • auth_restricted_channel is a channel with subscribe and publish access for auth_role_name role only.

After setting up credentials.json, just type rspec spec at the command line.