Webhooks
Customer Data Platform
What is a Webhook?
A webhook is an HTTP request triggered by an event in a source system (in this case, Sprig) and sent to a destination system with a payload of data. Webhook requests are automatically sent out when their event is triggered in Sprig.
What Webhook Events Does Sprig Support?
Sprig supports webhooks triggered by the following events:
- Answer submitted - a user submits an answer to a specific question in a study.
- Study submitted - a user completes and submits a study.
- Study sent - Sprig has triggered and delivered a study.
- Study seen - a user has viewed a study.
- Theme identified - Sprig identifies a new theme associated with a study.
- Study status changed - a study becomes paused, completed, etc.
Currently, Sprig supports Bearer Tokens for webhook authentication. The webhook is sent as an HTTP POST request to the specified endpoint, in JSON format.
You can have different Webhook configurations for each Product and Environment.
Configuring Webhooks in Sprig
To receive webhooks from Sprig to a destination system:
- Navigate to Integrations > Destinations > Webhook and click Configure.
- Select the Production or Development environment.
- Enter the destination system's Payload URL.
- Enter the Bearer Token API Secret (Bearer_is automatically prepended to the _authorization: header field).
- Check which events in Sprig you want to trigger a Webhook request.
- Click Test Webhook to see if the request posts to the destination system.
- Click Save to save the configuration.
Example cURL equivalent of the Test Webhook request
curl -X 'POST' 'https://webhook.site/96255364-4d38-4be5-a6e4-795881dc5b6b?' -H 'connection: close' -H 'host: webhook.site' -H 'content-length: 92' -H 'user-agent: axios/0.21.2' -H 'authorization: Bearer APIsecret' -H 'content-type: application/json' -H 'accept: application/json, text/plain, */*' -d $'{"id":1,"environmentId":"abc123","surveyId":1,"surveyName":"TEST_SURVEY","eventType":"TEST"}'
Example Payloads for Each Event
Answer Submitted
Property | Type | Description |
---|---|---|
id | Integer | Webhook ID |
environmentId | String | Internal Environment ID |
createdAt | Datetime | Creation date and time |
responseGroupUid | String | UUID for the Group of Responses sent by a User |
response | String | Integer | List | Object | Response Text or Option to the Question. This can be an Integer, String, or List, or Object. |
surveyId | Integer | Unique Survey ID |
surveyName | String | Survey name/title |
question | String | Question wording |
questionType | String | Question type (open, nps, multipleselect, matrix, etc.) |
visitorId | String | Visitor ID |
oldVisitorId | integer | Legacy Vistor ID |
userId | String | User ID |
anonymousId | String | Segment data not used by Sprig |
triggeringEvent | String | Event name of event that initiated study for visitor |
timestamp | Timestamp | Time of response in UTC unix milliseconds epoch |
String | Email address of the user | |
attributes | map | A key-value map of custom attributes you can set on the user |
href | String | URL where study was activated if web study |
os | String | Operating system of device if collected from SDK |
browser | String | Browser that study was activated if web study |
userAgent | String | Information about platform visitor used if collected from SDK |
customMetadata | Object | A key-value map of custom metadata you can set on the url of link studies, empty map otherwise |
selectedIndexes | Integer | List | This field can either be an Integer of a List of Integers, depending on the question type. If the question type is "multiplechoice", this field will be an Integer. If the question type is "multipleselect", this field will be a List of Integers. |
eventType | String | The type of event that triggers the webhook |
eventName | String | Name of Event under the Event Type |
eventProperties | Object | A key-value map of event properties that were set to target this visitor, empty map otherwise. |
JSON example
{
"id": 234211,
"environmentId": "ENVIRONMENT_ID",
"createdAt": "2022-08-16T17:57:33.603Z",
"responseGroupUid": "3305ee6c-15f4-4a55-a478-2c5f4adb9798",
"response": "[\"SUV\"]",
"surveyId": 11220,
"surveyName": "What Is Your Preferred Transportation Method?",
"question": "What models of car do you prefer?",
"questionType": "multipleselect",
"visitorId": "ba050493-0292-4099-9262-8e18c7406e81",
"oldVisitorId": 0,
"userId": "2603",
"anonymousId": null,
"triggeringEvent": exit_rental_booking,
"timestamp": 1660672653789,
"email": "[email protected]",
"attributes": {
"plan": "Enterprise",
"role": "admin"
},
"href": "https://retails.cars.com/surveys/11220",
"os": "Mac OS X",
"browser": "Chrome",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
"customMetadata": "{}",
"selectedIndexes": "[2]",
"eventType": "survey_response",
"eventName": "surveyResponse",
"eventProperties": {
"string-event-property": "string"
}
}
Theme Identified
Property | Type | Description |
---|---|---|
themename | string | Theme Name |
updatedAt | date/time | date and time |
productId | string | ID of the product |
environmentId | string | Environment ID |
questionText | string | Question body text |
questionType | string | Type of Question |
JSON example
{
"themename": "testthemeNew8",
"updatedAt": "2022-02-22T19:31:05.089Z",
"productName": "iOS Test Account",
"productId": 20110,
"environmentId": "RpOLQFy3T",
"questionText": "The iOS Test Account team has a video question for you",
"questionType": "videovoice"
}
Study Submitted
Property | Type | Description |
---|---|---|
visitorId | string | unique ID of the survey respondent |
platform | string | Study delivery method |
surveyId | string | ID of the survey |
timestamp | Time | UTC timestamp of when survey was completed |
environmentId | string | Enironment ID |
eventDate | date / time | Datestamp of when survey was completed in UTC |
recordType | string | Will always be Survey |
action | string | will always be completed |
responseGroupUid | integer | UUID of Response Group (used for debugging purposes) |
productName | string | Name of Sprig Product configured by the Customer |
productId | integer | Internal Numeric Id of Product (used for debugging) |
questions | string | All the questions in the survey with responses if available |
question | string | Question instance |
response | string | Response to the question |
order | string | order of question in the survey |
eventType | string | Event type |
JSON example
{
"visitorId": "2341e79f-9b73-49d0-884d-d1f168aa9511",
"platform": "link",
"surveyId": 8529,
"timestamp": 1645562173173,
"environmentId": "RpOLQFy3T",
"eventDate": "2022-02-22T20:36:13.011Z",
"recordType": "survey",
"action": "completed",
"responseGroupUid": "91355295-f316-40f3-85e5-dec3e7b2ec72",
"productName": "iOS Test Account",
"productId": 20110,
"eventName": "surveySubmitted",
"questions": [
{
"question": "I am testing something",
"response": 3,
"order": 1
}
],
"eventType": "product_message"
}
Study Status Changed
Property | Type | Description |
---|---|---|
surveyId | string | unique ID of the survey (used for debugging) |
surveyName | string | Name of the Survey |
oldStatus | string | Old status of the survey |
status | string | Updated status of the survey (possible values are "NEW", "IN_PROGRESS", "PAUSED", "COMPLETED") |
environmentId | string | Environment ID |
productName | string | Name of Sprig Product configured by the Customer |
productId | integer | Internal Numeric Id of Product (used for debugging) |
eventName | string | Name of Event under the Event Type |
questions | string | All the questions in the survey |
question | string | Question text |
questionTypeId | integer | Type of question |
eventType | string | Event type (will always be product message in this json object) |
JSON example
{
"surveyId": 77694,
"surveyName": "Test Survey for Webhooks",
"oldStatus": "NEW",
"status": "IN_PROGRESS",
"environmentId": "RpOLQFy3T",
"productName": "iOS Test Account",
"productId": 20110,
"eventName": "surveyStatusChange",
"questions": [
{
"question": "What is one plus one?",
"questionTypeId": "open"
},
{
"question": "How likely are you to recommend iOS Test Account to a friend or colleague?",
"questionTypeId": "nps"
}
],
"eventType": "product_message"
}
Study Sent
Property | Type | Description |
---|---|---|
isUserInterviews | boolean | True if Link Study with User Interviews integration enabled |
platform | string | Study delivery method |
timestamp | time | UTC timestamp of when survey was completed |
recordType | string | record type will always be "survey" |
eventDate | date/time | Datestamp of when survey was completed in UTC |
visitorId | string | unique ID of the survey respondent |
environmentId | string | Environment ID |
surveyId | integer | survey ID |
action | string | will always be completed |
responseGroupUid | integer | UUID of Response Group (used for debugging purposes) |
productName | string | Name of Sprig Product configured by the Customer |
productId | integer | Internal Numeric Id of Product (used for debugging) |
eventName | string | Name of Event under the Event Type |
triggeringEvent | string | Event name of event that initiated study for visitor |
surveyName | string | Name of the Sprig Study |
attributes | object | Object of attributes set on the visitor if available |
string | Email address if set | |
oldVisitorId | null | Deprecated |
userId | string | User ID if set |
anonymousId | string | Segment Anonymous ID if set |
customMetadata | object | Custom metadata if set for Link Study response |
eventType | string | Event type |
JSON example
{
"isUserInterviews": false,
"platform": "web",
"timestamp": 1711987848970,
"recordType": "survey",
"eventDate": "2024-04-01T16:10:48.970Z",
"visitorId": "0209f2ad-27db-4080-bf8b-2fdae11a2649",
"environmentId": "",
"surveyId": 0,
"action": "seen",
"responseGroupUid": "38b1a6fe-13ed-477f-ab04-af53f9ecd499",
"productName": "Earl Test",
"productId": 0,
"teamId": 0,
"eventName": "studySeen",
"triggeringEvent": "sprig",
"surveyName": "Survey Test",
"attributes": {},
"email": "",
"oldVisitorId": null,
"userId": null,
"anonymousId": null,
"customMetadata": "{}",
"eventType": "product_message"
}
Study Seen
Property | Type | Description |
---|---|---|
visitorId | string | unique ID of the survey respondent |
timestamp | Time | UTC timestamp of when survey was completed |
environmentId | string | Environment ID |
platform | string | Study delivery method |
recordType | string | record type will always be "survey" |
eventDate | date/time | Datestamp of when survey was completed in UTC |
surveyId | integer | Will always be Survey |
action | string | be completed ID |
responseGroupUid | integer | UUID of Response Group (used for debugging purposes) |
productName | string | Name of Sprig Product configured by the Customer |
productId | integer | Internal Numeric Id of Product (used for debugging) |
eventName | string | Name of Event under the Event Type |
triggeringEvent | string | Event name of event that initiated study for visitor |
surveyName | string | Name of the Sprig Study |
attributes | object | Object of attributes set on the visitor if available |
string | Email address if set | |
oldVisitorId | null | Deprecated |
userId | string | User ID if set |
anonymousId | string | Segment Anonymous ID if set |
customMetadata | object | Custom metadata if set for Link Study response |
eventType | string | Event type |
JSON example
{
"visitorId": "0209f2ad-27db-4080-bf8b-2fdae11a2649",
"timestamp": 1711987848665,
"environmentId": "",
"platform": "web",
"recordType": "survey",
"eventDate": "2024-04-01T16:10:48.665Z",
"surveyId": 0,
"action": "sent",
"responseGroupUid": "38b1a6fe-13ed-477f-ab04-af53f9ecd499",
"productName": "Demo Product",
"productId": 0,
"teamId": 0,
"eventName": "studySent",
"triggeringEvent": "studyEventTrigger",
"surveyName": "Survey Test",
"attributes": {},
"email": "",
"oldVisitorId": null,
"userId": null,
"anonymousId": null,
"customMetadata": "{}",
"eventType": "product_message"
}
Updated 8 months ago