Webhooks
What is a Webhook?
A webhook in web development is a method of augmenting or altering the behavior of a web application with custom callbacks. These callbacks may be maintained and managed by third-party users and developers who may not necessarily be affiliated with the originating application.
QuestionPro supports both incoming and outgoing webhooks. Webhooks can be invoked before the survey starts, during the survey (before or after a question), or after the survey is completed.
What are incoming webhooks?
Incoming Webhooks are a simple way to fetch the data from external sources into your survey.
What are outgoing webhooks?
Outgoing webhooks can be used to send survey data to an external source. They use standard HTTP requests with a JSON payload.
How to set up webhooks?
To create a webhook:
- Choose the survey you want to setup the webhook for.
- Go to: Integrations >> Webhooks
- Click on the Add New Webhook button.
- Enter a description for your webhook and click on the Create Webhook button.
Once you are in the configuration page, choose when the webhook should be invoked by selecting the trigger event.
- A webhook can be invoked before the survey, after a question, after a page in the survey, after the save and continue button in the survey, and after the survey.
Note: For the 'After Question' trigger event, the webhook triggers at the end of the survey, although sending only data captured up to that question and not the full response. If you require the webhook to be triggered immediately 'After question', you must manually add a page break after the question.
- If you choose to trigger the webhook after the survey, you can also configure the conditions based on which the webhook should be triggered.
- Configure the conditions (if any) and click Next.
After choosing the trigger condition, provide the data required for the API call:
- Method: The HTTP method used for making the call.
- API URL: The endpoint URL for making an API call.
- Authorization type: Choose the authorization type and add credentials if required. You can also choose to add the credentials either to the header or parameters as required by the external source.
- Request Header: HTTP header fields which are components of the header section of the request.
- Request JSON: Payload data required by the API. You can also use the Insert Response button to insert the response in the Request JSON.
- Once you fill in the above details, click on the Test Run button to check if you are getting the desired output. If not, please retry after modifying the API request data. Once you are satisfied with the output, click Next.
The Data Mapping step is primarily required for incoming webhooks. You can save the data retrieved from the external source by mapping it to variables. Please note that these variables are different from the custom variables that are stored with the respondent's response. If you don't want to map data to the variables you can proceed and click
Save.
- You can map the data to variables by assigning individual JSON keys to specific variables. You can add and delete the variables as and when needed.
- Once the mapping is set, the collected data can be displayed in the survey using the following code: ${code}.
Finally, once you want your webhook live, enable the toggle to make the webhook active.
How to provide data for an outgoing webhook?
In case of outgoing webhooks you can send the data collected in custom variables to an external web service by adding the custom variables on the Request JSON.
Data Replacement Variables
To fetch the Custom Variable data, you can use the following tags for the corresponding Custom Variables in the request JSON:
Custom Variable 1: ${custom1}
Custom Variable 2: ${custom2}
Custom Variable 3: ${custom3}
Custom Variable 4: ${custom4}
Custom Variable 5: ${custom5}
Custom Variable N: ${customN}
How would I know whether the Webhook was executed successfully or failed?
QuestionPro provides a logging facility for each webhook where you can check the API details called by that webhook along with the payload and the response from the endpoint. To access the logs, go to a particular webhook and click on Logs, where you can view the requests made by that webhook and on clicking on the ID you can check the details of any specific call.
Also, if the outgoing call failed to push the data for an
After Survey event, a Manual Retry button will be available next to any failed API calls, which you can click at any time to resend the data to the API endpoint. You can also select multiple webhooks and retry in bulk. Other trigger events are not supported for retry mechanism.
Are the conditions supported on all trigger events?
No. Currently conditions are only supported for After Survey event.
What are the question types supported under conditions?
We currently support Select one, Select many, Drop-down menu, and Single row text.
What are the question types supported under conditions?
We currently support Select one, Select many, Drop-down menu, and Single row text.
How can I display the variable data within the survey?
If you want to display the value of a variable like ${customN} in the survey, you can easily use ${code}. Alternatively you can add the same survey-level custom variable mapping that you configured in the data mapping section of the webhook or add a page break before that question.
Thank you for submitting feedback.