Ruby Helper

The Plivo Ruby helper simplifies the process of making Plivo API calls and generating Plivo XML. Please note that this is the legacy version.

If you are looking for the latest version, you can get it here.

Prerequisites

Installation

Quick Installation

Run the following command for a quick installation of the helper.

$ gem install plivo

Manual Installation

Install the helper manually from Github.

$ git clone git://github.com/plivo/plivo-ruby.git
$ rake gem
$ gem install pkg/plivo

Using the library

Initializing the RestAPI client

You can use plivo::RestAPI to initialize a REST client that can make API requests to Plivo.

1
2
3
AUTH_ID = "<auth_id>"
AUTH_TOKEN = "<auth_token>"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)

Send an SMS

The snippet below shows how you can send an SMS.

1
2
3
4
5
6
7
params = {
    'src' => '1111111111',
    'dst' => '2222222222',
    'text' => 'Hello, how are you?'
}

response = p.send_message(params)

Check out Message API documentation for more details.

Make an Outbound Phone Call

You can make outbound phone calls to landlines, mobiles, and SIP endpoints (e.g., softphones), in any of our 200+ coverage countries

1
2
3
4
5
6
7
8
params = {
    'to' => '2222222222',
    'from' => '1111111111',
    'answer_url' => 'https://s3.amazonaws.com/static.plivo.com/answer.xml',
    'answer_method' => 'GET'
}

response = p.make_call(params)

Check out Call API documentation for more details.

Examples

Take a look at the Ruby examples on GitHub.

Reporting Issues

Please report issues or submit patches using the Github Issue Tracker or Customer Support.

License

The Plivo Ruby Helper Library is written by the Plivo Team and is distributed under the MIT License.