Where do you want your form data to be sent? Get every submission sent straight to a compatible web app or URL as soon as it’s submitted with Webhooks.
In general terms, a Webhook is simply a notification sent over the web, which is triggered automatically whenever a specific event occurs.
In this case, the event is a new form submission. Whenever a new form submission comes in, a notification containing the response data is immediately sent to your chosen destination — the Webhook URL which you set in the configuration page.
Webhook notifications are sent via HTTP POST
request, and the request body (containing the response data) is in JSON
format.
If you need to make a test URL – to collect test submissions – you can do this at https://requestbin.net.
- Open Workflows page of your form
- Click Add a webhook:
- Enter a Destination URL. (This is where we will make HTTP POST requests to):
- Now click Save webhook, and you’ll be taken back to the webhooks tab. By default your new webhook will be set to OFF until you turn it on by clicking the toggle.
POST https://your-webhook.com/form-submission HTTP/1.1
Content-Type: application/json
User-Agent: Formsure-Webhook/1.0
X-Formsure-Payload-Signature: a9691345e11a9f33f2c8d81500c2a7773a746cb0
{
"submissionId": "5ff9da9aeb0d450xxxxxx",
"submission": [
{
"question": "When you first used the product, what was your overall impression of it?",
"answer": 5,
"type": "number",
"id": "5Dxxx",
},
{
"question": "What do you like most about it?",
"answer": "When you first used the product, what was your overall impression of it?\n",
"type": "long",
"id": "Cnxxx",
},
{
"question": "If you could buy the product today, would you?",
"answer": "No",
"type": "yesorno",
"id": "sZxxx",
}
],
"meta": {
"formId": "5ff28998c4b659820xxxxxx",
"formName": "Workflow automation",
"formSlug": "FXsPbpvsxx",
"createdAt": "2021-01-09T16:35:55.048Z"
}
}
You will get a header named X-Formsure-Payload-Signature
with HMAC
signed version of your payload with the Secret
you have given in the webhook add form in the Formsure dashboard.
Nodejs example code for verifying the request payload is as follows
'use strict'
const crypto = require('crypto')
let payloadSig = crypto
.createHmac('sha1', WEBHOOK_SECRET)
.update(REQUEST.DATA)
.digest('hex')
let isValidSig =
payloadSig === REQUEST.HEADERS['x-formsure-payload-signature']
? 'Valid'
: 'Not valid'
console.log(isValidSig)
We will retry a Webhook maximum of 3 times, if the request end up a non 2xx
response from your server.
We also have a timeout of 3000ms
if your web server failed to reply.