Integrations - Webhooks¶
Webhooks are triggered by Call Event, such as call ringing, call answered, call hangup etc. When that event occurs, VoIPstudio platform makes an HTTPS (POST) request to the URL configured for the Webhook - a third party web server (API). See more more on Wikipedia
- Click on Integrations.
- Scroll down to Webshooks and Enable.
- Select Add Webhook to create a new one.
- Enter any name for the new Webhook to indentify.
- Select events to listen for. Note
Call State change
type include all events. - Enter the URL used by your application.
- To Edit any Webhooks simply click on the name.
- If no longer needed simply click disable Webhooks.
NOTE: Only HTTPS Protocol is supported.
NOTE: For URL to be saved it need to be valid and reply to https requests.
Available events¶
With VoIPtudio WebHooks we monitor following call status events categories:
- Call State Change - triggered for any call state change: INITIAL, RINING, CONNECTED, ON_HOLD, HANGUP.
- Call Ringing
- Call Connected
- Call Ended
- Call Missed
- Call DTMF received
Note: webhook events show call status and they are matching SIP signalling messages as detailed bellow:
INITIAL
: SIP INVITE send to the corresponding endpoint (Phone).RINGING
: endpoint reply from SIP INVITE. It is indicating that the endpoint is active and it is already ringing.CONNECTED
: SIP 200 message indicating that user answered the call.ON_HOLD
: The call has ben paused. This corresponds to SIP INVITE withbody: a=sendonly
HANGUP
: indicating that call has ended. This corresponds to SIP BYE Message.
Apart from call status events, the following additional events are available:
- SMS received
- Queue wrap up - emitted when post call Wrap Up panel opens, closes or times out.
Event attributes¶
Events are delivered as HTTPs POST requests with JSON body - for example:
{
"id":"uk003.608920d55f7ac3.77053295",
"event_time":"2021-04-28 08:46:13",
"event_name":"call.hangup",
"call_id":139543232,
"state":"HANGUP",
"connected_at":"2021-04-28 08:46:02",
"start_time":"2021-04-28 08:45:55",
"context":"LOCAL_USER",
"destination":"in",
"duration":11,
"t_cause":"Normal Clearing",
"src":"447854740947",
"src_id":"0",
"src_name":"\"442035141598\" <2035141598>",
"src_hash":"fe5935cefbc82fc4e924bdaa21342a49c18c5dd9",
"dst":"441183211001",
"dst_id":"10002",
"dst_name":"John Smith",
"terminated_by": "caller"
}
Additionally for "DTMF received" event call.dtmf
two extra attributes are present:
"dtmf_tag":"*",
"dtmf_target":"U:123456"
Call status event attributes are as follows:
id
(string) - unique ID of an Eventevent_time
(string) - time of an Event in Y-m-d H:i:s format UTC timezoneevent_name
(string) - name of an Event, one of:call.initial
- Call in initial statecall.ringing
- Call is ringingcall.missed
- Missed (unanswered) callcall.connected
- Call is connectedcall.hangup
- Call is terminatedcall.hold
- Call is put onholdcall.unhold
- Call is unholdcall.dtmf
- In call DTMF is received
call_id
(integer) - this is numeric ID of the call. It can be later used to access resources via REST API. The relation to REST API resources is:call.id
- example REST API request:cdr.live_id
- example REST API request: GET/v1.1/cdrs?filter=[{"property":"live_id","operator":"=","value":"{call.id}"}]
monitor.live_id
- example REST API request: GET/v1.1/monitors?filter=[{"property":"live_id","operator":"=","value":"{call.id}"}]
state
(string) - state of the Call, one of:INITIAL
- Initial call stateACCEPTED
- Click 2 call has been acceptedRINGING
- Destination is riningCONNECTED
- Call is connectedON_HOLD
- Call is on holdHANGUP
- Call is terminated
connected_at
(string) - time when call was connected in Y-m-d H:i:s format UTC timezone. Defaultnull
start_time
(string) - time when call started in Y-m-d H:i:s format UTC timezone.context
(string) - context of the call within PBX systemdestination
(string) -in
for inbound call,out
for outbound callduration
(integer) - duration of the call is secondst_cause
(string) - Termination Causesrc
(string) - Number of the call sourcesrc_id
(integer) - Numeric ID of call sourcesrc_name
(string) - Name of the call sourcesrc_hash
(string) - Unique ID for single calldst
(string) - Number of the call destinationdst_id
(integer) - Numeric ID of call destinationdst_name
(string) - Name of the call destinationterminated_by
(string) - Designates party which terminated the callcaller
orcalled
SMS Received event attributes are as follows:
id
(string) - unique ID of an Eventevent_time
(string) - time of an Event in Y-m-d H:i:s format UTC timezoneevent_name
(string) - name of an Eventsms.received
customer_id
(integer) - Numeric ID of Customer Account which received SMS messageuser_id
(integer) - Numeric ID of User Account which received SMS message (optional, default:null
)from_no
(string) - originating phone numberto_no
(string) - phone number which received SMS messagetext
(string) - body of received message
Queue Wrap up event attributes are as follows:
event_name
(string) -queue.wrapup
state
(string) - state of the Wrap up panel:START
- panel has been opoenedEND
- panel has been closed by an AgentTIMEOUT
- panel was clsosed automatically due to timeout
all attritutes are the same as Call Event described below, with the exception of:
Related REST API endpoints¶
After receiving Webhook event as in example above (call_id
= 139543232
), one can retrieve and update Call resource via REST API:
GET /v1.1/calls/139543232
and to Transfer the call to extension 2002
:
PATCH /v1.1/calls/139543232
{
"dst": "2002"
}
Note: /calls
REST API resource represents active ongoing call. Once call is terminated and Event call.hangup
received it is no longer available at /calls
endpoint. Instead it can be accessed at /cdrs
(Call Details Report) and /monitors
(Call Recordings) endpoints using filter on live_id
attribute with value of call_id
from Webhook event, for example:
GET /v1.1/cdrs?filter=[{"property":"live_id","operator":"=","value":"139543232"}]
or
GET /v1.1/monitors?filter=[{"property":"live_id","operator":"=","value":"139543232"}]
Context attribute - Queue¶
As we have seen, context
attribute may have several values depending on the object that we generate them. If we like to monitor the events that occur in a user, we will need to look for attribute with context value LOCAL_USER
but if we want to monitor the events that occur in a queue, we will filter by theQUEUE
context.
Note: to start receiving Queue events we will need at least one Webhook on type Call Status Change
. As this is generating events for every objet.
These event context allow us to identify when a call has not been answered by any agent. Either because the maximum wait time has been reached or you just user got tired of waiting and ended the call. So to identify an unanswered call within a queue instead of inspecting the Context = User
we will look for an event with context:Queue
and event_name:call.missed
.
Troubleshooting Webhooks¶
Call detailed Reports from VoIPstudio dashboard allow customers to monitor all SIP packets workflow in a graphical view for every single call. It also display the Webhooks notifications send to your listening URL, including their content. This might be very useful to troubleshoot your Webhooks notification deployment.
You only need to browse Call Detailed Report and click on corresponding calls and check for the submitted events and their content. This should match the notification you received on server. Please follow steps bellow:
- From Admin dashboard panel open
History
section. - Click
CDR
, this will open list with recent calls processed under VoIPstudio platform. - Identify and click the call you would like to inspect to open detailed info of the corresponding call.
- Under call flow identify your API server column.
- You must see one POST request send to the server for each event you ave Webhook event set. Click on it to expand.
- Details of the Webhook post reply are shown here.