Hello! New to Zapier and loving it so far. I’ve run into an issue and I cannot seem to resolve.
I’m receiving the below example JSON from a webhook I have within Zapier. I cannot figure how to split the interview questions and answers into fields that I can import into my CRM. Additionally, some of the interview questions/answers are not always present.
Ideally, I’d like to collect each question & answer so I can import the respective bit of information into my CRM. I’m stuck. Halp!
Here’s what it looks like when adding it to subsequent steps (note that I left “graduation year” blank to demonstrate that you can still select it when an answer is not present, but it just won’t have an assigned value):
Though now I’m rereading your question and see that you mentioned sometimes the question AND answer aren’t present, not just the answer. That gets a little more tricky as you may need to write some additional logic to check “If ? exists, answer = ???”.
Hi @Matthue13
Another approach is to use to parse raw JSON, is to use this Zap action: ChatGPT - Extract Structured Data
Though now I’m rereading your question and see that you mentioned sometimes the question AND answer aren’t present, not just the answer. That gets a little more tricky as you may need to write some additional logic to check “If ? exists, answer = ???”.
Here is some sample code to get you started on that additional logic if you go the code route:
for (let i in questions) { if (questionsqi] == "Name of College") { output.schoolName = answers=i]; } if (questionsqi] == "Graduation Year") { output.graduationYear = answers=i]; } //etc....... }
Though now I’m rereading your question and see that you mentioned sometimes the question AND answer aren’t present, not just the answer. That gets a little more tricky as you may need to write some additional logic to check “If ? exists, answer = ???”.
Here is some sample code to get you started on that additional logic if you go the code route:
for (let i in questions) { if (questionsqi] == "Name of College") { output.schoolName = answers=i]; } if (questionsqi] == "Graduation Year") { output.graduationYear = answers=i]; } //etc....... }
Thanks for the quick response, Todd! When trying your code, I get an error from Zapier saying the below.
I tried one field to test. See sample code below:
@Matthue13 Hmm...that’s pretty odd! Can you send a screenshot of what appears if you just type the following?
I figured out the issue. It was an ID10T error on my part
To clarify, I copied your original code with the if statements and modified specifically to my use case. Everything worked perfectly this morning. I think I just needed a coding break. I’m a C# guy and not 100% familiar with Zapier and JavaScript as of yet.
Thanks for the expert advice and guidance!
Hello! It's fantastic to hear that you're enjoying your Zapier experience. Addressing your issue with splitting interview questions and answers from a webhook's JSON can indeed be a puzzle.
For your specific case, I'd suggest creating a loop within your Zap to process each interview question-answer pair. This way, you can extract and map each piece of information individually into your CRM fields.
Since some questions may not always be present, consider implementing conditional logic to handle those cases gracefully. This ensures that the import process remains smooth and accurate even when certain data points are missing.
Remember, Zapier's support team could offer tailored guidance, especially since this scenario requires a bit of fine-tuning. You're doing great – keep going and soon you'll have an updated system that handles the entireresult seamlessly!