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.
  • 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:

  1. Navigate to Connect > Destinations > Webhook and click Configure.
  2. Select the Production or Development environment.
  3. Enter the destination system's Payload URL.
  4. Enter the Bearer Token API Secret (Bearer is automatically prepended to the authorization: header field).
  5. Check which events in Sprig you want to trigger a Webhook request.
  6. Click Test Webhook to see if the request posts to the destination system.
  7. 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 'x-datadog-sampling-priority: 1' -H 'x-datadog-origin: rum' -H 'x-datadog-sampled: 1' -H 'x-datadog-parent-id: 1972977474278417943' -H 'x-datadog-trace-id: 2744865438758791698' -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

string

Webhook ID

environmentId

string

Internal Environment Id

createdAt

date/time

Creation date and time

responseGroupUid

String

UUID for the Group of Responses sent by a User

response

integer

Response Text or Option to the Question

surveyId

integer

Unique Survey ID

surveyName

string

Survey name/title

question

string

Question wording

questionType

string

Question type:

visitorId

string

Visitor ID

oldVisitorId

integer

Legacy Vistor ID

userId

string

User ID

email

string

Email address of the user

attributes

map

A key-value map of custom attributes you can set on the user

eventType

string

The type of event that triggers the webhook

eventName

string

Name of Event under the Event Type

productName

string

Product Name

productId

integer

Unique product ID

{
  "id": 175483,
  "environmentId": "RpOLQFy3T",
  "createdAt": "2022-02-04T17:45:56.340Z",
  "responseGroupUid": "490aa111-e4b1-41da-9025-afef7a35fbba",
  "response": "3",
  "surveyId": 4778,
  "surveyName": "Evaluate the User Experience",
  "question": "How easy to use is [insert product or feature]?",
  "questionType": "likert",
  "visitorId": "94d2d453-2867-4e3e-84b1-63da28fee14d",
  "oldVisitorId": 0,
  "userId": null,
  "email": null,
  "attributes": {},
  "eventType": "survey_response",
  "eventName": "surveyResponse",
  "productName": "iOS Test Account",
  "productId": 20110
}

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

{
  "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

Data / 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

{
  "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

Will always be surveyStatusChange with this JSON object

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)

{
  "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"
}