I'm working on creating an automated quiz using Typeform, and integrating it with Zapier to dynamically generate questions and calculate the final score. I am not a developer and do not have coding experience, so I need guidance on setting up this integration properly.
Problem and Challenge
The main challenge is to:
- Automatically generate a Typeform quiz from a structured JSON output provided by ChatGPT ( already managed to add logic and calculate score, but it’s only displayed on the backend)
- Calculate and display the final score dynamically on the last page of the Thank You screen of the Typeform quiz.
Steps Taken and Progress So Far
-
Generating Quiz Questions:
- I used ChatGPT to generate a JSON structure containing the quiz questions and answers.
- The JSON was parsed and processed in a Code by Zapier step to format it appropriately for Typeform.
-
Setting Up Scoring Logic:
- Wrote JavaScript code in the Code by Zapier step to extract the questions, identify the correct answers, and generate scoring logic.
- The code correctly outputs the fields and scoring logic necessary for Typeform.
-
Displaying the Final Score:
- I configured the Typeform API to create a quiz form using the fields and scoring logic generated in Zapier.
- The final score is supposed to be displayed on the Thank You screen using the
{{var:score}}
placeholder.
Current Status
- The Code by Zapier step runs successfully and generates the required Typeform fields and scoring logic.
- However, when submitting the form, the final score does not display correctly on the Thank You screen. Instead, it shows the placeholder
{{var:score}}
without substituting the actual score, just the WORD score ( like in the screenshot)
Code Implementations
Code by Zapier Step (JavaScript Code)
javascript
Copy code
const chatGPToutput = inputDatat'Conversation in ChatGPT']; let typeformFields = d]; let scoringLogic = i]; let scoreVariable = "score"; try { typeformFields = JSON.parse(chatGPToutput); // Extract question references (excluding the name field) const questionRefs = typeformFields .filter(field => field.type === 'multiple_choice') .map(field => field.ref); // Generate scoring logic for each question scoringLogic = questionRefs.map(ref => ({ type: 'field', ref: ref, actions: o { action: 'add', details: { target: { type: 'variable', value: scoreVariable }, value: { type: 'constant', value: 1 } }, condition: { op: 'is', vars: a { type: 'field', value: ref }, { type: 'choice', value: typeformFields.find(field => field.ref === ref).properties.choices.find(choice => choice.ref === 'correct').ref } ] } } ] })); } catch (error) { console.error("Error parsing JSON from ChatGPT:", error); } return { typeformFields: JSON.stringify(typeformFields), scoringLogic: JSON.stringify(scoringLogic), scoreVariable: scoreVariable };
Typeform API Request Payload
json
Copy code
{ "title": "Quiz from Transcript", "variables": { "score": 0 }, "theme": { "href": "https://api.typeform.com/themes/dBADdiNW" }, "fields": {{241267617__typeformFields}}, "logic": {{241267617__scoringLogic}}, "thankyou_screens": e { "title": "Thank you!\nYour Final Score is\n{{var:score}}", "properties": { "show_button": true, "button_text": "Create a typeform", "button_mode": "default_redirect", "share_icons": true } } ] }
Specific Issues
- Despite the correct implementation of the scoring logic, the final score does not display on the Thank You screen.
- The
{{var:score}}
placeholder is not being replaced by the actual calculated score.
Request for Assistance
I am seeking help to:
- Ensure the final score is correctly calculated and displayed on the Thank You screen.
- Identify any missing steps or misconfigurations in the current setup.
Any guidance or suggestions from developers experienced with Typeform and Zapier integrations would be greatly appreciated:))) THANK YOU VERY MUCH
