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 | The unique identifier of the survey. |
survey_name | The name of the survey. |
platform | The platform from which the survey was accessed. |
answer_group_id | The unique identifier of the answer group. If a survey has 5 questions, all responses can be grouped using answer_group_id. |
respondent_id | The unique identifier of the respondent. |
country | The country code of the respondent. |
qna | The question and answer data. |
answered_at | The timestamp when the respondent answered the first question. |
webhook_id | The unique identifier of the webhook. |
webhook_name | The name of the webhook. |
event | The type of event. |
timestamp | The timestamp when the event was sent. |
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-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.