Zapier Integration for Surveys
In this article
Suggested next article: Surveys Webhooks.
About the Zapier integration
Zapier allows you to quickly and easily connect Delighted Surveys to thousands of other apps in automated workflows.
While there isn't yet a native integration connecting Delighted Surveys and Zapier, you can use the Webhooks by Zapier app to catch a Surveys Webhook when a response is received and trigger workflows throughout the rest of your tech stack.
If you're connecting Delighted Surveys with Zapier, we'd love to hear about it! Send a note to our team and let us know what your zap is doing.
Connecting a survey to Zapier
We recommend getting familiar with our Surveys Webhooks article before diving into the instructions below.
Creating a new zap
- 1
- In Zapier → create a new zap
- 2
- Choose “Webhooks by Zapier” → as the trigger event
- 3
- Choose “Catch Raw Hook” → as the event
- 4
- Press "Continue"
- 5
- "Copy" the Webhook URL that is provided
Adding your zap to Delighted surveys
- 1
- Head to Delighted Surveys → and click on your survey
- 2
- Choose the “Connections” tab
- 3
- If not already completed, enable Webhooks → and click “Add new event”
- 4
- Paste in the Webhook URL from Zapier (copied in step 5 above) → and choose “Save rule”
- 5
- Submit a response to your survey → answering every question
- Note: If you have logic in your survey, answer the survey as many times as it takes to follow each potential survey flow. (Don’t worry, we can delete these test responses later!)
- 6
- Wait 10 minutes after submitting your last response → this is the delay built into the Webhook!
Testing in Zapier
- 1
- Head back to Zapier → and click “Test" trigger
- 2
- Zapier should find all of the test responses that you submitted. Select one → and choose “Continue with selected record”
- 3
- Add a step to your zap
- 4
- Choose “Code by Zapier” as the action → and “Run Javascript” as the event → then press "Continue"
Setting up your code!
No matter your survey setup, setting up your code will follow this basic structure:
const payload = JSON.parse(inputData.payload);
const question1 = payload.event_data.answers.find(answer => answer.question_id === '1631').value.free_text;<br> const question2 = payload.event_data.answers.find(answer => answer.question_id === '1633').value.multiple_choice[0].option_text;<br> const question3 = payload.event_data.answers.find(answer => answer.question_id === '1632').value.free_text;<br> const question4 = payload.event_data.answers.find(answer => answer.question_id === '1634').value.multiple_choice[0].option_text;<br> const question5 = payload.event_data.answers.find(answer => answer.question_id === '1635').value.multiple_choice[0].option_text;<br> const question6 = payload.event_data.answers.find(answer => answer.question_id === '1636').value.free_text;<br> const question7 = payload.event_data.answers.find(answer => answer.question_id === '1637').value.free_text;<br> const question8 = payload.event_data.answers.find(answer => answer.question_id === '1638').value.free_text;
As you can see, you’ll want to update the question id for each line, as well as the end based on the question type. You can also decide to name the variables that you’re constructing something different than ‘question1,’ ‘question2,’ etc.
Warning: If you have logic in your survey, you’ll get an error if you try to run the above code on a response that didn’t see or answer one of the questions. In that case, you’ll need to either create paths to deal with these different survey flows, or add error handling to the code to set the value to null if no response is found. Reach out to the Concierge team with questions on this!