Voice Survey

We use voice surveys for collecting information from customers like satisfaction scores of a service provided. Plivo’s PHLO allows you to create and configure a voice survey system for your business. An API call triggers the PHLO to call the customer with survey questions.

You can set up PHLO with multi-level survey questions based on the key pressed. You can also configure and receive the responses on your app for consolidation.

Creating the Use Case using PHLO

With PHLO, you can quickly create a workflow that suits your use case. To use PHLO, make sure to register and log on to Plivo Console.

Use the following components to create this PHLO:

  • Initiate Call
  • IVR Menu
  • Play Audio
  • HTTP Request

When you send an API request to the PHLO, it triggers a call to the user using the Initiate Call component. Once the user answers the call, the Play Audio component plays an audio to the user. The call will disconnect automatically after the playback audio is completed.

Note: The Callback function provides the user details required to make the call.

To create this PHLO

  1. On the top navigation bar, click PHLO.The PHLO page will appear and display your existing PHLOs, if any exist. If this is your first PHLO, then the PHLO page will be empty.
  2. Click CREATE NEW PHLO to build a new PHLO.
  3. From the CREATE A NEW PHLO window, select Build on a blank canvas, and then click CREATE PHLO. 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 four available trigger states of the Start node; Incoming SMS, Incoming Call, and API Request. For this PHLO, we will use the API Request trigger state.
  4. Click the Start node to open the Configurations tab, and then enter the information to retrieve from the HTTP Request payload. For example, this could be a list of numbers to call.
  5. Click Validate to save the configurations for the node.
  6. From the list of components on the left-hand side, drag and drop the Initiate Call component onto the canvas. This will add a Initiate call node onto the canvas.
  7. Connect the Start node with the Initiate Call node, using the API Request trigger state.
  8. Configure the Initiate Call node to select the From and To numbers from the Start node.Note:
    • Enter two curly brackets to view all available variables.
    • The values for the From and To numbers are picked from the HTTP Request Payload. Make sure to clearly define the variables in the Start node.
  9. Rename the Initiate Call node to Call_Customer. Note: You can rename the nodes as per your requirements. We are using specific names in this example to help you relate to the different nodes used in this use case.
  10. Click Validate to save the configurations for the node.
  11. Similarly, create a node for the IVR Menu component and connect it to the Initiate Call node using the Answered trigger state.
  12. Click the IVR Menu node to open the Configurations tab.
  13. Configure the choices for the IVR Menu from the Configurations tab. In this example, we will select 1 and 2 as the allowed choices and enter a message to play to the user.
  14. Rename the IVR Menu node to Question_1, and then click Validate to save the configurations for the node.
  15. Similarly, create another IVR Menu node and rename it to Question_2.
  16. Connect Question_2 node to the Question_1 node using the 1 and 2 trigger states.
  17. Configure the choices for Question_2 from the Configurations tab. In this example, we will select 1 and 2 as the allowed choices, and enter a message to play to the user.
  18. Enter a message in the Speak Text field. The caller will be greeted with this message. Note: You can also configure the Language and Voice for the message.
  19. Click Validate to save the configurations of the node.
  20. Create a node for the Play Audio component.
  21. Rename the node to Acknowledge_Participation using the Configurations tab.
  22. Connect Acknowledge_Participation node to the Question_2 node using the 1 and 2 trigger states.
  23. Configure the Acknowledge_Participation node to speak a message to the customer.
  24. Click Validate to save the configurations for the node.
  25. Next, create a node for HTTP Request component and rename it to Handle_Callback.
  26. Connect the Handle_Callback node to the Acknowledge_Participation node using the Prompt Completed trigger state.
  27. Configure the **HTTP Request_1 **node to post the survey results to a website.
  28. In the Params tab, add answer1 and answer2 as Key.
  29. For answer1, enter two curly braces and select Question_1.digits.
  30. For answer2, enter two curly braces and select Question_2.digits.
  31. Click Validate to save the configurations of the node.
  32. After you complete the configurations, click Save.You can trigger your PHLO using the PHLO URL to test it out.

Triggering the PHLO from your app

