Overview

PHLO stands for Plivo High-Level Objects. It is a collection of building blocks that allows you to create custom communication workflows (including Voice and SMS) based on your requirements. With PHLO, you can build applications with much lesser code. It provides you with a graphical user interface where you can place components and create custom workflows to better suit your needs.

We have put together the following collection of use cases guides to help you get started:

The above use cases are also available on Plivo Console as PHLO Templates. PHLO Templates are predefined workflows that you can use to build and ship your capabilities faster. Depending on the template, all necessary nodes and connections will be available for you to configure and deploy.

Features

PHLO has the following features:

  • Complete parity with Plivo APIs
  • Interface to drag and drop components and create workflows
  • Build applications and ship capabilities faster with much lesser code, using PHLO Templates
  • Create custom integrations with third-party applications
  • Create Voice and SMS based capabilities

PHLO Basics

PHLO

Pronounced as “flow”, PHLO stands for Plivo High-Level Objects. It is a combination of components that make a workflow.

The following components are available in PHLO:

  • Send SMS
  • IVR Menu
  • Get Input
  • Initiate Call
  • Call forward
  • Hangup
  • Conference
  • Play Audio
  • Record Audio
  • Multi-Party Call
  • HTTP Request
  • Counter
  • Branch

Canvas

Canvas is the space where you place and connect different components to create a PHLO. It is an infinitely scrollable space which allows the user to create and view the PHLOs.

Top Navigation Bar

The Top Navigation Bar lists the available Plivo Products for your account. It helps you switch between Plivo Products.

Components

Components are the building blocks used to create a PHLO. Based on the workflow, you can piece together different components to create a PHLO.

States

States are properties that the component is set to or based on for each action. Each component has one input state and at least one output state.

Node

Node is an instance of a component when placed on the canvas. Drag and drop components to the canvas to create their nodes. Each node must have a unique name within the PHLO.

Configurations tab

Every node has a set of default configurations associated with it. Click the node to view the configurations for the node. To view the list of configuration options available for the node, click the Information tab.

Make sure you validate the node after the configuration. The side panel will display validation errors, if any. Make sure you correct all validation errors before saving the PHLO.

Information tab

The information tab gives you more information about the node. You can also view all the default variables available for each node, along with node specific options and states.

Triggers

Triggers provide you the ability to manage an ongoing call. There are four types of triggers:

  • Call
  • Hold
  • Transfer
  • Hangup

For more information, see the Components Library.

Creating PHLOs

Creating a PHLO is a very simple process. You can create a PHLO by either using a blank canvas, or by using one of our packaged templates.

Building the PHLO structure using a Blank Canvas

To build a PHLO structure using a blank canvas

  1. On the top navigation bar, click PHLO. The PHLO page will appear and display any of your existing PHLOs. If this is your first PHLO, then the PHLO page will be empty.
  2. Click CREATE NEW PHLO to build a new PHLO. The Choose your use-case screen appears.
  3. On the Choose your use-case window, click Build my own. The PHLO canvas will appear with the Start node. Note: The Start node is the starting point of any PHLO. You can choose between the three available trigger states of the Start node; Incoming SMS, Incoming Call, API Req uest.
  4. From the Components list, drag and drop the components you wish to add to your PHLO based on your use case. A node will be created for the component, on the canvas, and the Configurations tab will appear.
  5. Connect the nodes in a logical sequence. For more information, see Configuring PHLO Components.
  6. Click the node to configure it. For more information, see Configuring PHLO Components.
  7. Click Validate to save the configurations for the node.
  8. Enter a unique name for the PHLO, and then click Save. Your PHLO will be saved. Add the PHLO to a Phone Number, if it is based on an incoming call or SMS, or link it to your application using the PHLO URL to trigger the PHLO.

Building the PHLO structure using a template

