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 on 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 cURL:

<?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 a few times before failing.

Did this answer your question?