Once you have created and configured your PHLO, copy the PHLO Run URL. Integrate a PHLO into your application workflow by making an API request to the PHLO URL with the required payload.

Code Samples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# without payload in request

import plivo

auth_id = '<auth_id>'
auth_token = '<auth_token>'
phlo_id = '<phlo_id>'
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)

# with payload in request

import plivo

auth_id = '<auth_id>'
auth_token = '<auth_token>'
phlo_id = '<phlo_id>'
payload = {"from" : "+12025550000","to" : "+12025551111"}
phlo_client = plivo.phlo.RestClient(auth_id=auth_id, auth_token=auth_token)
phlo = phlo_client.phlo.get(phlo_id)
response = phlo.run(**payload)
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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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

# without payload in request
begin
    phlo = client.phlo.get('phlo_id')
    response = phlo.run()
    puts response
  rescue PlivoRESTError => e
    puts 'Exception: ' + e.message
  end

# with payload in request

begin
  phlo = client.phlo.get('phlo_id')
  #parameters set in PHLO - params
  params = {
     from: '9999999999',
     to: '0000000000'
  }
  response = phlo.run(params)
  puts response
rescue PlivoRESTError => e
  puts 'Exception: ' + e.message
end
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
var plivo = require('plivo');
var PhloClient = plivo.PhloClient;

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

// without payload in request

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);
});

// with payload in request

var payload = {
    from: '19999999999',
    to: '18888888888'
}
phloClient = new PhloClient(authId, authToken);
phloClient.phlo(phloId).run(payload).then(function (result) {
    console.log('Phlo run result', result);
}).catch(function (err) {
    console.error('Phlo run failed', err);
});
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
<?php
/**
 * Example for API request
 */
require 'vendor/autoload.php';
use Plivo\Resources\PHLO\PhloRestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new PhloRestClient("<auth_id>", "<auth_token>");

// without payload in request

$phlo = $client->phlo->get("<phlo_id>");
try {
    $response = $phlo->run();
    print_r($response);
} catch (PlivoRestException $ex) {
    print_r($ex);
}

// with payload in request

