- Node
- Ruby
- Python
- PHP
- .NET
- Java
- Go
Overview
Plivo passes the call status of an ongoing call so you can decide how to process it. For all the calls made using Plivo’s Make a Call API or Dial XML, Plivo sends the call status to the application server at different stages of a call. We send call status as an HTTP webhook request to URLs such asring_url, answer_url, fallback_url, action_url, callback_url, and hangup_url.In each callback, the CallStatus parameter takes one of these values:| in-progress | The call was answered and is in progress. Calls with this status can be terminated using the Hangup API. |
| completed | The call was completed, terminated either by the Hangup API or by one of the parties in the call. |
| ringing | The call is ringing. This status is sent to the Ring URL. |
| no-answer | The call was not answered. |
| busy | The called line is busy. |
| cancel | The call was canceled by the caller. |
| timeout | There was a timeout while connecting your call, caused by either an issue with one of the terminating carriers or network lag in our system. |
| Parameter | Description |
|---|---|
DialRingStatus | Indicates whether the dial attempt rang or not. Values: true, false |
DialHangupCause | The standard telephony hangup cause. |
DialStatus | Status of the dial. Values: completed, busy, failed, timeout, no-answer |
DialALegUUID | CallUUID of the A leg. |
DialBLegUUID | CallUUID of the B leg. Empty if nobody answers. |
- Using XML
Here’s how to use Plivo APIs and XML to send callback events for dial status reporting.
Plivo requests an answer URL when a Plivo number receives a call (step 2) and expects the file at that URL to be configured in the application assigned to the number to hold a valid XML response with instructions on how to handle the call. For outbound calls you specify an answer URL along with the make call API request, and for incoming calls the answer URL is specified in the Plivo application associated with the phone number.In addition to requests to the answer URL, Plivo initiates HTTP requests to your application server throughout the course of a call based on specific XML elements and attributes in your answer XML document (step 5). Such requests are broadly classified into two categories:Action URL requests: These requests are typically invoked at the end of an XML element’s execution, and the server expects XML instructions to carry forward the call in response to these requests. This happens, for example, when a caller provides Touch-Tone input during GetInput XML execution.Callback URL requests: These requests serve as webhooks to pass the application server information about events through the course of an XML element’s execution, such as when a conference participant is muted or unmuted. These callback URL requests can be used for dial status reporting. No XML instructions are expected in response to these requests.Replace the phone number placeholder with an actual phone number in E.164 format (for example, +12025551234).In this code, we tell Plivo to POST the call status to https://<yourdomain>.com/dialstatus/. We set the redirect attribute, which determines whether to change the call flow of an ongoing call based on the actions performed, to 

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 Express server for dial status reporting
Create a file calleddial_status.js and paste into it this code.true, which tells Plivo to expect a valid XML document to be posted to https://<yourdomain>.com/dialstatus/action. The code creates an XML document with a Dial XML element.Create a Plivo application for dial status reporting
Associate the Express 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 oursDial Status Report. Enter the server URL you want to use (for example https://<yourdomain>.com/dialstatus/) in the Answer URL field and set the method to POST. Click on 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 Dial Status Report (the name we gave the application).Click Update Number to save.