Survey Webhook

Survey Webhook

The Survey Webhook feature can be used to execute a action on your server when a user completes a survey. You can use it for example to give rewards on you app, track a completed state, etc.

How to setup the Callback

To setup a callback navigate to Integrations and select "Webhooks".

  • Step 1 - Select the "My Webhooks" tab
  • Step 2 - Click "+ Webhook" Webhooks1
  • Step 3 - Provide a name for your webhook
  • Step 4 - Enter your server URL of your webhook
  • Step 5 - Add headers including authorization keys
  • Step 6 - Select surveys you wish to have this webhook apply to. By default the webhook will trigger from all surveys. If you wish for it to only trigger for certain surveys you can select these surveys at this step. Webhooks1

Details

Webhook Request

The webhook request is sent to your provided url as a POST call, containing the data as you can see in the next section.

POST your_provided_callback_url

Webhook Data

The webhook contains lots of useful data, such as survey details, user answers and user external id (which you can provide as the customer_id on you survey taking page).

You are able to change the format of this JSON payload from within the editor and click preview to see what the parsed JSON will look like. This can be helpful to make the JSON payload consistent with third party services which have expected property values.

By default the data looks like this:


$data = [
    'survey_uuid' => int, // Survey UUID - eg.: 1ecf9a3e-6c69-4c63-b254-0f32a88e7f61
    'survey_name' => string, // Survey Name - eg.: My coll survey
    'user_session_id' => int, // Unique user Session ID - eg.: 123
    'user_external_id' => string, // Your provided customer_id for the user, or an auto-generated one if none was provided - eg.: bc7239d8844e90cc0ae56ce02570eea5 (or you id format)
    'answers' => [
        [
            'question_id' => int, // Question unique internal ID - eg.: 123
            'question_hash' => string, // Question hash - unique within the survey - eg.: 6AcjaBedTE
            'question_type' => string, //  Question type - eg.: radio, checkbox, text, rating, ...
            'question_title' => string, // Question title - eg.: What's your favorite color?
            'answer' => string | string[], // User answer(s), if is a single response (eg. radio), will be an string, if multiple (eg. checkbox) will a a string array. - eg.: ['Blue', 'Red']
        ]
        ...
    ],
    'started_at' => string, // Moment the user started the survey - eg.: 2024-01-01T14:52:02Z
    'completed_at' => string, // Moment the user completed the survey - eg.: 2024-01-01T14:52:02Z

    // The below keys will only be available if a value is provided on the survey settings

    // Only if reward data was provided in the settings
    'reward' => [
        'name' => string, // Reward name - eg.: Coins
        'amount' => string, // Reward amount - eg.: '500'
    ],

    // Only if a complete extra json was provided in the settings
    // NOTE: the json it's returned as a string, remember to parse it on your side
    'complete_extra_json' => string, // Your custom JSON provided in the settings, eg.: '{"param": 123}'
];