JSON API » webhook » webhook/usage

Webhook usage.

Introduction

015Pbx can send webhook on extension and queue calls. It will pass details of the call to the URL.

To add a new Webhook

  1. Log in to the 015 Cloud web interface.
  2. Go to Features » Web Urls Templates.
  3. Click the "Create" button.
  4. Enter the following:
    • A name for the web urls template.
    • Optionally a description.
    • Set the option "Is Webhooks" to Yes
    • In "Event Filter" Select the Event that 015Pbx will send the call details (listed in the "Event" section below)
    • HTTP URL to send the events
    • HTTP request method
    • HTTP request headers
    • HTTP request body
  5. Click the "Save" button.

Call flow

  1. 015Pbx will invoke the URL specified, passing the call fields that listed in the "Template" section below.

Event fields

  • Calling: Event on call start
  • Answer: Event on call answer
  • Hangup: Event on call hangup
  • Hangup Answered Only: Event on call hangup only if the call was answered
  • Transfer: Event on transfer call
  • Abandon: Event on abandon of queue call
  • Join: Event on call enter to the queue
  • Leave: Event on call leave the queue
  • ReJoin: Event on call re-enter to the queue
  • Queue Callback: Event on caller ask to callback from the queue
  • Complete Agent: Event on queue call that agent Hangup the call
  • Complete Caller: Event on queue call that caller Hangup the call
  • Pause: Event on agent pause
  • UnPause: Event on agent un-pause
  • Login: Event on agent login
  • Logout: Event on agent logout

Template fields

This fields can send in the HTTP request to supply details of the call:

  • #start#: The start time of the call. (in timestamp)
  • #answered#: The answered time of the call. (in timestamp)
  • #end#: The end time of the call. (in timestamp)
  • #status#: The status of the event. Values from the "Event" section
  • #callid#: An identifier for the call. The combination of server and callid will be different for every call. Legs of the same call will have the same callid but may have different uniqueids, depending on how they are routed within the server.
  • #uniqueid#: An identifier for the call leg within the server at the telephony level.
  • #callerid_external#: The calling number.
  • #callername#: The caller name.
  • #stype#: The source type. This will normally be "external" for an external number, or "phone" for a local telephone.
  • #snumber#: The source number. The calling number or telephone. If a telephone, it will be the account rather than callerid.
  • #dtype#: The destination type that sent the call to the URL. For example, "number" or "code".
  • #dnumber#: The destination number that sent the call to the URL, i.e. the number or feature code. For some dtypes such as IVR, this will be the ID of the object in the database.
  • #ctype#: The called type. This will normally be blank, unless a call has been redirected.
  • #cnumber#: The called number, as presented to the system.
  • #extension#: The extension that called or calling (if the call is coming in or out from the extension)
  • #direction#: The direction of the call. "inbound", "outbound" or "internal"
  • #totaltime#: How long the call ran for in seconds, including ringing.
  • #talktime#: How long the call ran for in seconds, excluding ringing. For calls which were not answered, this will be 0.
  • #recording#: The path to the recording file. If there was no recording, this will be an empty string.

Example with URL encoded:

Headers:

Content-Type: application/x-www-form-urlencoded

Template:

start=#start#&uniqueid=#uniqueid#&callid=#callid#&stype=#stype#&snumber=#snumber#&dtype=#dtype#&dnumber=#dnumber#&status=#status#&callerid=#callerid_external#&callername=#callername#&server=#server#&ctype=#ctype#&cnumber=#cnumber#&recording=https://015pbx.net/recordings/Records/#recording#.mp3&end=#end#&extension=#extension#&direction=#direction#&totaltime=#totaltime#&talktime=#talktime#&answered=#answered#

Example with JSON:

Headers:

Content-Type: application/json

Template:

{
  "start":#start#,
  "uniqueid":#uniqueid#,
  "callid":#callid#,
  "stype":"#stype#",
  "snumber":"#snumber#",
  "dtype":"#dtype#",
  "dnumber":"#dnumber#",
  "status":"#status#",
  "callerid":"#callerid_external#",
  "callername":"#callername#",
  "server":"#server#",
  "ctype":"#ctype#",
  "cnumber":"#cnumber#",
  "recording":"https://015pbx.net/recordings/Records/#recording#.mp3",
  "end":"#end#",
  "extension":"#extension#",
  "direction":"#direction#",
  "totaltime":#totaltime#,
  "talktime":#talktime#,
  "answered":#answered#
}