Set up Your Ruby Dev Environment for PHLO
In this guide, you will learn how to set up a development environment in under 5 minutes to trigger a PHLO.
Prerequisites
Install Node.js and the Plivo Node.js SDK
You must set up and install Ruby and Plivo’s Ruby SDK to trigger a PHLO. Here’s how.
Install Java
Operating System | Instructions |
---|---|
OS X & Linux | You would already have Ruby installed, you can check this by running the command ruby --version in the terminal. If you don't have it installed, you can install it using homebrew. |
Windows | To install Ruby on Windows you can download it from here and install. |
Install Plivo Ruby Package
Create a project directory, run the following command:
$ mkdir myrubyapp
Change the directory to our project directory in the command line:
$ cd myrubyapp
Add this line to your application’s Gemfile:
gem 'plivo', '>= 4.3.0'
And then execute:
$ bundle
Or install it yourself as:
$ gem install plivo
Trigger a PHLO
Once you have created and configured your PHLO, copy the PHLO Run URL. You can integrate a PHLO into your application workflow by making an API request to the PHLO URL with the required payload.
With Static Payload
You can choose to either configure the mandatory params required for a PHLO while creating the PHLO itself or, you can pass the params as payload while triggering the PHLO from your app.
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'rubygems'
require 'plivo'
include Plivo
AUTH_ID = 'AUTH_ID'
AUTH_TOKEN = 'AUTH_TOKEN'
client = Phlo.new(AUTH_ID, AUTH_TOKEN)
# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
# then initialize client as:
# client = Phlo.new
begin
phlo = client.phlo.get('phlo_id')
response = phlo.run()
puts response
rescue PlivoRESTError => e
puts 'Exception: ' + e.message
end
With Dynamic Payload
To use dynamic values for the parameters, you can use the liquid templating params while creating the PHLO and pass the values while triggering the PHLO.
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'rubygems'
require 'plivo'
include Plivo
AUTH_ID = 'AUTH_ID'
AUTH_TOKEN = 'AUTH_TOKEN'
client = Phlo.new(AUTH_ID, AUTH_TOKEN)
# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
# then initialize client as:
# client = Phlo.new
begin
phlo = client.phlo.get('phlo_id')
#parameters set in PHLO - params
params = {
from: '+14157778888',
to: '+14157778889'
}
response = phlo.run(params)
puts response
rescue PlivoRESTError => e
puts 'Exception: ' + e.message
end
You can get your Auth_ID and Auth_token from your dashboard
You can find the PHLO_ID on the PHLO Listing page.