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.

Back to top


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:

1
Under “Input Data,” add “payload” → and set that equal to the raw hook from steps 1-5 in the "Creating a new zap" section above
2
As the first line of code → add const payload = JSON.parse(inputData.payload);
3
Now, we’ll pull out the answers to each question. The exact code here will depend on the question IDs in your survey, which you can find in the test respons(es) recovered in step 13. Here’s some example code for a survey with 8 questions:

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.

4
In the last line in the code (replacing the default output definition that Zapier provides), add a comma separated list of the variables you created to hold each answer
5
Don’t forget to wrap this output in [{ }] and include the ; at the end, as shown above!
There you have it! Test and save that action step, and you’ll see the values for each answer assigned to the variables you’ve created. You can now use those answers in later steps in yoddur zap.

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!

Back to top


Still need help? Contact Us Contact Us