Ruby VoIP developers 101

Part 4: Ruby connection with gem library (Calls)

The Ozeki Phone System gives you the opportunity to use its special features. It is possible to use the ops_sdk.gem library to connect to the Ozeki Phone System. This guide helps you to install, and use this library.

Part 1: Ruby example on sending SMS, making VoIP calls
Part 2: Ruby example on recording VoIP calls, call routing
Part 3: Ruby connection with gem library (SMS)
Part 5: Ruby SDK Commands


This page assumes that you already have some basic knowledge in Ruby programming language. If you don't have these skills, then you should check out our basic examle site at Ruby basic example.

1. Installing

First you should download the (100KB). After unpacking this zip file, you should execute the following command in a command prompt or in a terminal.

gem install ops_sdk

2. Using the library

In your project after the successful installation, you should include the gem file with the following command.

require 'ops_sdk'

Code example 1 - Including Ozeki Phone System SDK library

Now you are ready to call the functions. Here is an example how to send an SMS from the 9999 API extension to the 2000 SIP extension if your Ozeki Phone System XE IP address is, the HTTP API service is listening on port 7780, and the authentication is set to Anonymous.

OPS.send_sms '', '9999', '2000', 'Hello world!'

ops = '', '9999'
ops.send_sms '2000', 'Hello world!'

Code example 2 - Sending an SMS message

To send an e-mail with the aid of 9999 API extension.

OPS.send_email '', '9999', '', 'Nin hao!', nil, ''

ops = '', '9999'
ops.send_email '', 'Nin hao!', nil, ''

Code example 3 - Sending an e-mail message

To call an extension with the aid of 9999 API extension.

OPS.make_call '', '9999', '2000', 7780, 'http://localhost/test.xml', nil, 'Elek'

ops = '', '9999'
ops.make_call '2000', 7780, 'http://localhost/test.xml', nil, 'Elek'

Code example 4 - Make a call

To get a list of active calls.

calls = OPS.list_active_calls ''
puts calls

ops = ''
calls = ops.list_active_calls
puts calls

Code example 5 - List active calls

3. Call functions

After you get the active calls with the list_active_calls command, you are able to use the following commands too.

# Get active calls if HTTP API service running on port 7781
calls = OPS.list_active_calls '', 7781

call = calls[0]
if (call == nil)
return 'No call in progress.'

# The hold command is used to put both legs of the call into Hold state.

# The unhold command is used to put both legs of the call to InCall state.

# The dtmf command is used to send a DTMF message to a participant of the conversation.
call.dtmf "12345"
call.dtmf_to_caller "678"
call.dtmf_to_callee "90"

# The speak command converts the given text to speech and plays it to the caller, callee or all.
call.speak "12345"
call.speak_to_caller "678"
call.speak_to_callee "90"

# The play_file command is used to play a wav or mp3 sound to the parties of the conversation.
call.play_file "C:\work\Other\simpledemo.wav"
call.play_file_to_caller "C:\work\Other\simpledemo.wav"
call.play_file_to_callee "C:\work\Other\simpledemo.wav"

# Records the conversation in a call. When the call finished, a request will be sent to the specified URL.

# The forward command forwards a call by ID to another number while it's still in ringing state.
call.forward 1000

# The BlindTransfer command is used to connect two phones together.
call.blind_transfer_callee 1002
call.blind_transfer_caller 1000

# The Hangup command is used to disconnect an ongoing call in the system.

Code example 5 - Call commands

Read more about OzML commands.

Part 5: Ruby SDK Commands

If you have any questions or need assistance, please do not hesitate to contact us at

More information