To build a PHLO structure using a template

  1. On the top navigation bar, click PHLO. The PHLO page will appear and display any of your existing PHLOs. If this is your first PHLO, then the PHLO page will be empty.
  2. Click CREATE NEW PHLO to build a new PHLO. The Choose your use-case screen will appear.
  3. On the Choose your use-case screen, select one of the available templates. The PHLO Canvas appears with the Start node, and all other required nodes. Components that are a part of the template will be connected appropriately by default.
  4. If you need to add more components to the PHLO, from the Components list, drag and drop the components based on your use case.
  5. Create the necessary connections between the nodes. For more information, see Configuring PHLO Components.
  6. Configure the individual nodes based on your use case. For more information, see Configuring PHLO Components.
  7. Enter a unique name for the PHLO, and then click Save. Your PHLO will be saved and available for you to assign to a Phone Number.

Connecting PHLO Components

Once you have all the required components added to the PHLO Canvas, you must create a connection between the nodes to complete the workflow. Defining a command to a response is as simple as connecting the output state of one node to the input state of another node. The output state is the command and the input state is the response. This will also define the workflow transition for each command, in the PHLO. Each node has a predefined set of output states. To connect PHLO components, on the PHLO Canvas, click and drag the output state of a node to the input state of another node. Below is an example of an IVR menu that shows the connection between the input and output states.

In the above example, the IVR Menu_1 node has the following output states:

  • No Input
  • Wrong Input
  • 1
  • 2

Similarly, the Play Audio_1 node has Prompt completed as the output state and Hangup_1 has Hangup Complete as the output state. The No Input state of the IVR Menu_1 node is connected to the Play Audio_1 using the input state at the top of the node. Every node has a input state, except the Start node. Once you have connected all the nodes on your PHLO canvas, make sure to configure the components. For more information, see Configuring PHLO Components.

Configuring PHLO Components

Every component must be configured to make sure the workflow works as intended. You can access the Configurations tab for the components by clicking on their nodes on the canvas. You can also access the Information tab to know more about the default configurations and variables available for each node. In a PHLO, there are two types of variables that you can use.

  1. Global Variables
  2. Variables specific to Components

Global Variables Global variables can be configured in the Start node of the PHLO. To use Global Variables, make sure you define the key and value pairs in the Start node. Connect the Start node to the component in which you wish to use the global variables. Once the nodes are connected, use two curly brackets to view all available variables. Scroll through the list of variables, and then select the variable that is applicable for your use.

Note: Make sure you define specific values for your variables.

Variables specific to Components Each component has a list of predefined variables. You may choose to use any of the predefined variables. For more information on the components and their default variables and configurations, see PHLO Components Library.

Once you have configured the node, click Validate to make sure there are no errors in the configuration. In case of any validation errors, a message will be displayed with an error message.

If the PHLO becomes very big and covers the visible canvas completely, you can scroll the canvas in all directions to help declutter the PHLO. Use the trackpad on your laptops to navigate around the canvas.

Triggering a PHLO

A PHLO can be triggered using an outgoing API Call or with an incoming Call or SMS. To trigger a PHLO for an Incoming Call or SMS, you must add the PHLO to a Plivo Number.

Triggering a PHLO using a Phone Number

Once you have created and configured your PHLO, assign your PHLO to a number. To assign a PHLO to a number

  1. On the Product Navigation bar, click PHONE NUMBER.
  2. On the Numbers page, under YOUR NUMBERS, click the phone number you wish to use for the PHLO.
  3. In the EDIT NUMBERS window, select PHLO from the APP TYPE list.
  4. From the PHLO list, select the PHLO you wish to use with the phone number, and then click UPDATE.

You can now call or send an SMS, depending on the type of PHLO, to your phone number to test your PHLO.

If you have not purchased a phone number yet, you must buy a number to use with your PHLO.

To buy a phone number

  1. On the Numbers page, click Buy New Number.
  2. On the Search & Buy Phone Numbers page, search for available Phone Numbers based on your location, and then click Buy Number against the phone number that you wish to purchase.

