Webhooks
Integrate FeedbackSpark with your favourite tools using webhooks. Learn how to set up, customize, and manage webhooks for seamless data flow and enhanced productivity.
Introduction
The webhook lets you receive real-time notifications about specific events, such as when a respondent completes a survey. By configuring webhooks, you can integrate FeedbackSpark with your applications and automate workflows based on these events.
Events overview
Currently, FeedbackSpark supports the following events:
- Survey Completed: This event is triggered when a respondent completes a survey or closes a survey. So, if a respondent leaves the survey in between, it will not be triggered.
- Survey Answered: This event is triggered when a respondent submits a survey response. So, if your survey has 5 questions, it will be triggered 5 times.
Example payload for each event
Event object structure
Field | Description |
---|---|
survey_id | Unique identifier for the survey, auto-generated upon survey creation. |
survey_name | Display name of the survey as defined by the creator. |
platform | Distribution channel of the survey. Possible values: ‘email’, ‘web’, ‘link’, ‘mobile’. |
environment | Indicates whether the webhook is from sandbox or production environment. Possible values: ‘production’, ‘sandbox’. |
answer_group_id | Unique identifier that groups all responses from a single survey session. Used to correlate multi-question responses. |
respondent_id | Unique identifier for the person answering the survey. Can be anonymous or linked to a user account. |
country | Two-letter ISO country code (e.g.,‘IN’) identifying respondent’s country. |
qna | JSON object containing question identifiers and their corresponding responses. |
rating_range | The scale of the rating question. Possible values: 3 (1-3), 5 (1-5), or 10 (0-10/NPS rating). |
rating_scale | Visual representation of the rating. Possible values: ‘numerical’, ‘emoji’, ‘star’. |
answered_at | Unix timestamp (seconds since epoch) when the first question was answered (e.g., 1719215272). |
webhook_id | Unique identifier for the webhook configuration that triggered this event. |
webhook_name | Display name of the webhook as defined in the webhook configuration. |
event | Type of webhook event that triggered this payload. |
timestamp | Unix timestamp (seconds since epoch) when the webhook event was generated (e.g., 1719215272). |
Secure your webhook.
To secure your integration, check that the request is coming from FeedbackSpark and that the data has not been tampered with. You can use the following methods:
Verify the signature
All payloads sent to your webhook will include an X-Spark-Signature
header. This header contains a signature generated using the HMAC algorithm with the SHA-256 hash function. The signature is generated using the webhook secret key and the event payload. You can verify the signature by generating a new one and comparing it with the signature in the X-Spark-Signature
header.
Prevent replay attacks
Each webhook includes an x-spark-request-timestamp
header, which represents the time the webhook was sent. To guard against replay attacks, verify that this timestamp is within an acceptable time window (e.g., 5 minutes) of the current time.
Example code to verify the timestamp in Python:
Retry behavior
If a webhook fails to deliver an event, FeedbackSpark will retry sending the event up to 3 times at an equal interval of 10 minutes. If the event is still not delivered after 3 retries, the event will be discarded.
Duplicate events
Webhooks may be delivered more than once. Ensure that your system can handle duplicate events. Use the webhook_id
to identify unique events.
Best practices
- Use HTTPS: Always use HTTPS to secure your webhook endpoint.
- Verify the signature: Verify the signature of the payload to ensure that the event is coming from FeedbackSpark.
- Validate the timestamp: Validate the timestamp to prevent replay attacks.
- Asynchronous processing: Process the webhook events asynchronously. A significant spike in events can overwhelm your system if processed synchronously.
- Roll secret key: Rotate your secret keys periodically to enhance security. Click reconfigure in webhook integration page to generate a new secret key.