Table of Content
Table of Contents |
---|
Introduction
Webhooks are used to communicate between two different or same systems. You can use webhooks when you want central to send/receive any data from/to other systems. On Central, you can operate webhooks in 3 different manner, which are as follows -
...
You do not need to bother about the request body or need to specify the variables that needs to be passed. You can simply follow the 2 steps to invoke any webhook in between the flow.
Step 1 : Configure Internal Webhook
List of Internal Webhook
You can use any of the following internal functions. How to configure them is listed below.
...
Flow Variable | Example | Description |
$flow.key.cli_pause_update |
| The Direct Dial was successfully paused / unpaused |
Content |
| The Direct Dial was could not be paused / unpaused |
...
Step 1 : Configure Internal Webhook
First step is to configure a webhook(to which the details will be send). To configure a webhook, you can follow the below steps -
...
Info |
---|
Use this when you want to call any external API with predefined structure. All Flow Variables will work in any section of the widget. |
Introduction
This webhook widget is use to call any external API using dynamic data and configurable structure. You can use this when you want to integrate and use any external API in between or at the end of the flow execution.
Step 1: Add Webhook Widget
...
Add widget
...
In the flow designer select the webhook widget and add to the designer screen and connect with the appropriate widget. Now double click on the widget to open the configurations -
Now the select the ‘custom’ option in the URL
Step 2:
...
Configure Request
...
Method
URL: Dynamic flow variables will work
Authentication
Headers
Body Type
Query Parameters:
Mandatory
...
Configure Response:
Response Type
Path and how to find it
Note: x to be replaced with ‘data’
...
Other Configurations
Wait for response: How max seconds
...
Flow Variables available after Webhook widget
Generic:
Raw response
On Success
On Failture
...
Notes
...
After you select the custom option, you need to configure the webhook/API request. To configure the request, you need to following configurations -
Method : You need to select the method based on the action you need to perform in the API request. The methods supported are GET, POST, PATCH, DELETE, PUT, OPTION, HEAD.
Authentication : The authentication method that is required to perform the action on the URL. You can select ‘none’ if there is no authentication required or you can select ‘basic’ and provide username and password for authentication.
Headers : Some APIs require you to send particular headers along with sending request, typically to provide additional metadata about the operation you are performing. So by clicking on ‘add headers’ and you can provide headers that are necessary by providing its key and value. You can add multiple headers and mark them as mandatory as well (if required).
Body Type : The type of the body in which the request will be send. It can be none, JSON or XML.
Body : Here you need to provide the request body, according to the body type selected
Query Parameters : Query parameters are appended at the end of the URL. They are extensions of the URL that are used to help define specific content or actions based on the data being passed. You can add multiple query parameters by clicking on ‘add query parameter’ and also mark them as mandatory by selecting the checkbox. You can provide the key and value of the query parameter in their respective text box.
Info |
---|
|
Step 2 : Configure Response
Once the request is configured, you need to configure the response of that request in webhook widget. In order to configure response, follow below steps -
Response Type : Select the type of the response that you will be receiving from API call. The response type can be JSON or XML for now.
Object Mapping : You can directly store a particular response object in the flow variable. To add any response object, click on the '➕' button.
In the ‘save in’, enter the flow variable in which you want to save the response object and in the ‘object map’, paste/enter the path of the object.
' JSON' Response Type : When the response type is JSON, in order to find the path of the object you can visit http://jsonpathfinder.com.
On this page, you can paste your JSON response and on the right side, click on the object whose path you need to find.
You will be able to see the path at the top right corner.
Copy that path and paste in the ‘object map’ area.
Replace ‘X' with 'data’
To know more, you can refer to the help section of the widget.
You can mark any response object as ‘mandatory’, by selecting the checkbox.
‘XML’ Response Type : When the response type is XML, you can contact our support team to find the path at support@phonon.io.
Step 3 : Other Configurations
After the response parameters are configured, you can configure some additional configurations as follows -
Wait for response : Enable if you want to wait for the response of your request. You can play hold music meanwhile by enabling ‘enable hold music’. The maximum response wait time is ‘60 seconds’.
Persist Response : Enable if you want to retain the value of flow variables after the flow execution is completed.
Error code Flow Variables : Once the execution of webhook widget is over, you will be able to get some of the values in the specified flow variables which are as follows -
On Success -
Flow Variable | Description | Example Value |
---|---|---|
$flow.key.response_status | API call Success or Failure status | SUCCESS |
$flow.key.response_status_code | Status Code for response(2XX) | 200 |
$flow.key.response_duration | Duration in seconds for the API to return data | 0.11 |
$flow.key.response_raw | Raw response received from server, null if empty | |
$flow.key.response_error | If API resulted in error, Boolean true or false | false |
b. On Failure -
Flow Variable | Description | Example Value |
---|---|---|
$flow.key.response_status | API call Success or Failure status | FAILED |
$flow.key.response_status_code | Status Code for response | 401, 200 |
$flow.key.response_status_type | Type of error, based on status code | Redirection |
$flow.key.response_duration | Duration in seconds for the API to return data | 0.11 |
$flow.key.response_raw | Raw response received from server, null if empty | {...} |
$flow.key.response_error | If API resulted in error, Boolean true or false | true |
$flow.key.error_reason | Reason for failure | SERVER_ERROR |
Once the execution of the webhook widget is completed, according to the response the flow will move forward. That is for success response, it will move in ‘line 0’ and for failure response, it will move in ‘line 1’.
Flow End Webhook
On flow complete webhooks are used when you want to push/send all the flow details to the default webhook once the flow gets completed.
...
If you want to send some additional data at the end of the flow in some different format, then you can use a webhook widget after ‘on flow complete’ widget.
This functionality will be modified in the near future.
FAQs
What is a ‘response object’ ?