Once you have completed the purchase, follow the instructions in the section above to assign the PHLO to your Phone Number.

Triggering a PHLO using an API Request

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.

Code Samples

1
2
curl -i --user AUTH_ID:AUTH_TOKEN \
  https://phlorunner.plivo.com/v1/account/{auth_id}/phlo/{phlo_id}
1
2
3
4
5
6
7
8
9
import plivo

auth_id = 'Your AUTH ID'
auth_token = 'Your AUTH Token'
phlo_id = 'Your PHLO ID' # https://console.plivo.com/phlo/list/
phlo_client = plivo.phlo.RestClient(auth_id=auth_id, auth_token=auth_token)
phlo = phlo_client.phlo.get(phlo_id)
response = phlo.run()
print str(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import com.plivo.api.Plivo;
import com.plivo.api.PlivoClient;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.phlo.Phlo;
import java.io.IOException;

public class Example
{
    private static final String authId = "Your AUTH ID";
    private static final String authToken = "Your AUTH Token";
    private static PlivoClient client = new PlivoClient(authId, authToken);
    public static void main(String[] args) throws IOException, PlivoRestException
    {
        String phloId = "Your PHLO ID";
        Plivo.init(authId, authToken);
        Phlo phlo = Phlo.getter(phloId).client(client).get();
        Map<String, Object> payload = new HashMap<>();
        payload.put("phone", "+1111111111");
        payload.put("to", "+1111111112");
        PhloUpdateResponse response = Phlo.updater(phloId).payload(payload).run();
    }
}
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main

import (
	"fmt"
	"plivo-go"
)

// Initialize the following params with corresponding values to trigger resources

const authId  = "auth_id"
const authToken = "auth_token"
const phloId = "phlo_id"

// with payload in request

func main() {
	testPhloRunWithParams()
}

func testPhloRunWithParams() {
	phloClient,err := plivo.NewPhloClient(authId, authToken, &plivo.ClientOptions{})
	if err != nil {
		panic(err)
	}
	phloGet, err := phloClient.Phlos.Get(phloId)
	if err != nil {
		panic(err)
	}
	//pass corresponding from and to values
	type params map[string]interface{}
	response, err := phloGet.Run(params{
		"from": "111111111",
		"to": "2222222222",
	})

	if (err != nil) {
		println(err)
	}
	fmt.Printf("Response: %#v\n", response)
}

// without payload in request

func main() {
	testPhloRunWithoutParams()
}

func testPhloRunWithoutParams() {
	phloClient,err := plivo.NewPhloClient(authId, authToken, &plivo.ClientOptions{})
	if err != nil {
		panic(err)
	}
	phloGet, err := phloClient.Phlos.Get(phloId)
	if err != nil {
		panic(err)
	}
	response, err := phloGet.Run(nil)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Response: %#v\n", response)

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
/**
 * Example for API Request
 */
require 'vendor/autoload.php';
use Plivo\Resources\PHLO\PhloRestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new PhloRestClient("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
$phlo = $client->phlo->get("YOUR_PHLO_ID");
try {
    $response = $phlo->run(["field1" => "value1", "field2" => "value2"]); // These are the fields entered in the PHLO console
    print_r($response);
} catch (PlivoRestException $ex) {
    print_r($ex);
}
?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var plivo = require('../dist/rest/client.js');
var PhloClient = plivo.PhloClient;

var authId = 'auth-id';
var authToken = 'auth-token';
var phloId = 'PHLO_ID';
var phloClient = phlo = null;

// Run phlo
phloClient = new PhloClient(authId, authToken);
phloClient.phlo(phloId).run().then(function (result) {
    console.log('Phlo run result', result);
}).catch(function (err) {
    console.error('Phlo run failed', err);
});

You can install the server-side SDKs and setup your development environment by referring to the instructions available in the below links:

Server-side SDKs
Setup your development environment

You can get your Auth_ID and Auth_token from your dashboard

You can find the PHLO_ID on the PHLO Listing page.