$phlo = $client->phlo->get("<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
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
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;

// without payload 

public class Example
{
    private static final String authId = "<auth_id>";
    private static final String authToken = "<auth_token>";
    private static PlivoClient client = new PlivoClient(authId, authToken);
    public static void main(String[] args) throws IOException, PlivoRestException
    {
        String phloId = "<phlo_id>";
        Plivo.init(authId, authToken);
        Phlo phlo = Phlo.getter(phloId).client(client).get();
        PhloUpdateResponse response = Phlo.updater(phloId).payload().run();
    }
}

// with payload 

public class Example
{
    private static final String authId = "<auth_id>";
    private static final String authToken = "<auth_token>";
    private static PlivoClient client = new PlivoClient(authId, authToken);
    public static void main(String[] args) throws IOException, PlivoRestException
    {
        String phloId = "<phlo_id>";
        Plivo.init(authId, authToken);
        Phlo phlo = Phlo.getter(phloId).client(client).get();
        Map<String, Object> payload = new HashMap<>();
        payload.put("phone", "+12025550000");
        payload.put("to", "+12025551111");
        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
64
65
66
67
68
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"

// without payload in request

func main() {
	testPhloRunWithoutParams()
}

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

}

// with payload in request

func main() {
	testPhloRunWithParams()
}

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

	if err != nil {
		println(err)
	}
	fmt.Printf("Response: %#v\n", response)
}
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
using System;
using Plivo;

// without payload 

namespace test_PHLO_dotnet
{
    class Program
    {
        public static void Main(string[] args)
        {
            var phloClient = new PhloApi("<auth_id>", "<auth_token>");
            var phloID = "phlo_id";
            var phlo = phloClient.Phlo.Get(phloID);   
            Console.WriteLine(phlo.Run());
        }
    }
}

// with payload 

namespace test_PHLO_dotnet
{
    class Program
    {
        public static void Main(string[] args)
        {
            var phloClient = new PhloApi("<auth_id>", "<auth_token>");
            var phloID = "phlo_id";
            var phlo = phloClient.Phlo.Get(phloID); 
            var data = new Dictionary<string, object>
            {
                { "from", "19999999999" },
                { "to", "18888888888" }

            };  
            Console.WriteLine(phlo.Run(data));
        }
    }
}
1
2
3
4
5
curl --request POST \
  --user AUTH_ID:AUTH_TOKEN \
  --url 'https://phlorunner.plivo.com/v1/account/{auth_id}/phlo/{phlo_id}' \
  --header 'Content-Type: application/json' \
  --data '{"from": "12025550000","to": "12025551111"}'

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

  1. On the top navigation bar, click PHLO. The PHLO page will appear and display your existing PHLOs, if any exist. If this is your first PHLO, then the PHLO page will be empty.
  2. Click CREATE NEW PHLO to build a new PHLO.
  3. From the CREATE A NEW PHLO window, select Build on a blank canvas, and then click CREATE PHLO. The PHLO canvas will appear with the Start node.
  4. Note:

    The Start node is the starting point of any PHLO. You can choose between the four available trigger states of the Start node; Incoming SMS, Incoming Call, and API Request. For this PHLO, we will use the API Request trigger state.

  5. Click the Start node to open the Configurations tab, and then enter the information to retrieve from the HTTP Request payload. For example, this could be a list of numbers to call.
  6. Click Validate to save the configurations for the node.
  7. From the list of components on the left-hand side, drag and drop the Initiate Call component onto the canvas. This will add a Initiate call node onto the canvas.
  8. Connect the Start node with the Initiate Call node, using the API Request trigger state.
  9. Configure the Initiate Call node to select the From and To numbers from the Start node.
  10. Note:
    • Enter two curly brackets to view all available variables.
    • The values for the From and To numbers are picked from the HTTP Request Payload. Make sure to clearly define the variables in the Start node.
  11. Rename the Initiate Call node to Call_Customer.
  12. Note:

    You can rename the nodes as per your requirements. We are using specific names in this example to help you relate to the different nodes used in this use case.

  13. Click Validate to save the configurations for the node.
  14. Similarly, create a node for the IVR Menu component and connect it to the Initiate Call node using the Answered trigger state.
  15. Click the IVR Menu node to open the Configurations tab.
  16. Configure the choices for the IVR Menu from the Configurations tab. In this example, we will select 1 and 2 as the allowed choices and enter a message to play to the user.
  17. Rename the IVR Menu node to Question_1, and then click Validate to save the configurations for the node.
  18. Similarly, create another IVR Menu node and rename it to Question_2.
  19. Connect Question_2 node to the Question_1 node using the 1 and 2 trigger states.
  20. Configure the choices for Question_2 from the Configurations tab. In this example, we will select 1 and 2 as the allowed choices, and enter a message to play to the user.
  21. Enter a message in the Speak Text field. The caller will be greeted with this message.
  22. Note:

    You can also configure the Language and Voice for the message.

  23. Click Validate to save the configurations of the node.
  24. Create a node for the Play Audio component.
  25. Rename the node to Acknowledge_Participation using the Configurations tab.
  26. Connect Acknowledge_Participation node to the Question_2 node using the 1 and 2 trigger states. This will acknowledge the customer’s participation in the survey.
  27. Next, create a node for HTTP Request component and rename it to Handle_Callback.
  28. Connect the Handle_Callback node to the Acknowledge_Participation node using the Prompt Completed trigger state.
  29. Configure the HTTP Request_1 node to post the survey results to a website.
  30. In the Params tab, add answer1 and answer2 as Key.
  31. For answer1, enter two curly braces and select Question_1.digits.
  32. For answer2, enter two curly braces and select Question_2.digits.
  33. Click Validate to save the configurations of the node.
  34. After you complete the configurations, click Save. You can trigger your PHLO using the PHLO URL to test it out.

For more information on using PHLO, see the PHLO User Guide.

Server SDKs
Setup your development environment

You can get your Auth_ID and Auth_token from your dashboard

AuthID

You can find the PHLO_ID on the PHLO Listing page.

PHLO Listing