> ## Documentation Index
> Fetch the complete documentation index at: https://plivo.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Receive Incoming Calls

> Handle incoming calls on a Plivo number with text-to-speech greetings

> [tab] Node
>
> ## 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.
>
> > [tab] 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.
> >
> > ## How it works
> >
> > ![Inbound Call Flow](https://mintcdn.com/plivo/7-odxN9fJG_Dg1dt/images/receive-incoming-calls.png?fit=max\&auto=format\&n=7-odxN9fJG_Dg1dt\&q=85\&s=fc3a488003b5b2eaa3ebe2302793cf9e)
> >
> > 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](https://plivo.com/docs/voice/xml/audio-output.md#speak) XML element.
> >
> > ## Prerequisites
> >
> > To get started, you need a Plivo account —  [sign up](https://cx.plivo.com/signup) 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](https://cx.plivo.com/phone-numbers) page of the Plivo console, or by using the [Numbers API](https://plivo.com/docs/numbers.md). 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).
> >
> > ![Create an MVC app](https://mintcdn.com/plivo/2OFvQXVNT3srKLUy/images/create_mvcapp.png?fit=max\&auto=format\&n=2OFvQXVNT3srKLUy\&q=85\&s=342cab800d30d99fb9cdb362a91ccab8)
> >
> > Give the project a name — we used `Receivecall`.
> >
> > ![Configure the MVC app](https://mintcdn.com/plivo/EvRfP72Bjs4tuRt5/images/configure_mvcapp.png?fit=max\&auto=format\&n=EvRfP72Bjs4tuRt5\&q=85\&s=9c42a016caf26a1d44fc1edbafa2ae14)
> >
> > Navigate to the Controllers directory in the Receivecall project. Create a controller named ReceivecallController.cs and paste into it this code.
> >
> > ```cs theme={null}
> > 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](https://cx.plivo.com/xml-applications) in the Plivo console and click on **Add New Application**, or use Plivo’s [Application API](https://plivo.com/docs/account/api/application.md#create-an-application).
> >
> > Give your application a name — we called ours `Receive_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.
> >
> > ![Create Application](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/create_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=a59eb98ad01ad5ce21f2e2e0a702bc82)
> >
> > ## Assign a Plivo number to your application
> >
> > Navigate to the [Numbers](https://cx.plivo.com/phone-numbers) page and select the phone number you want to use for this application.
> >
> > From the Application Type drop-down, select `XML Application`.
> >
> > From the Plivo Application drop-down, select `Receive_call` (the name we gave the application).
> >
> > Click **Update Number** to save.
> >
> > ![Assign Phone Number to Receive Call App](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/assign_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=f6fefc30231d54f0dd650ffa77672b03)
> >
> > ## 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.”

> [tab] Ruby
>
> ## 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.
>
> > [tab] 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.
> >
> > ## How it works
> >
> > ![Inbound Call Flow](https://mintcdn.com/plivo/7-odxN9fJG_Dg1dt/images/receive-incoming-calls.png?fit=max\&auto=format\&n=7-odxN9fJG_Dg1dt\&q=85\&s=fc3a488003b5b2eaa3ebe2302793cf9e)
> >
> > 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](https://plivo.com/docs/voice/xml/audio-output.md#speak) XML element.
> >
> > ## Prerequisites
> >
> > To get started, you need a Plivo account —  [sign up](https://cx.plivo.com/signup) 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](https://cx.plivo.com/phone-numbers) page of the Plivo console, or by using the [Numbers API](https://plivo.com/docs/numbers.md). 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 called `receive_call.rb` and paste into it this code.
> >
> > ```rb theme={null}
> > 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](https://cx.plivo.com/xml-applications) in the Plivo console and click on **Add New Application**, or use Plivo’s [Application API](https://plivo.com/docs/account/api/application.md#create-an-application).
> >
> > Give your application a name — we called ours `Receive_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.
> >
> > ![Create Application](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/create_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=a59eb98ad01ad5ce21f2e2e0a702bc82)
> >
> > ## Assign a Plivo number to your application
> >
> > Navigate to the [Numbers](https://cx.plivo.com/phone-numbers) page and select the phone number you want to use for this application.
> >
> > From the Application Type drop-down, select `XML Application`.
> >
> > From the Plivo Application drop-down, select `Receive_call` (the name we gave the application).
> >
> > Click **Update Number** to save.
> >
> > ![Assign Phone Number to Receive Call App](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/assign_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=f6fefc30231d54f0dd650ffa77672b03)
> >
> > ## 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.”

> [tab] Python
>
> ## 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.
>
> > [tab] 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.
> >
> > ## How it works
> >
> > ![Inbound Call Flow](https://mintcdn.com/plivo/7-odxN9fJG_Dg1dt/images/receive-incoming-calls.png?fit=max\&auto=format\&n=7-odxN9fJG_Dg1dt\&q=85\&s=fc3a488003b5b2eaa3ebe2302793cf9e)
> >
> > 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](https://plivo.com/docs/voice/xml/audio-output.md#speak) XML element.
> >
> > ## Prerequisites
> >
> > To get started, you need a Plivo account —  [sign up](https://cx.plivo.com/signup) 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](https://cx.plivo.com/phone-numbers) page of the Plivo console, or by using the [Numbers API](https://plivo.com/docs/numbers.md). 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 called `receive_call.py` and paste into it this code.
> >
> > ```py theme={null}
> > 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](https://cx.plivo.com/xml-applications) in the Plivo console and click on **Add New Application**, or use Plivo’s [Application API](https://plivo.com/docs/account/api/application.md#create-an-application).
> >
> > Give your application a name — we called ours `Receive_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.
> >
> > ![Create Application](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/create_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=a59eb98ad01ad5ce21f2e2e0a702bc82)
> >
> > ## Assign a Plivo number to your application
> >
> > Navigate to the [Numbers](https://cx.plivo.com/phone-numbers) page and select the phone number you want to use for this application.
> >
> > From the Application Type drop-down, select `XML Application`.
> >
> > From the Plivo Application drop-down, select `Receive_call` (the name we gave the application).
> >
> > Click **Update Number** to save.
> >
> > ![Assign Phone Number to Receive Call App](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/assign_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=f6fefc30231d54f0dd650ffa77672b03)
> >
> > ## 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.”

> [tab] PHP
>
> ## 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.
>
> > [tab] 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.
> >
> > ## How it works
> >
> > ![Inbound Call Flow](https://mintcdn.com/plivo/7-odxN9fJG_Dg1dt/images/receive-incoming-calls.png?fit=max\&auto=format\&n=7-odxN9fJG_Dg1dt\&q=85\&s=fc3a488003b5b2eaa3ebe2302793cf9e)
> >
> > 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](https://plivo.com/docs/voice/xml/audio-output.md#speak) XML element.
> >
> > ## Prerequisites
> >
> > To get started, you need a Plivo account —  [sign up](https://cx.plivo.com/signup) 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](https://cx.plivo.com/phone-numbers) page of the Plivo console, or by using the [Numbers API](https://plivo.com/docs/numbers.md). 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.
> >
> > ```shell theme={null}
> > $ php artisan make:controller VoiceController
> > ```
> >
> > 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.
> >
> > ```php theme={null}
> > <?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](https://cx.plivo.com/xml-applications) in the Plivo console and click on **Add New Application**, or use Plivo’s [Application API](https://plivo.com/docs/account/api/application.md#create-an-application).
> >
> > Give your application a name — we called ours `Receive_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.
> >
> > ![Create Application](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/create_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=a59eb98ad01ad5ce21f2e2e0a702bc82)
> >
> > ## Assign a Plivo number to your application
> >
> > Navigate to the [Numbers](https://cx.plivo.com/phone-numbers) page and select the phone number you want to use for this application.
> >
> > From the Application Type drop-down, select `XML Application`.
> >
> > From the Plivo Application drop-down, select `Receive_call` (the name we gave the application).
> >
> > Click **Update Number** to save.
> >
> > ![Assign Phone Number to Receive Call App](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/assign_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=f6fefc30231d54f0dd650ffa77672b03)
> >
> > ## 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.”

> [tab] .NET
>
> ## 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.
>
> > [tab] 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.
> >
> > ## How it works
> >
> > ![Inbound Call Flow](https://mintcdn.com/plivo/7-odxN9fJG_Dg1dt/images/receive-incoming-calls.png?fit=max\&auto=format\&n=7-odxN9fJG_Dg1dt\&q=85\&s=fc3a488003b5b2eaa3ebe2302793cf9e)
> >
> > 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](https://plivo.com/docs/voice/xml/audio-output.md#speak) XML element.
> >
> > ## Prerequisites
> >
> > To get started, you need a Plivo account —  [sign up](https://cx.plivo.com/signup) 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](https://cx.plivo.com/phone-numbers) page of the Plivo console, or by using the [Numbers API](https://plivo.com/docs/numbers.md). 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).
> >
> > ![Create an MVC app](https://mintlify.s3.us-west-1.amazonaws.com/plivo/images/create_mvcapp.jpg)
> >
> > Give the project a name — we used `Receivecall`.
> >
> > ![Configure the MVC app](https://mintlify.s3.us-west-1.amazonaws.com/plivo/images/configure_mvcapp.jpg)
> >
> > Navigate to the Controllers directory in the Receivecall project. Create a controller named ReceivecallController.cs and paste into it this code.
> >
> > ```cs theme={null}
> > 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](https://cx.plivo.com/xml-applications) in the Plivo console and click on **Add New Application**, or use Plivo’s [Application API](https://plivo.com/docs/account/api/application.md#create-an-application).
> >
> > Give your application a name — we called ours `Receive_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.
> >
> > ![Create Application](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/create_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=a59eb98ad01ad5ce21f2e2e0a702bc82)
> >
> > ## Assign a Plivo number to your application
> >
> > Navigate to the [Numbers](https://cx.plivo.com/phone-numbers) page and select the phone number you want to use for this application.
> >
> > From the Application Type drop-down, select `XML Application`.
> >
> > From the Plivo Application drop-down, select `Receive_call` (the name we gave the application).
> >
> > Click **Update Number** to save.
> >
> > ![Assign Phone Number to Receive Call App](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/assign_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=f6fefc30231d54f0dd650ffa77672b03)
> >
> > ## 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.”

> [tab] Java
>
> ## 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.
>
> > [tab] 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.
> >
> > ## How it works
> >
> > ![Inbound Call Flow](https://mintcdn.com/plivo/7-odxN9fJG_Dg1dt/images/receive-incoming-calls.png?fit=max\&auto=format\&n=7-odxN9fJG_Dg1dt\&q=85\&s=fc3a488003b5b2eaa3ebe2302793cf9e)
> >
> > 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](https://plivo.com/docs/voice/xml/audio-output.md#speak) XML element.
> >
> > ## Prerequisites
> >
> > To get started, you need a Plivo account —  [sign up](https://cx.plivo.com/signup) 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](https://cx.plivo.com/phone-numbers) page of the Plivo console, or by using the [Numbers API](https://plivo.com/docs/numbers.md). 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 called `ReceiveCall` and paste into it this code.
> >
> > ```java theme={null}
> > 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](https://cx.plivo.com/xml-applications) in the Plivo console and click on **Add New Application**, or use Plivo’s [Application API](https://plivo.com/docs/account/api/application.md#create-an-application).
> >
> > Give your application a name — we called ours `Receive_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.
> >
> > ![Create Application](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/create_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=a59eb98ad01ad5ce21f2e2e0a702bc82)
> >
> > ## Assign a Plivo number to your application
> >
> > Navigate to the [Numbers](https://cx.plivo.com/phone-numbers) page and select the phone number you want to use for this application.
> >
> > From the Application Type drop-down, select `XML Application`.
> >
> > From the Plivo Application drop-down, select `Receive_call` (the name we gave the application).
> >
> > Click **Update Number** to save.
> >
> > ![Assign Phone Number to Receive Call App](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/assign_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=f6fefc30231d54f0dd650ffa77672b03)
> >
> > ## 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.”

> [tab] 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.
>
> > [tab] 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.
> >
> > ## How it works
> >
> > ![Inbound Call Flow](https://mintcdn.com/plivo/7-odxN9fJG_Dg1dt/images/receive-incoming-calls.png?fit=max\&auto=format\&n=7-odxN9fJG_Dg1dt\&q=85\&s=fc3a488003b5b2eaa3ebe2302793cf9e)
> >
> > 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](https://plivo.com/docs/voice/xml/audio-output.md#speak) XML element.
> >
> > ## Prerequisites
> >
> > To get started, you need a Plivo account —  [sign up](https://cx.plivo.com/signup) 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](https://cx.plivo.com/phone-numbers) page of the Plivo console, or by using the [Numbers API](https://plivo.com/docs/numbers.md). 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 called `receive_call.go` and paste into it this code.
> >
> > ```go theme={null}
> > 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](https://cx.plivo.com/xml-applications) in the Plivo console and click on **Add New Application**, or use Plivo’s [Application API](https://plivo.com/docs/account/api/application.md#create-an-application).
> >
> > Give your application a name — we called ours `Receive_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.
> >
> > ![Create Application](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/create_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=a59eb98ad01ad5ce21f2e2e0a702bc82)
> >
> > ## Assign a Plivo number to your application
> >
> > Navigate to the [Numbers](https://cx.plivo.com/phone-numbers) page and select the phone number you want to use for this application.
> >
> > From the Application Type drop-down, select `XML Application`.
> >
> > From the Plivo Application drop-down, select `Receive_call` (the name we gave the application).
> >
> > Click **Update Number** to save.
> >
> > ![Assign Phone Number to Receive Call App](https://mintcdn.com/plivo/Ac6PoKJHHxDx1U63/images/assign_receivecall_app.png?fit=max\&auto=format\&n=Ac6PoKJHHxDx1U63\&q=85\&s=f6fefc30231d54f0dd650ffa77672b03)
> >
> > ## 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.”
