- Node
- Ruby
- Python
- PHP
- .NET
- Java
- Go
Overview
This guide shows how to receiving incoming calls on a Plivo number and greet callers with a text-to-speech message. Managing incoming calls is a key part of the call flow in many common use cases, such as interactive voice response (IVR), call forwarding, and conference calling.You can handle incoming calls either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.- Using XML
Here’s how to use a Plivo XML document that handles incoming calls on a Plivo number by playing a text-to-speech message to the caller.
Plivo requests an answer URL when it answers the call (step 2) and expects the file at that address to hold a valid XML response from the application with instructions on how to handle the call. In this example, when an incoming call is received, Plivo’s text-to-speech engine plays a message using the Speak XML element.
Give the project a name — we used 
Navigate to the Controllers directory in the Receivecall project. Create a controller named ReceivecallController.cs and paste into it this code.

How it works

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 MVC controller to handle incoming calls
In Visual Studio, create a new project. Use the template for Web Application (Model-View-Controller).
Receivecall.
Copy
Ask AI
using System;
using Plivo.XML;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
namespace Receivecall
{
public class ReceivecallController : Controller
{
public IActionResult Index()
{
Plivo.XML.Response resp = new Plivo.XML.Response();
resp.AddSpeak("Hello, you just received your first call",
new Dictionary<string, string>() {
{
"loop",
"3"
}
});
var output = resp.ToString();
Console.WriteLine(output);
return this.Content(output, "text/xml");
}
}
}
Create a Plivo application to receive calls
Associate the controller you created with Plivo by creating a Plivo application. Visit Voice > Applications in the Plivo console and click on Add New Application, or use Plivo’s Application API.Give your application a name — we called oursReceive_call. Enter the server URL you want to use (for example https://<yourdomain>.com/receive_call/) in the Answer URL field and set the method to POST. Click Create Application to save your application.
Assign a Plivo number to your application
Navigate to the Numbers page and select the phone number you want to use for this application.From the Application Type drop-down, selectXML Application.From the Plivo Application drop-down, select Receive_call (the name we gave the application).Click Update Number to save.
Test
Make a call to your Plivo number using any phone. Plivo will send a request to the answer URL you provided requesting an XML response and then process the call according to the instructions in the XML document the server provides. You should hear the text-to-speech message, “Hello, you just received your first call.”Overview
This guide shows how to receiving incoming calls on a Plivo number and greet callers with a text-to-speech message. Managing incoming calls is a key part of the call flow in many common use cases, such as interactive voice response (IVR), call forwarding, and conference calling.You can handle incoming calls either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.- Using XML
Here’s how to use a Plivo XML document that handles incoming calls on a Plivo number by playing a text-to-speech message to the caller.
Plivo requests an answer URL when it answers the call (step 2) and expects the file at that address to hold a valid XML response from the application with instructions on how to handle the call. In this example, when an incoming call is received, Plivo’s text-to-speech engine plays a message using the Speak XML element.

How it works

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 Ruby application to handle incoming calls
Create a file calledreceive_call.rb and paste into it this code.Copy
Ask AI
include Plivo
include Plivo::XML
include Plivo::Exceptions
class PlivoController < ApplicationController
def inbound
response = Response.new
speak_body = 'Hello, you just received your first call'
response.addSpeak(speak_body)
xml = Plivo::PlivoXML.new(response)
render xml: xml.to_xml
end
end
Create a Plivo application to receive calls
Associate the Ruby application you created with Plivo by creating a Plivo application. Visit Voice > Applications in the Plivo console and click on Add New Application, or use Plivo’s Application API.Give your application a name — we called oursReceive_call. Enter the server URL you want to use (for example https://<yourdomain>.com/receive_call/) in the Answer URL field and set the method to POST. Click Create Application to save your application.
Assign a Plivo number to your application
Navigate to the Numbers page and select the phone number you want to use for this application.From the Application Type drop-down, selectXML Application.From the Plivo Application drop-down, select Receive_call (the name we gave the application).Click Update Number to save.
Test
Make a call to your Plivo number using any phone. Plivo will send a request to the answer URL you provided requesting an XML response and then process the call according to the instructions in the XML document the server provides. You should hear the text-to-speech message, “Hello, you just received your first call.”Overview
This guide shows how to receiving incoming calls on a Plivo number and greet callers with a text-to-speech message. Managing incoming calls is a key part of the call flow in many common use cases, such as interactive voice response (IVR), call forwarding, and conference calling.You can handle incoming calls either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.- Using XML
Here’s how to use a Plivo XML document that handles incoming calls on a Plivo number by playing a text-to-speech message to the caller.
Plivo requests an answer URL when it answers the call (step 2) and expects the file at that address to hold a valid XML response from the application with instructions on how to handle the call. In this example, when an incoming call is received, Plivo’s text-to-speech engine plays a message using the Speak XML element.

How it works

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 server to handle incoming calls
Create a file calledreceive_call.py and paste into it this code.Copy
Ask AI
from flask import Flask, request, make_response
from plivo import plivoxml
app = Flask(__name__)
@app.route('/receive_call/', methods=['GET','POST'])
def speak_xml():
response = (plivoxml.ResponseElement()
.add(plivoxml.SpeakElement('Hello, you just received your first call')))
return(response.to_string())
if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True)
Create a Plivo application to receive calls
Associate the Flask server you created with Plivo by creating a Plivo application. Visit Voice > Applications in the Plivo console and click on Add New Application, or use Plivo’s Application API.Give your application a name — we called oursReceive_call. Enter the server URL you want to use (for example https://<yourdomain>.com/receive_call/) in the Answer URL field and set the method to POST. Click Create Application to save your application.
Assign a Plivo number to your application
Navigate to the Numbers page and select the phone number you want to use for this application.From the Application Type drop-down, selectXML Application.From the Plivo Application drop-down, select Receive_call (the name we gave the application).Click Update Number to save.
Test
Make a call to your Plivo number using any phone. Plivo will send a request to the answer URL you provided requesting an XML response and then process the call according to the instructions in the XML document the server provides. You should hear the text-to-speech message, “Hello, you just received your first call.”Overview
This guide shows how to receiving incoming calls on a Plivo number and greet callers with a text-to-speech message. Managing incoming calls is a key part of the call flow in many common use cases, such as interactive voice response (IVR), call forwarding, and conference calling.You can handle incoming calls either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.- Using XML
Here’s how to use a Plivo XML document that handles incoming calls on a Plivo number by playing a text-to-speech message to the caller.
Plivo requests an answer URL when it answers the call (step 2) and expects the file at that address to hold a valid XML response from the application with instructions on how to handle the call. In this example, when an incoming call is received, Plivo’s text-to-speech engine plays a message using the Speak XML element.The command generates a controller named VoiceController in the app/http/controllers/ directory. Edit the app/http/controllers/voiceController.php file and paste into it this code.

How it works

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 for incoming calls
Change to the project directory and run this command to create a Laravel controller for inbound calls.Copy
Ask AI
$ php artisan make:controller VoiceController
Copy
Ask AI
<?php
namespace App\Http\Controllers;
require '../../vendor/autoload.php';
use Plivo\RestClient;
use Plivo\XML\Response;
use Illuminate\Http\Request;
class VoiceController extends Controller
{
// Speak XML to handle your first incoming call
public function receiveCall()
{
$response = new Response();
$speak_body = "Hello, you just received your first call";
$response->addSpeak($speak_body);
Header('Content-type: text/xml');
echo $response->toXML();
}
}
Create a Plivo application to receive calls
Associate the controller you created with Plivo by creating a Plivo application. Visit Voice > Applications in the Plivo console and click on Add New Application, or use Plivo’s Application API.Give your application a name — we called oursReceive_call. Enter the server URL you want to use (for example https://<yourdomain>.com/receive_call/) in the Answer URL field and set the method to POST. Click Create Application to save your application.
Assign a Plivo number to your application
Navigate to the Numbers page and select the phone number you want to use for this application.From the Application Type drop-down, selectXML Application.From the Plivo Application drop-down, select Receive_call (the name we gave the application).Click Update Number to save.
Test
Make a call to your Plivo number using any phone. Plivo will send a request to the answer URL you provided requesting an XML response and then process the call according to the instructions in the XML document the server provides. You should hear the text-to-speech message, “Hello, you just received your first call.”Overview
This guide shows how to receiving incoming calls on a Plivo number and greet callers with a text-to-speech message. Managing incoming calls is a key part of the call flow in many common use cases, such as interactive voice response (IVR), call forwarding, and conference calling.You can handle incoming calls either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.- Using XML
Here’s how to use a Plivo XML document that handles incoming calls on a Plivo number by playing a text-to-speech message to the caller.
Plivo requests an answer URL when it answers the call (step 2) and expects the file at that address to hold a valid XML response from the application with instructions on how to handle the call. In this example, when an incoming call is received, Plivo’s text-to-speech engine plays a message using the Speak XML element.
Give the project a name — we used
Navigate to the Controllers directory in the Receivecall project. Create a controller named ReceivecallController.cs and paste into it this code.

How it works

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 handle incoming calls
In Visual Studio, create a new project. Use the template for Web Application (Model-View-Controller).
Receivecall.
Copy
Ask AI
using System;
using Plivo.XML;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
namespace Receivecall
{
public class ReceivecallController : Controller
{
public IActionResult Index()
{
Plivo.XML.Response resp = new Plivo.XML.Response();
resp.AddSpeak("Hello, you just received your first call",
new Dictionary<string, string>() {
{
"loop",
"3"
}
});
var output = resp.ToString();
Console.WriteLine(output);
return this.Content(output, "text/xml");
}
}
}
Create a Plivo application to receive calls
Associate the controller you created with Plivo by creating a Plivo application. Visit Voice > Applications in the Plivo console and click on Add New Application, or use Plivo’s Application API.Give your application a name — we called oursReceive_call. Enter the server URL you want to use (for example https://<yourdomain>.com/receive_call/) in the Answer URL field and set the method to POST. Click Create Application to save your application.
Assign a Plivo number to your application
Navigate to the Numbers page and select the phone number you want to use for this application.From the Application Type drop-down, selectXML Application.From the Plivo Application drop-down, select Receive_call (the name we gave the application).Click Update Number to save.
Test
Make a call to your Plivo number using any phone. Plivo will send a request to the answer URL you provided requesting an XML response and then process the call according to the instructions in the XML document the server provides. You should hear the text-to-speech message, “Hello, you just received your first call.”Overview
This guide shows how to receiving incoming calls on a Plivo number and greet callers with a text-to-speech message. Managing incoming calls is a key part of the call flow in many common use cases, such as interactive voice response (IVR), call forwarding, and conference calling.You can handle incoming calls either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.- Using XML
Here’s how to use a Plivo XML document that handles incoming calls on a Plivo number by playing a text-to-speech message to the caller.
Plivo requests an answer URL when it answers the call (step 2) and expects the file at that address to hold a valid XML response from the application with instructions on how to handle the call. In this example, when an incoming call is received, Plivo’s text-to-speech engine plays a message using the Speak XML element.

How it works

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 Spark application to handle incoming calls
Create a Java class calledReceiveCall and paste into it this code.Copy
Ask AI
import static spark.Spark.*;
import com.plivo.api.xml.Speak;
import com.plivo.api.xml.Response;
public class ReceiveCall {
public static void main(String[] args) {
post("/receive_call/", (request, response) -> {
response.type("application/xml");
return new Response()
.children(new Speak("Hello, you just received your first call")).toXmlString();
});
}
}
Create a Plivo application to receive calls
Associate the Spark application you created with Plivo by creating a Plivo application. Visit Voice > Applications in the Plivo console and click on Add New Application, or use Plivo’s Application API.Give your application a name — we called oursReceive_call. Enter the server URL you want to use (for example https://<yourdomain>.com/receive_call/) in the Answer URL field and set the method to POST. Click Create Application to save your application.
Assign a Plivo number to your application
Navigate to the Numbers page and select the phone number you want to use for this application.From the Application Type drop-down, selectXML Application.From the Plivo Application drop-down, select Receive_call (the name we gave the application).Click Update Number to save.
Test
Make a call to your Plivo number using any phone. Plivo will send a request to the answer URL you provided requesting an XML response and then process the call according to the instructions in the XML document the server provides. You should hear the text-to-speech message, “Hello, you just received your first call.”÷÷Overview
This guide shows how to receiving incoming calls on a Plivo number and greet callers with a text-to-speech message. Managing incoming calls is a key part of the call flow in many common use cases, such as interactive voice response (IVR), call forwarding, and conference calling.You can handle incoming calls either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.- Using XML
Here’s how to use a Plivo XML document that handles incoming calls on a Plivo number by playing a text-to-speech message to the caller.
Plivo requests an answer URL when it answers the call (step 2) and expects the file at that address to hold a valid XML response from the application with instructions on how to handle the call. In this example, when an incoming call is received, Plivo’s text-to-speech engine plays a message using the Speak XML element.

How it works

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 application to handle incoming calls
Create a file calledreceive_call.go and paste into it this code.Copy
Ask AI
package main
import (
"fmt"
"net/http"
"github.com/plivo/plivo-go/v7"
)
func handler(w http.ResponseWriter, r *http.Request) {
response := xml.ResponseElement{
Contents: []interface{} {
new(xml.SpeakElement).
AddSpeak("Hello, you just received your first call"),
},
}
fmt.Printf(response.String())
}
func main() {
http.HandleFunc("/receive_call/", handler)
http.ListenAndServe(":8080", nil)
}
Create a Plivo application to receive calls
Associate the Go application you created with Plivo by creating a Plivo application. Visit Voice > Applications in the Plivo console and click on Add New Application, or use Plivo’s Application API.Give your application a name — we called oursReceive_call. Enter the server URL you want to use (for example https://<yourdomain>.com/receive_call/) in the Answer URL field and set the method to POST. Click Create Application to save your application.
Assign a Plivo number to your application
Navigate to the Numbers page and select the phone number you want to use for this application.From the Application Type drop-down, selectXML Application.From the Plivo Application drop-down, select Receive_call (the name we gave the application).Click Update Number to save.