8
n8n 中文网amn8n.com

使用GPT-4生成考试试卷并通过邮件发送

高级

这是一个自动化工作流,包含 21 个节点。主要使用 Code, Html, Gmail, Merge, FormTrigger 等节点。 使用GPT-4生成考试试卷并通过邮件发送

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "VXI1oimqqgMIuyoW",
  "meta": {
    "instanceId": "b33f6c1147e225af41a854f1486c7ac242396bd8c6fdf975414cedf6f10acac6",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 GPT-4 生成考试试卷并通过邮件发送",
  "tags": [
    {
      "id": "FpgsQop46OJZvlVy",
      "name": "email delivery,",
      "createdAt": "2025-10-06T06:19:27.472Z",
      "updatedAt": "2025-10-06T06:19:27.472Z"
    },
    {
      "id": "jOrd4snJb09TgYlm",
      "name": "exam",
      "createdAt": "2025-10-03T18:11:52.921Z",
      "updatedAt": "2025-10-03T18:11:52.921Z"
    },
    {
      "id": "myoUDIKtA36WZV5o",
      "name": "questions",
      "createdAt": "2025-10-03T18:12:03.507Z",
      "updatedAt": "2025-10-03T18:12:03.507Z"
    },
    {
      "id": "sdVZxgD8cvoEmBne",
      "name": "question paper",
      "createdAt": "2025-10-03T18:12:18.509Z",
      "updatedAt": "2025-10-03T18:12:18.509Z"
    }
  ],
  "nodes": [
    {
      "id": "d52fb9c2-2115-4652-8e2e-52dede6bc99e",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -720,
        -500
      ],
      "webhookId": "ba5aac25-fcd2-491b-95d3-2ce73be663fa",
      "parameters": {
        "options": {},
        "formTitle": "Syllabus Submission",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Name of the subject with code"
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "syllabus for unit 1"
            },
            {
              "fieldLabel": "syllabus for unit 2"
            },
            {
              "fieldType": "email",
              "fieldLabel": "Enter your email to send the Exam Question Paper.",
              "placeholder": "You will receive the question paper link in the email.",
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "1747ae55-0145-491d-b06c-7d6fad1b6fb4",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        40,
        -940
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4-turbo-2024-04-09",
          "cachedResultName": "gpt-4-turbo-2024-04-09"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "44dFzrYE2Jum9ohO",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "db8b52b5-de1f-4346-a1e4-a2cd1505bb10",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -20,
        -460
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4-turbo",
          "cachedResultName": "gpt-4-turbo"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "44dFzrYE2Jum9ohO",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c3e9d1d5-46ca-42b4-807e-faa2cbc1c747",
      "name": "OpenAI聊天模型2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -20,
        100
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "44dFzrYE2Jum9ohO",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "647e3bc6-2672-4858-8cce-f2bc12f2ff4c",
      "name": "A 部分试卷生成代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "onError": "continueErrorOutput",
      "position": [
        140,
        -1260
      ],
      "parameters": {
        "text": "=You are a professor in a college assigned to create a question paper.\n\nTask\n\nCreate exactly 4 questions, each worth 13 marks:\n\nQuestions 1 and 2 from {{ $json['syllabus for unit 1'] }}\n\nQuestions 3 and 4 from {{ $json['syllabus for unit 2'] }}\n\nDo NOT include question numbers in the text. Return ONLY valid JSON with 4 items. Generate simple questions with 2 marks each, following Bloom’s Taxonomy levels — Remember and Understand.\n\nOutput Format\n\n{\n\"QuestionsA\": [\n\"Question from Unit 1 - 1\",\n\"Question from Unit 1 - 2\",\n\"Question from Unit 2 - 1\",\n\"Question from Unit 2 - 2\"\n]\n}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.8,
      "alwaysOutputData": false
    },
    {
      "id": "d8336bbc-ad6e-44db-9555-453a4f28de0a",
      "name": "C 部分试卷生成代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        180,
        -280
      ],
      "parameters": {
        "text": "=You are a professor in a college assigned to create a question paper for the syllabus.\n\nTask\n\nCreate 2 questions, each worth 14 marks, from the following syllabus: {{ $json['syllabus for unit 1'] }}.\n\nGenerate questions that align with Bloom’s Taxonomy levels — Analyze and Evaluate.\n\nOutput Format\n\nDisplay each question separately on a new line, one after another.\n\nOutput exactly 2 questions in total.\n\nDo not include question numbers in the output.\n\nReturn the output in valid JSON format as shown below:\n\n{\n  \"QuestionsC\": [\n    \"string (question from Unit 1 - 1)\",\n    \"string (question from Unit 1 - 2)\"\n  ]\n}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.8
    },
    {
      "id": "ed68e227-24b1-48d0-879b-5a5db0476399",
      "name": "结构化输出解析器2",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        440,
        60
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\n\t\"QuestionsC\": [\n      \"q1\", \n      \"q2\"\n      ]\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "b96123a3-5216-465e-b96f-3b1fdba19821",
      "name": "结构化输出解析器1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        420,
        -440
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"QuestionsB\": [\n    \"string (question from Unit 1)\",\n    \"string (question from Unit 1)\",\n    \"string (question from Unit 2)\",\n    \"string (question from Unit 2)\"\n  ]\n}\n"
      },
      "typeVersion": 1.2
    },
    {
      "id": "53df364b-d29e-4bff-a0f3-2a568e27d74e",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        520,
        -860
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"QuestionsA\": [\n    \"Question from Syllabus 1 - 1\",\n    \"Question from Syllabus 1 - 2\",\n    \"Question from Syllabus 2 - 1\",\n    \"Question from Syllabus 2 - 2\"\n  ]\n}\n"
      },
      "typeVersion": 1.2
    },
    {
      "id": "710af5bb-3308-49aa-9415-40f89a132aa4",
      "name": "B 部分试卷生成代理1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "onError": "continueRegularOutput",
      "position": [
        120,
        -780
      ],
      "parameters": {
        "text": "=You are a professor in a college assigned to create a question paper.\n\nTask:\n\nCreate exactly 4 questions for Part B, each worth 13 marks.\n\nChoose 2 questions from the following syllabus topics: {{ $json[\"syllabus for unit 1\"] }}\n\nChoose 2 questions from the following syllabus topics: {{ $json[\"syllabus for unit 2\"] }}\n\nGenerate questions worth 13 marks each, following Bloom’s Taxonomy levels — Apply and Analyse.\n\nOutput Format (must strictly match this schema):\n{\n  \"QuestionsB\": [\n    \"string (question from Unit 1 - 1)\",\n    \"string (question from Unit 1 - 2)\",\n    \"string (question from Unit 2 - 1)\",\n    \"string (question from Unit 2 - 2)\"\n  ]\n}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.8
    },
    {
      "id": "7dc94d6b-d214-437c-b6c6-251f231d4053",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "onError": "continueRegularOutput",
      "position": [
        1180,
        -820
      ],
      "parameters": {},
      "typeVersion": 3,
      "alwaysOutputData": true
    },
    {
      "id": "5c40fd23-220c-4215-b6ce-6b9d9c82c88d",
      "name": "合并1",
      "type": "n8n-nodes-base.merge",
      "position": [
        1440,
        -360
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "feb6ebc0-2a02-45cd-93b6-c273e82a4dd9",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        1620,
        -580
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      QuestionsA: items[0].json.output.QuestionsA,\n      QuestionsB: items[1].json.output.QuestionsB,\n      QuestionsC: items[2].json.output.QuestionsC,\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "11aa55ff-531b-4357-bf9c-208c6939073d",
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2100,
        -940
      ],
      "webhookId": "581776a3-67fa-4c9a-b916-29cb2a937578",
      "parameters": {
        "sendTo": "={{ $node[\"On form submission\"].json[\"Enter your email to send the Exam Question Paper.\"] }} \n",
        "message": "=Thank you for your interest. We have \n\n{{ $json.html }}",
        "options": {
          "bccList": "weki9631@gmail.com"
        },
        "subject": "={{ $node[\"On form submission\"].json[\"Name of the subject with code\"] }} Question Paper"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "cqSWSp3vkWk7gIEM",
          "name": "Gmail account 2"
        }
      },
      "executeOnce": true,
      "typeVersion": 2.1
    },
    {
      "id": "b92f56f3-0a1a-4dc1-8fda-a73f49cc1047",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1700,
        -1060
      ],
      "parameters": {
        "content": "在 HTML 部分输入试卷模板的 HTML 代码,并调用 AI 代理生成的试题"
      },
      "typeVersion": 1
    },
    {
      "id": "4aaa8af3-6477-4e1b-be7b-dedd9b903870",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2060,
        -1080
      ],
      "parameters": {
        "content": "您将在邮件中收到生成的试卷"
      },
      "typeVersion": 1
    },
    {
      "id": "972d7487-57a9-48d4-9ff2-2580721d38b7",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -840,
        -660
      ],
      "parameters": {
        "content": "在表单中输入科目代码/名称、教学大纲和发送试卷的邮箱地址"
      },
      "typeVersion": 1
    },
    {
      "id": "00b1703f-2de1-4b68-b395-990731953778",
      "name": "HTML 格式试卷排版器",
      "type": "n8n-nodes-base.html",
      "position": [
        1780,
        -920
      ],
      "parameters": {
        "html": "<!DOCTYPE html>\n<html>\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Question Paper</title>\n    <style>\n        body {\n            font-family: 'Times New Roman', Times, serif;\n            margin: 40px;\n            line-height: 1.6;\n        }\n        .header {\n            text-align: center;\n            border-bottom: 2px solid #000;\n            padding-bottom: 10px;\n            margin-bottom: 20px;\n        }\n        .header img {\n            width: 120px;\n            vertical-align: middle;\n        }\n        .header h1, .header h2, .header h3 {\n            margin: 5px 0;\n        }\n        .title-section {\n            text-align: center;\n            margin-bottom: 30px;\n        }\n        .part-title {\n            font-weight: bold;\n            margin-top: 25px;\n            font-size: 18px;\n        }\n        .question {\n            margin: 10px 0;   /* removed left margin */\n        }\n        .sub-question {\n            margin: 5px 0;   /* removed left margin */\n        }\n        .footer {\n            margin-top: 40px;\n            font-size: 12px;\n            text-align: center;\n            border-top: 1px solid #000;\n            padding-top: 10px;\n        }\n    </style>\n</head>\n<body>\n\n    <!-- Header -->\n    <div class=\"header\">\n        <h1>AI-AGENT LEARNING AND TRAINING COLLEGE</h1>\n        <h3>Autonomous | Approved by AIXYZ | Affiliated to XYZ University</h3>\n        <h3>College Code: XYZ123</h3>\n    </div>\n\n    <!-- Title Section -->\n    <div class=\"title-section\">\n        <h2>Assessment QP – Month – Year (for III, V and VII Sem)</h2>\n        <p><strong>Sub. Code/Name:</strong> 24YSN2025 - {{ $node['On form submission'].json['Name of the subject with code'] }} </p>\n        <p><strong>Slot/Strength:</strong> 25FLrn / NN Students</p>\n    </div>\n\n    <!-- Part A -->\n    <div>\n        <div class=\"part-title\" style=\"text-align: center;\">PART – A (4 x 2 = 08 Marks)</div>\n        <p><strong>1.</strong> {{ $json.QuestionsA[0] }}</p>\n        <p><strong>2.</strong> {{ $json.QuestionsA[1] }}</p>\n        <p><strong>3.</strong> {{ $json.QuestionsA[2] }}</p>\n        <p><strong>4.</strong> {{ $json.QuestionsA[3] }}</p>\n    </div>\n\n    <!-- Part B -->\n    <div>\n        <div class=\"part-title\" style=\"text-align: center;\">PART – B (2 x 13 = 26 Marks)</div>\n\n        <p class=\"question\"><strong>3a.</strong> {{ $json.QuestionsB[0] }}</p>\n        <p style=\"text-align: center; font-weight: bold; margin: 5px 0;\">or</p>\n        <p class=\"question\"><strong>3b.</strong> {{ $json.QuestionsB[1] }}</p>\n\n        <p class=\"question\"><strong>4a.</strong> {{ $json.QuestionsB[2] }}</p>\n        <p style=\"text-align: center; font-weight: bold; margin: 5px 0;\">or</p>\n        <p class=\"question\"><strong>4b.</strong> {{ $json.QuestionsB[3] }}</p>\n    </div>\n\n    <!-- Part C -->\n    <div>\n        <div class=\"part-title\" style=\"text-align: center;\">PART – C (Case Study / Applications) (1 x 14 = 14 Marks)</div>\n        <p class=\"sub-question\"><strong>5a.</strong> {{ $json.QuestionsC[0] }}</p>\n        <p style=\"text-align: center; font-weight: bold; margin: 5px 0;\">or</p>\n        <p class=\"sub-question\"><strong>5b.</strong> {{ $json.QuestionsC[1] }}</p>\n    </div>\n\n    <!-- Footer -->\n    <div class=\"footer\">\n        Generated on: {{ new Date().toLocaleDateString(\"en-GB\") }} template by Gracewell89 via N8N\n    </div>\n\n</body>\n</html>\n"
      },
      "typeVersion": 1.2,
      "alwaysOutputData": false
    },
    {
      "id": "261c711f-af63-4362-bfff-39897a4e7438",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        540,
        -1320
      ],
      "parameters": {
        "content": "此 AI 代理将生成四道 2 分题"
      },
      "typeVersion": 1
    },
    {
      "id": "c706be51-1c6a-4c45-9b31-6dd52a24aaf7",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        440,
        -720
      ],
      "parameters": {
        "content": "此 AI 代理将生成四道 13 分题,每题包含 2 个选项"
      },
      "typeVersion": 1
    },
    {
      "id": "791adcb1-058e-4a5b-a4c5-711d4c0fd61d",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        -180
      ],
      "parameters": {
        "content": "此 AI 代理将生成两道 14 分题,每题包含 2 个选项"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1"
  },
  "versionId": "d01a99dd-8100-4e2a-b097-d897b44af582",
  "connections": {
    "feb6ebc0-2a02-45cd-93b6-c273e82a4dd9": {
      "main": [
        [
          {
            "node": "00b1703f-2de1-4b68-b395-990731953778",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7dc94d6b-d214-437c-b6c6-251f231d4053": {
      "main": [
        [
          {
            "node": "5c40fd23-220c-4215-b6ce-6b9d9c82c88d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5c40fd23-220c-4215-b6ce-6b9d9c82c88d": {
      "main": [
        [
          {
            "node": "feb6ebc0-2a02-45cd-93b6-c273e82a4dd9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "647e3bc6-2672-4858-8cce-f2bc12f2ff4c": {
      "main": [
        [
          {
            "node": "7dc94d6b-d214-437c-b6c6-251f231d4053",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d8336bbc-ad6e-44db-9555-453a4f28de0a": {
      "main": [
        [
          {
            "node": "5c40fd23-220c-4215-b6ce-6b9d9c82c88d",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "710af5bb-3308-49aa-9415-40f89a132aa4": {
      "main": [
        [
          {
            "node": "7dc94d6b-d214-437c-b6c6-251f231d4053",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "1747ae55-0145-491d-b06c-7d6fad1b6fb4": {
      "ai_languageModel": [
        [
          {
            "node": "647e3bc6-2672-4858-8cce-f2bc12f2ff4c",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "d52fb9c2-2115-4652-8e2e-52dede6bc99e": {
      "main": [
        [
          {
            "node": "647e3bc6-2672-4858-8cce-f2bc12f2ff4c",
            "type": "main",
            "index": 0
          },
          {
            "node": "d8336bbc-ad6e-44db-9555-453a4f28de0a",
            "type": "main",
            "index": 0
          },
          {
            "node": "710af5bb-3308-49aa-9415-40f89a132aa4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "db8b52b5-de1f-4346-a1e4-a2cd1505bb10": {
      "ai_languageModel": [
        [
          {
            "node": "710af5bb-3308-49aa-9415-40f89a132aa4",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "c3e9d1d5-46ca-42b4-807e-faa2cbc1c747": {
      "ai_languageModel": [
        [
          {
            "node": "d8336bbc-ad6e-44db-9555-453a4f28de0a",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "00b1703f-2de1-4b68-b395-990731953778": {
      "main": [
        [
          {
            "node": "11aa55ff-531b-4357-bf9c-208c6939073d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "53df364b-d29e-4bff-a0f3-2a568e27d74e": {
      "ai_outputParser": [
        [
          {
            "node": "647e3bc6-2672-4858-8cce-f2bc12f2ff4c",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "b96123a3-5216-465e-b96f-3b1fdba19821": {
      "ai_outputParser": [
        [
          {
            "node": "710af5bb-3308-49aa-9415-40f89a132aa4",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "ed68e227-24b1-48d0-879b-5a5db0476399": {
      "ai_outputParser": [
        [
          {
            "node": "d8336bbc-ad6e-44db-9555-453a4f28de0a",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量21
分类-
节点类型9
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流

分类

分类: 34