All Collections
Integrations
How to Use Webhooks to Send Data to 3rd Party Applications
How to Use Webhooks to Send Data to 3rd Party Applications

An article explaining how to use webhooks to send data submitted in Opinion Stage widgets to a 3rd party application

Dima Mjakotnyj avatar
Written by Dima Mjakotnyj
Updated over a week ago

This article explains how to create your own webhook function. However, in many cases, you will want to simplify/speed up the process by using a mediator which will make the configuration as easy as clicking a few buttons. If you would like to use Zapier.com (one of the most popular ones) as your mediator, check out this article - How to use Zapier to send data to 1000's of applications

First, configure the webhook in the relevant widget (e.g., poll, quiz, survey, etc.) creation form:

  1. Edit the widget creation form.

  2. Go to the "Integration Settings" section.

  3. Set the "Enable custom webhook" checkbox and configure the URL you want the data to be sent to.

Once a user completes answering all the questions in the widget and gets a result, Opinion Stage will send the submitted data to the configured URL.

In what format is the data sent?

Opinion Stage sends the data via a POST request to the configured URL. The data is encoded as JSON key-value pairs in the request's body. Keys can be found on the webhook configuration page ("Webhook key"), and corresponding values are the actual data (e.g., answer to card) submitted to that key.

Example payload:

{
"widget-id": "c524d12e",
"question-bd5482ac-title": "How would you describe your style in the kitchen?",
"question-bd5482ac-answer": "Freestyle! I go with my gut and improvise",
"result-title": "Free Spirit",
"result-text": "You're ready for a food adventure, always seeking out the next hole-in-the-wall spot serving up the best next thing nobody has heard of yet. In the kitchen, you follow your instincts.",
"submitted-on": "2022-09-26T14:17:01Z",
"hosting-url": "https://example.com",
"os-utm-source": "twitter"
}

Examples:

To illustrate how the system sends webhook data, the following are some examples:

curl command-line utility:

curl --data '{"key": "value"}' -H 'Content-Type: application/json' -- https://acme.co/webhook

<?php
$url = 'https://acme.co/webhook';
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"example":"payload"}');

curl_exec($ch);

curl_close($ch);
?>

Best practices

  1. Use an HTTPS URL for webhooks, so the data is sent encrypted and secure.

  2. Verify the webhook URL is always accessible. Note that if data is sent to a URL that doesn't respond, Opinion Stage tries sending it a few times before failing.

Did this answer your question?