Skip to main content

Hi Guys,

I created a 10 questions multiple choice quiz in Zapier, based on ChatGPT API, and now would like to directly automate the process and instead of copying and pasting it one by one, would like to integrate it directly by automating the process, in which I use Zapier.

Any way I can make it to use the output of ChatGPT API to send it directly and format the questions and answers into Typeform quiz template?

Your help is highly appreciated!

Hi @Rafa1610 

This is a cool workflow.

I think you can ask ChatGPT to format the payload to fit the expected format from Typeform API.
And then call Typeform API to create form https://www.typeform.com/developers/create/reference/create-form/

And it should create the form for you.

Is this something you’ve tried already?


Hi @picsoung ,

Thanks a lot for your response and support.

What do u mean? is it something I have to instruct iChatGPT API in the prompt stage? I am not a technical person so if there is some code required I wont be able to do it.

Can you elaborate a bit more about it?

This is the prompt I gave to ChatGPT API:

You are an expert quiz creator specializing in creating multiple-choice questions from transcripts. Your task is to analyze the following transcript and generate 10 challenging multiple-choice questions in English. Each question should have 4 answer options, with only ONE correct answer clearly indicated with an asterisk (*).

 **Guidelines:** 1. **Question Format:** Phrase questions clearly and concisely. 2. **Answer Options:** Ensure answer options are plausible and relevant to the transcript. 3. **Difficulty:** Craft questions that require a deep understanding of the transcript's content. 4. **Correct Answer:** Mark the single correct answer for each question with an asterisk (*). 5. **Output Format:** Present the quiz in the following easy-to-copy format: tQuestion 1] a. aOption A] b. bOption B] c. cOption C] d. dOption D]* ]Question 2] a. aOption A] b. bOption B]* c. cOption C] d. dOption D] ...and so on for all 10 questions. **Please adhere strictly to these guidelines and generate exactly 10 questions.**

And he provided the questions as followed:

 

Reply

content

>Question 1] What is the primary purpose of dental implants according to the speaker? a. To improve speech and pronunciation b. To provide functional and aesthetic oral rehabilitation* c. To enhance facial appearance only d. To prevent tooth decay cQuestion 2] Which material is most commonly used for dental implants? a. Stainless steel b. Titanium* c. Aluminum d. Gold oQuestion 3] What is grade 23 titanium alloy known for compared to grade 4 and grade 5? a. Higher nitrogen content b. Lower flexibility c. Extra low interstitial elements* d. Higher iron content  etc…..

So from here, how can I automate it and send it directly to Typeform via Zapier to create the quiz?

Thanks again 


Nice, I added the following instruction to the prompt and it seems to work fine:
 

Return the result as JSON file. The JSON should follow Typeform API standard to create a new form.Return a compact version of the JSON, no formatting, no explanation text.
Multiple choices question have the following shape:
{
"title": "QUESTION_TITLE",
"ref": "UNIQUE SLUG DESCRIBING THE QUESTION",
"properties": {
"choices":
{
"ref": "UNIQUE SLUG IDENTIFYING THE CHOICE",
"label": "LABEL OF THE CHOICE"
}
]
},
"validations": {
"required": true
},
"type": "multiple_choice"
}
}

You can then parse the returned JSON and push it to Typeform API.

In Zapier you probably want to use the “extract structured data” action for OpenAI, so it’s more consistent it what it’s returning. It’s using function calling


Perfect!!! Working… thx so much!!! So much appreciated 


@picsoung Still need your help though, explained as below :

have 4 steps as in the screenshot


 

