The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "Trivia AI Mode Generator",
"nodes": [
{
"parameters": {
"path": "trivia-ai-generator",
"responseMode": "responseNode",
"options": {}
},
"id": "webhook-trigger",
"name": "Webhook Trigger",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1.1,
"position": [
200,
300
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.z.ai/v1/chat/completions",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer {{$credentials.apiKey}}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"model\": \"zai-pro\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are an expert trivia game creator. Generate engaging, educational, and accurate trivia questions. Ensure questions are factually correct and properly formatted.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Generate {{ $json.numQuestions }} trivia questions about {{ $json.topic }} at {{ $json.difficulty }} difficulty level.\\n\\nRequirements:\\n1. Include a mix of question types: multiple-choice, true-false, and text-input\\n2. For multiple-choice: Provide 4 options (a, b, c, d)\\n3. For text-input: Provide acceptable alternative answers\\n4. Each question must have a clear, concise explanation\\n5. Questions should cover different aspects of the topic\\n6. Ensure difficulty is appropriate for the specified level\\n\\nReturn response in this exact JSON format:\\n{\\n \\\"topic\\\": \\\"{{ $json.topic }}\\\",\\n \\\"difficulty\\\": \\\"{{ $json.difficulty }}\\\",\\n \\\"questions\\\": [\\n {\\n \\\"id\\\": \\\"1\\\",\\n \\\"type\\\": \\\"multiple-choice\\\",\\n \\\"question\\\": \\\"Your question here\\\",\\n \\\"correctAnswer\\\": \\\"a\\\",\\n \\\"options\\\": [\\n {\\\"id\\\": \\\"a\\\", \\\"text\\\": \\\"Option A\\\"},\\n {\\\"id\\\": \\\"b\\\", \\\"text\\\": \\\"Option B\\\"},\\n {\\\"id\\\": \\\"c\\\", \\\"text\\\": \\\"Option C\\\"},\\n {\\\"id\\\": \\\"d\\\", \\\"text\\\": \\\"Option D\\\"}\\n ],\\n \\\"explanation\\\": \\\"Clear explanation here\\\"\\n }\\n ],\\n \\\"total_questions\\\": {{ $json.numQuestions }}\\n}\"\n }\n ],\n \"temperature\": 0.7,\n \"max_tokens\": 4000\n}"
},
"id": "z-ai-llm",
"name": "Z.AI LLM - Generate Questions",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
500,
300
]
},
{
"parameters": {
"jsCode": "const response = items[0].json;\n\n// Parse the AI response\nlet parsedData;\ntry {\n const content = response.choices[0].message.content;\n // Extract JSON from the response (in case there's extra text)\n const jsonMatch = content.match(/\\{[\\s\\S]*\\}/);\n if (jsonMatch) {\n parsedData = JSON.parse(jsonMatch[0]);\n } else {\n parsedData = JSON.parse(content);\n }\n} catch (error) {\n return [{\n json: {\n error: 'Failed to parse AI response',\n details: error.message,\n rawResponse: response\n }\n }];\n}\n\n// Generate categories based on topic\nconst categories = [\n {\n name: 'General',\n description: `General knowledge about ${parsedData.topic}`,\n subcategories: ['Basics', 'Key Facts', 'Overview']\n },\n {\n name: 'Deep Dive',\n description: `In-depth questions about ${parsedData.topic}`,\n subcategories: ['Advanced', 'Specific Topics', 'Details']\n }\n];\n\n// Format questions\nconst formattedQuestions = parsedData.questions.map((q, index) => ({\n id: q.id || (index + 1).toString(),\n type: q.type,\n question: q.question,\n correctAnswer: q.correctAnswer,\n explanation: q.explanation,\n options: q.options,\n acceptableAnswers: q.acceptableAnswers\n}));\n\n// Return structured game data\nreturn [{\n json: {\n topic: parsedData.topic || items[0].json.topic,\n difficulty: parsedData.difficulty || items[0].json.difficulty,\n categories: categories,\n questions: formattedQuestions,\n total_questions: formattedQuestions.length,\n difficulty_distribution: {\n [items[0].json.difficulty]: formattedQuestions.length\n }\n }\n}];"
},
"id": "format-response",
"name": "Format Response",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
800,
300
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ $json }}"
},
"id": "respond-to-webhook",
"name": "Respond to Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
1100,
300
]
}
],
"connections": {
"Webhook Trigger": {
"main": [
[
{
"node": "Z.AI LLM - Generate Questions",
"type": "main",
"index": 0
}
]
]
},
"Z.AI LLM - Generate Questions": {
"main": [
[
{
"node": "Format Response",
"type": "main",
"index": 0
}
]
]
},
"Format Response": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"tags": [],
"triggerCount": 1,
"updatedAt": "2024-01-22T12:00:00.000Z",
"versionId": "1"
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Trivia AI Mode Generator. Uses httpRequest. Webhook trigger; 4 nodes.
Source: https://github.com/Abdullah-Alholiel/TriviaAI/blob/f94c9046e55d10e003afa19734721e22a737775a/n8n-workflows/trivia-ai-generator.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This n8n template provides enterprise-level version control for your workflows using GitHub integration. Stop losing hours to broken workflows and manual exports – get proper commit history, visual di
This flow creates dummy files for every item added in your *Arrs (Radarr/Sonarr) with the tag .
eek-Go v2 (Batch-Then-Review). Uses httpRequest. Webhook trigger; 75 nodes.
This workflow receives webhook requests from a content calendar and uses the X API v2 to publish text posts, threads, image/video posts, and polls, as well as delete existing posts and run a credentia
This workflow acts as a central API gateway for all technical indicator agents in the Binance Spot Market Quant AI system. It listens for incoming webhook requests and dynamically routes them to the c