Connect a Call to a Second Person
Overview
You may want to have an application dial out for someone, so that it calls them on their phone, then connects them to the number they want. This involves three tasks:
- Make an outbound call to a caller.
- When the call recipient answers the phone, place a new call to a different number (second user).
- Bridge the calls (first and second user) after the second user answers.
Common use cases for this practice include click to call, where a server application directs a call to a person who clicks on a web link, then connects them with a company representative.
This guide shows how to code connecting a user to second person on the Plivo platform, either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a Node.js development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a file called TriggerPhlo.js
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a Node.js development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a file called TriggerPhlo.js
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
Here‘s how to connect a call to a second person using XML.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. You must have a voice-enabled Plivo phone number to receive incoming calls; you can rent numbers from the Numbers page of the Plivo console, or by using the Numbers API. If this is your first time using Plivo APIs, follow our instructions to set up a Node.js development environment and a web server and safely expose that server to the internet.
Create an Express server to connect calls to a second person
Create a file called connect_call.js
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phone number placeholders with actual phone numbers (for example, 12025551234).
Save the file and run it.
You should see your basic server application in action at http://localhost:3000/outbound_call/.
Set up ngrok to expose your local server to the internet.
Note:
We recommend that you store your credentials in the auth_id
and auth_token
environment variables, to avoid the possibility of accidentally committing them to source control. If you do this, you can initialize the client with no arguments and Plivo will automatically fetch them from the environment variables. You can use process.env
to store environment variables and fetch them when initializing the client.
Test
Have your application make a call to a regular mobile phone. Plivo will send a request to your answer URL requesting a valid XML response and connect the call to a second user.
Overview
You may want to have an application dial out for someone, so that it calls them on their phone, then connects them to the number they want. This involves three tasks:
- Make an outbound call to a caller.
- When the call recipient answers the phone, place a new call to a different number (second user).
- Bridge the calls (first and second user) after the second user answers.
Common use cases for this practice include click to call, where a server application directs a call to a person who clicks on a web link, then connects them with a company representative.
This guide shows how to code connecting a user to second person on the Plivo platform, either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a Node.js development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a file called TriggerPhlo.js
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a Node.js development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a file called TriggerPhlo.js
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
Here‘s how to connect a call to a second person using XML.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. You must have a voice-enabled Plivo phone number to receive incoming calls; you can rent numbers from the Numbers page of the Plivo console, or by using the Numbers API. If this is your first time using Plivo APIs, follow our instructions to set up a Node.js development environment and a web server and safely expose that server to the internet.
Create an Express server to connect calls to a second person
Create a file called connect_call.js
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phone number placeholders with actual phone numbers (for example, 12025551234).
Save the file and run it.
You should see your basic server application in action at http://localhost:3000/outbound_call/.
Set up ngrok to expose your local server to the internet.
Note:
We recommend that you store your credentials in the auth_id
and auth_token
environment variables, to avoid the possibility of accidentally committing them to source control. If you do this, you can initialize the client with no arguments and Plivo will automatically fetch them from the environment variables. You can use process.env
to store environment variables and fetch them when initializing the client.
Test
Have your application make a call to a regular mobile phone. Plivo will send a request to your answer URL requesting a valid XML response and connect the call to a second user.
Overview
You may want to have an application dial out for someone, so that it calls them on their phone, then connects them to the number they want. This involves three tasks:
- Make an outbound call to a caller.
- When the call recipient answers the phone, place a new call to a different number (second user).
- Bridge the calls (first and second user) after the second user answers.
Common use cases for this practice include click to call, where a server application directs a call to a person who clicks on a web link, then connects them with a company representative.
This guide shows how to code connecting a user to second person on the Plivo platform, either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a Ruby development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a file called trigger_phlo.rb
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a Ruby development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a file called trigger_phlo.rb
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
Here‘s how to connect a call to a second person using XML.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. You must have a voice-enabled Plivo phone number to receive incoming calls; you can rent numbers from the Numbers page of the Plivo console, or by using the Numbers API. If this is your first time using Plivo APIs, follow our instructions to set up a Ruby development environment and a web server and safely expose that server to the internet.
Create a Rails controller to connect calls to a second person
Change to the project directory and run this command to create a Rails controller for inbound calls.
This command generates a controller named plivo_controller in the app/controllers/ directory and a respective view in the app/views/plivo directory. We can delete the view, as we don’t need it.
Edit app/controllers/plivo_controller.rb and add this code in the PlivoController class.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phone number placeholders with actual phone numbers (for example, 12025551234).
Note: We recommend that you store your credentials in the auth_id
and auth_token
environment variables, to avoid the possibility of accidentally committing them to source control. If you do this, you can initialize the client with no arguments and Plivo will automatically fetch them from the environment variables. You can use ENV
to store environment variables and fetch them when initializing the client.
Add a route
Add a route for the inbound function in the PlivoController class. Edit the config/routes.rb file and add these lines.
Start the Rails server.
You should see your basic server application in action at http://localhost:3000/plivo/outbound_call/.
Set up ngrok to expose your local server to the internet.
Test
Have your application make a call to a regular mobile phone. Plivo will send a request to your answer URL requesting a valid XML response and connect the call to a second user.
Overview
You may want to have an application dial out for someone, so that it calls them on their phone, then connects them to the number they want. This involves three tasks:
- Make an outbound call to a caller.
- When the call recipient answers the phone, place a new call to a different number (second user).
- Bridge the calls (first and second user) after the second user answers.
Common use cases for this practice include click to call, where a server application directs a call to a person who clicks on a web link, then connects them with a company representative.
This guide shows how to code connecting a user to second person on the Plivo platform, either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a Python development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a file called trigger_phlo.py
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a Python development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a file called trigger_phlo.py
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
Here‘s how to connect a call to a second person using XML.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. You must have a voice-enabled Plivo phone number to receive incoming calls; you can rent numbers from the Numbers page of the Plivo console, or by using the Numbers API. If this is your first time using Plivo APIs, follow our instructions to set up a Python development environment and a web server and safely expose that server to the internet.
Create a Flask application to connect calls to a second person
Create a file called connect_call.py
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phone number placeholders with actual phone numbers (for example, 12025551234).
Save the file and run it.
You should see your basic server application in action at http://localhost:5000/outbound_call/.
Set up ngrok to expose your local server to the internet.
Note: We recommend that you store your credentials in the auth_id
and auth_token
environment variables, to avoid the possibility of accidentally committing them to source control. If you do this, you can initialize the client with no arguments and Plivo will automatically fetch them from the environment variables. You can use the os module (os.environ
) to store environment variables and fetch them when initializing the client.
Test
Have your application make a call to a regular mobile phone. Plivo will send a request to your answer URL requesting a valid XML response and connect the call to a second user.
Overview
You may want to have an application dial out for someone, so that it calls them on their phone, then connects them to the number they want. This involves three tasks:
- Make an outbound call to a caller.
- When the call recipient answers the phone, place a new call to a different number (second user).
- Bridge the calls (first and second user) after the second user answers.
Common use cases for this practice include click to call, where a server application directs a call to a person who clicks on a web link, then connects them with a company representative.
This guide shows how to code connecting a user to second person on the Plivo platform, either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a PHP development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a file called TriggerPhlo.php
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a PHP development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a file called TriggerPhlo.php
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
Here‘s how to connect a call to a second person using XML.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. You must have a voice-enabled Plivo phone number to receive incoming calls; you can rent numbers from the Numbers page of the Plivo console, or by using the Numbers API. If this is your first time using Plivo APIs, follow our instructions to set up a PHP development environment and a web server and safely expose that server to the internet.
Create a Laravel controller to connect calls to a second person
Change to the project directory and run this command to create a Laravel controller for inbound calls.
This generates a controller named VoiceController in the app/http/controllers/ directory. Now, Edit app/http/controllers/voiceController.php and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phone number placeholders with actual phone numbers (for example, 12025551234).
Note: We recommend that you store your credentials in the auth_id
and auth_token
environment variables, to avoid the possibility of accidentally committing them to source control. If you do this, you can initialize the client with no arguments and Plivo will automatically fetch them from the environment variables. You can use $_ENV
or putenv/getenv
functions to store environment variables and fetch them when initializing the client.
Add a route
Add a route for the forward function in VoiceController. Edit the routes/web.php file and add these lines.
Start the Laravel server.
You should see your basic server application in action at http://localhost:8000/outboundCall/.
Set up ngrok to expose your local server to the internet.
Test
Have your application make a call to a regular mobile phone. Plivo will send a request to your answer URL requesting a valid XML response and connect the call to a second user.
Overview
You may want to have an application dial out for someone, so that it calls them on their phone, then connects them to the number they want. This involves three tasks:
- Make an outbound call to a caller.
- When the call recipient answers the phone, place a new call to a different number (second user).
- Bridge the calls (first and second user) after the second user answers.
Common use cases for this practice include click to call, where a server application directs a call to a person who clicks on a web link, then connects them with a company representative.
This guide shows how to code connecting a user to second person on the Plivo platform, either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a PHP development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Open the file in the CS project called Program.cs and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a PHP development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Open the file in the CS project called Program.cs and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
Here‘s how to connect a call to a second person using XML.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. You must have a voice-enabled Plivo phone number to receive incoming calls; you can rent numbers from the Numbers page of the Plivo console, or by using the Numbers API. If this is your first time using Plivo APIs, follow our instructions to set up a .NET development environment and a web server and safely expose that server to the internet.
Create an MVC controller to connect calls to a second person
In Visual Studio, create a controller called Connect.cs
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phone number placeholders with actual phone numbers (for example, 12025551234).
Before starting the application, edit Properties/launchSettings.json and set the applicationUrl as
Run the project and you should see your basic server application in action at http://localhost:5000/Connect/.
Set up ngrok to expose your local server to the internet.
Note: We recommend that you store your credentials in the auth_id
and auth_token
environment variables, to avoid the possibility of accidentally committing them to source control. If you do this, you can initialize the client with no arguments and Plivo will automatically fetch them from the environment variables. You can use the Environment.SetEnvironmentVariable
method to store environment variables and Environment.GetEnvironmentVariable
to fetch them when when initializing the client.
Test
Have your application make a call to a regular mobile phone. Plivo will send a request to your answer URL requesting a valid XML response and connect the call to a second user.
Overview
You may want to have an application dial out for someone, so that it calls them on their phone, then connects them to the number they want. This involves three tasks:
- Make an outbound call to a caller.
- When the call recipient answers the phone, place a new call to a different number (second user).
- Bridge the calls (first and second user) after the second user answers.
Common use cases for this practice include click to call, where a server application directs a call to a person who clicks on a web link, then connects them with a company representative.
This guide shows how to code connecting a user to second person on the Plivo platform, either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a PHP development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a Java class called TriggerPhlo
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a PHP development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Create a Java class called TriggerPhlo
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
Here‘s how to connect a call to a second person using XML.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. You must have a voice-enabled Plivo phone number to receive incoming calls; you can rent numbers from the Numbers page of the Plivo console, or by using the Numbers API. If this is your first time using Plivo APIs, follow our instructions to set up a Java development environment and a web server and safely expose that server to the internet.
Create a Spring server to connect calls to a second person
Edit the PlivoVoiceApplication.java file in the src/main/java/com.example.demo/ folder and paste into it this code.
Note: Here, the demo application name is PlivoVoiceApplication.java because we provided the friendly name Plivo Voice
in the Spring Initializr.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phone number placeholders with actual phone numbers (for example, 12025551234).
Save the file and run it.
You should see your basic server application in action at http://localhost:8080/outbound_call/.
Set up ngrok to expose your local server to the internet.
Note: We recommend that you store your credentials in the auth_id
and auth_token
environment variables, to avoid the possibility of accidentally committing them to source control. If you do this, you can initialize the client with no arguments and Plivo will automatically fetch the values from the environment variables. You can use <a rel="nofollow" href="https://docs.oracle.com/javase/tutorial/essential/environment/env.html">System.getenv()</a>
to store environment variables and retrieve them when initializing the client.
Test
Have your application make a call to a regular mobile phone. Plivo will send a request to your answer URL requesting a valid XML response and connect the call to a second user.
Overview
You may want to have an application dial out for someone, so that it calls them on their phone, then connects them to the number they want. This involves three tasks:
- Make an outbound call to a caller.
- When the call recipient answers the phone, place a new call to a different number (second user).
- Bridge the calls (first and second user) after the second user answers.
Common use cases for this practice include click to call, where a server application directs a call to a person who clicks on a web link, then connects them with a company representative.
This guide shows how to code connecting a user to second person on the Plivo platform, either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a PHP development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
You can create and deploy a PHLO to have an application call someone then connect them to a third party, and you can trigger the PHLO with a few lines of code.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a PHP development environment and a web server and safely expose that server to the internet.
Create the PHLO
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
-
Click Create New PHLO.
-
In the Choose your use case pop-up, click Build my own. The PHLO canvas will appear with the Start node.
Note: The Start node is the starting point of any PHLO. It lets you trigger a PHLO to start upon one of three actions: incoming SMS message, incoming call, or API request.
-
Click the Start node to open the Configuration tab, and then enter the information to retrieve from the HTTP Request payload — in this case key names for the From and To numbers and the second user‘s number.
-
Validate the configuration by clicking Validate. Do the same for each node as you go along.
-
From the list of components on the left side, drag and drop the Initiate Call component onto the canvas. This adds an Initiate Call node onto the canvas. When a component is placed on the canvas it becomes a node.
-
Draw a line to connect the Start node’s API Request trigger state to the Initiate Call node.
-
In the Configuration tab of the Initiate Call node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
From the list of components on the left side, drag and drop the Play Audio component onto the canvas. Draw a line to connect the Answered trigger state of the Initiate Call node with the Play Audio node.
- Configure the Play Audio node to play a message to the user by entering text in the Speak Text box in the Prompt section of the Configuration pane. Enter a static message — for example, “Please wait while we connect your call to the second number.”
-
From the list of components on the left side, drag and drop the Call Forward component onto the canvas.
-
Draw a line to connect the Prompt Completed trigger state of the Play Audio with the Call Forward node.
-
In the Configuration tab of the Call Forward node, give the node a name. To enter values for the From and To fields, enter two curly brackets to view all available variables, and choose the appropriate ones. The values for the numbers will be retrieved from the HTTP Request payload you defined in the Start node.
-
After you complete and validate the node configurations, give the PHLO a name by clicking in the upper left, then click Save.
Your complete PHLO should look like this:
Your PHLO is now ready to test.
Trigger the PHLO
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or, as we do here, define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
With dynamic payload
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code to the PHLO when you trigger it.
Code
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Test
Save the file and run it.
Here‘s how to connect a call to a second person using XML.
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. You must have a voice-enabled Plivo phone number to receive incoming calls; you can rent numbers from the Numbers page of the Plivo console, or by using the Numbers API. If this is your first time using Plivo APIs, follow our instructions to set up a Go development environment and a web server and safely expose that server to the internet.
Create a Go server to connect calls to a second person
Create a file called connect_call.go
and paste into it this code.
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phone number placeholders with actual phone numbers (for example, 12025551234).
Save the file and run it.
You should see your basic server application in action at http://localhost:8080/outbound-call/.
Set up ngrok to expose your local server to the internet.
Note: We recommend that you store your credentials in the auth_id
and auth_token
environment variables, to avoid the possibility of accidentally committing them to source control. If you do this, you can initialize the client with no arguments and Plivo will automatically fetch them from the environment variables. You can use the os.Setenv
and os.Getenv
functions to store environment variables and fetch them when initializing the client.
Test
Have your application make a call to a regular mobile phone. Plivo will send a request to your answer URL requesting a valid XML response and connect the call to a second user.