Steps Completed:

  1. ChatGPT API Prompt: I created a prompt to generate multiple-choice questions from transcripts. The prompt ensures that the correct answer is randomly placed among the options.

    Prompt Example:

    plaintext

    Copy code

    You are an expert quiz creator specializing in creating multiple-choice questions in a Typeform-compatible JSON format from transcripts. Your task is to analyze the following transcript and generate quiz content, including a name field and 10 challenging multiple-choice questions in English. **Transcript:** {{240955785__transcript}} **Guidelines:** 1. **Name Field:** Include the following object at the beginning of your JSON output: ```json { "type": "short_text", "title": "What is your name?", "validations": { "required": true } } ``` 2. **Question Format:** Phrase questions clearly and concisely within the `"title"` field of the JSON object. 3. **Answer Options:** * Ensure answer options are plausible and relevant to the transcript. * Place them within the `"choices"` array of the JSON object, with the **correct answer randomly placed among the options**. 4. **Correct Answer Identification:** Include a separate JSON structure at the end of your response that lists the correct answer for each question. 5. **Difficulty:** Craft questions that require a deep understanding of the transcript's content. 6. **Output Format:** Your entire response must be a valid JSON array containing **only** the following structure for each question, with no additional text or explanations: ```json { "type": "multiple_choice", "title": " Question Text]", "properties": { "choices": : {"label": " Answer Option]"}, {"label": " Answer Option]"}, {"label": " Answer Option]"}, {"label": " Answer Option]"} ], "randomize": false, "allow_other_choice": false }, "validations": { "required": true } }

     

    *******UP TO THIS STAGE ( before adding *Correct Answers*) when tested, everything worked find, but after adding the part below it breaks

  2. Correct Answers: At the end of your response, include the correct answers in the following format:

    json

     

    { "correct_answers": s {"question": ""Question Text]", "correct_answer": ""Correct Answer]"}, ... ] }

    Output Count: Generate exactly 10 question objects in the above JSON format.

    No Additional Text: Do not include any additional text, explanations, code blocks (```), or introductory statements. Your entire response must be the JSON array and the correct answers object only.

    Please adhere strictly to these guidelines.


     

  3. JavaScript in Code by Zapier: I used JavaScript in Zapier to process the JSON output from ChatGPT and format it for Typeform.

    Current JavaScript:

    // Get the output from ChatGPT const chatGPToutput = inputDatat'Conversation in ChatGPT']G'Reply']; if (!chatGPToutput) { console.error("Missing or invalid input data from ChatGPT:", inputData); return { error: "Missing or invalid input data from ChatGPT" }; } // Parse the JSON string into a JavaScript object let parsedOutput; try { parsedOutput = JSON.parse(chatGPToutput); } catch (error) { console.error("Error parsing JSON from ChatGPT:", error); return { error: "Error parsing JSON from ChatGPT" }; } // Check if the last element is the correct answers object let correctAnswers = r]; if (parsedOutput.length && parsedOutputuparsedOutput.length - 1].correct_answers) { correctAnswers = parsedOutput.pop().correct_answers; } // Construct the final output for Typeform const outputForTypeform = { fields: parsedOutput, correct_answers: correctAnswers }; // Log final output for debugging console.log("Output for Typeform:", outputForTypeform); // Return the formatted data return { typeformFields: JSON.stringify(outputForTypeform.fields), correctAnswers: JSON.stringify(outputForTypeform.correct_answers) };

  4. API Request to Typeform: I then sent the formatted data to Typeform to create the quiz.

    using this :
     

    { "title": "Quiz from Transcript", "fields":

     

     3. Typeform Fields: {"type":"multi…quired":true}}] }

     

    Current Issues:

  5. Correct Answers: When adding the correct answers at the end of the JSON output, the process fails. I need guidance on properly including correct answers in the JSON output without breaking the format.

    Example of Failed JSON Structure:

    json

    Copy code

    p { "type": "multiple_choice", "title": "What is the most common material used for dental implants?", "properties": { "choices": {"label": "Titanium"}, {"label": "Gold"}, {"label": "Silver"}, {"label": "Stainless Steel"} ], "randomize": false, "allow_other_choice": false }, "validations": { "required": true } }, ... { "correct_answers": t {"question": "What is the most common material used for dental implants?", "correct_answer": "Titanium"}, ... ] } ]



Also need help how to add
Title for Quiz:
How can we structure the ChatGPT prompt to include a title for the entire quiz in the JSON output?

Custom Styling: How can we write the ChatGPT prompt to generate a quiz with specific colors (e.g., red on a white background) and font preferences?

Any help or advice on these issues would be greatly appreciated. Thank you!


That sounds like a great idea for streamlining your quiz creation process! With Zapier, you can automate the integration between ChatGPT API and Typeform to directly format the questions and answers into a quiz template. You'll likely need to configure a Zap that triggers when you generate the quiz questions using ChatGPT API and then sends the formatted questions and answers to Typeform. You might need to use a combination of Zapier's built-in tools and custom formatting to ensure the data is transferred correctly. Once set up, this automation can save you a lot of time and effort. Good luck with your automation project!


@abuislam  thank you for your comment. Yes, that’s actually what I did, now my question is how to add/find the correct answers within the quiz, all other steps already managed to complete.


Great progress @Rafa1610 

The correct answer in typeform is defined via Logic. Not in the settings of the multiple choice.

Understanding the structure of the logic array is as simple as creating a manual example. You'll see it clearly when calling api.typeform.com/forms/{form_id} in your browser.

Using logic in the typeform UI, you can create logic to add +1 to a variable score if the response is correct.

My suggestion is then to tell ChatGPT to reproduce the structure of this logic array for all correct answers.
Logic relies on field and option ref, so your first prompt has to make sure ref are unique and properly defined.


@picsoung sorry for the clarification request, yet I am not a developer and very basic coding experience, so need your help.

Here “ create logic to add +1 to a variable score if the response is correct”’ you mean I need to adjust MY ChatGPT API prompt? 

tell ChatGPT to write the prompt JSON strucutre to create logic to add +1 to a variable score if the response is correct and then to reproduce the same structure logic for all the correct answers?

is this what you mean?

Anyway you can provide just a sample example so I know what to look for and make sure it has it right when it creates it for me?

Thank you once again


Reply