
Webhooks for outbound calls
For outbound calls from your web application, you can use callbacks to manage the call flow and receive status events on your application server. Plivo uses webhook callbacks in both Voice API and XML elements:URLs specific to API request payload
Webhook parameters associated with a Voice API outbound call payload are answer_url, ring_url, fallback_url, and hangup_url. answer_url is a mandatory parameter for outbound API calls; the others are optional. You can configure unique webhook URLs and set the method as either POST or GET to receive call status-related callbacks during different events.-
answer_url : When a call is answered by the destination number, you can control the call flow with the help of the answer_url set in the API request. Plivo invokes the answer_url specified as soon as the call is answered and expects a valid XML response with instructions to handle the call. To see how this works, you can use https://s3.amazonaws.com/static.plivo.com/answer.xml as answer_url to test your first outgoing call:
This XML snippet gives instructions to say, “Congratulations! You’ve made your first outbound call!” to the call recipient.
- fallback_url : Plivo can invoke this URL if answer_url is not reachable.
- ring_url : Plivo can notify this URL when the call starts ringing.
- hangup_url : Plivo can notify this URL when the call is disconnected.
URLs specific to XML response from the answer_url of outbound Call API
The URLs most commonly associated with an XML response from the answer_url are action and callbackUrl.- action : Plivo expects XML instructions to carry forward the call in response to action requests, which are typically invoked at the end of an XML element’s execution, such as when an IVR input is received from the caller during a GetInput XML execution.
- callbackUrl : No XML instructions are expected in response to these requests. They serve as webhooks to notify your application server of important events during the course of an XML element’s execution, such as when a conference participant is muted or unmuted.
Webhooks for inbound calls
You can use webhooks with Plivo numbers to receive callbacks for incoming calls. When a voice-enabled Plivo phone number receives an incoming call, Plivo sends an HTTP request callback (either POST or GET depending on the method set for the webhook) to the URL specified in the application. In the callback, all the information related to the inbound call is either in the POST request’s body or the GET request’s query parameters. Here are details about the URLs associated with an inbound call to a Plivo number:URLs specific to the Plivo number’s Voice app
The URLs associated with API payload are Primary Answer URL, Fallback Answer URL, and Hangup URL.- Primary Answer URL is a mandatory field for a voice application assigned to a Plivo number; the other URLs are optional. You can configure these fields with unique webhook URLs and set the method as either POST or GET to receive call status-related callbacks during different events.
- Fallback Answer URL : Plivo invokes this URL if the Primary Answer URL is not reachable.
- Hangup URL is an optional URL that Plivo can notify when the call is disconnected.
URLs specific to the XML response from the answer_url
The URLs associated with the XML response from the answer_url are action and callbackUrl.- action : XML instructions to carry forward the call are expected in response to these requests. These requests are typically invoked at the end of an XML element’s execution, such as when an IVR input is received from the caller during a GetInput XML execution.
- callbackUrl : No XML instructions are expected in response to these requests. Such requests serve as webhooks to notify your application server of important events during the course of an XML element’s execution, such as when a conference participant is muted or unmuted.