基于已修先修课程的AI课程排程器(Google Sheets + OpenAI)
中级
这是一个自动化工作流,包含 13 个节点。主要使用 Set, SplitOut, GoogleSheets, ManualTrigger, Agent 等节点。 基于已修先修课程的AI课程排程器(Google Sheets + OpenAI)
前置要求
- •Google Sheets API 凭证
- •OpenAI API Key
分类
-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "ad0113c344ee237399e44e9f11798b05baeb83a6196d514a9ae9d2ad71c3b5c9",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "5432b2ed-adde-4021-b6b3-e75e43bd102c",
"name": "点击\"执行工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-1936,
6608
],
"parameters": {},
"typeVersion": 1
},
{
"id": "d25eca2c-90bb-4888-b474-8e433089ffb2",
"name": "OpenAI 聊天模型2",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1328,
6880
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "gpt-4o"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "4l6TDfLZVFS24g3X",
"name": "OpenAi account 4"
}
},
"typeVersion": 1.2
},
{
"id": "735096be-4698-4f16-9ba3-0f4e22d1b96e",
"name": "便签66",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1408,
6592
],
"parameters": {
"color": 3,
"width": 224,
"height": 400,
"content": "### 3) 连接 OpenAI (API 密钥)"
},
"typeVersion": 1
},
{
"id": "adc4b2bc-5927-409e-809f-bcaf9dd09ab5",
"name": "多表:您可以连接多个表以实现有组织的数据结构",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
-1008,
6592
],
"parameters": {
"jsonSchemaExample": "[\n {\n \"StudentID\": \"S001\",\n \"Term\": \"Fall 2025\",\n \"Selected\": [\n \"CS-201 | Computer Systems | 3\",\n \"CS-220 | Databases | 3\",\n \"CS-210 | Web Development | 3\",\n \"GEN-107 | Introduction to Sociology | 3\",\n \"GEN-109 | Environmental Science | 4\"\n ],\n \"Rationale\": \"Student met prerequisites for sophomore-level Computer Science courses and added two Gen Eds for balance.\"\n }\n]\n"
},
"typeVersion": 1.3
},
{
"id": "6dc807d0-5f0d-4b88-8e37-3e05890b6f55",
"name": "便签67",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1728,
6160
],
"parameters": {
"color": 3,
"width": 224,
"height": 656,
"content": "### 1) 连接 Google Sheets (OAuth2)"
},
"typeVersion": 1
},
{
"id": "abb848f7-0819-423c-8e24-3541f469d5d0",
"name": "调度代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-1168,
6384
],
"parameters": {
"text": "=\n \"StudentID\": \"{{$json.StudentID}}\",\n \"Name\": \"{{$json.Name}}\",\n \"Program\": \"{{$json.Program}}\",\n \"Year\": \"{{$json.Year}}\",\n \"CompletedCourses\": \"{{$json.CompletedCourses}}\"\n\n",
"options": {
"systemMessage": "You are a registrar scheduling assistant. Using ONLY the provided Students sheet (10 sophomores with pipe-separated CompletedCourses), generate exactly FIVE courses per student for the current term (Fall 2025) from the catalog below, following all constraints.\n\nCATALOG\n# Format: CourseID | Title | Credits | Program | Category | Prereqs(pipe-separated AND) | Offered(Fall/Spring/Both)\nGEN-101 | College Writing I | 3 | GenEd | Gen Ed | | Both\nGEN-102 | College Writing II | 3 | GenEd | Gen Ed | GEN-101 | Both\nGEN-103 | Quantitative Reasoning | 3 | GenEd | Gen Ed | | Both\nGEN-104 | Introduction to Philosophy | 3 | GenEd | Gen Ed | | Both\nGEN-105 | Public Speaking | 3 | GenEd | Gen Ed | | Both\nGEN-106 | World History Since 1500 | 3 | GenEd | Gen Ed | | Both\nGEN-107 | Introduction to Sociology | 3 | GenEd | Gen Ed | | Both\nGEN-108 | General Psychology | 3 | GenEd | Gen Ed | | Both\nGEN-109 | Environmental Science | 4 | GenEd | Gen Ed (Lab) | | Both\nGEN-110 | Introduction to Statistics | 3 | GenEd | Gen Ed | GEN-103 | Both\n\nCS-101 | Intro to Programming (Python) | 4 | Computer Science BS | Major Core | | Both\nCS-102 | Data Structures | 4 | Computer Science BS | Major Core | CS-101 | Both\nCS-103 | Discrete Mathematics | 3 | Computer Science BS | Major Core | GEN-103 | Both\nCS-201 | Computer Systems | 3 | Computer Science BS | Major Core | CS-102 | Fall\nCS-202 | Algorithms | 4 | Computer Science BS | Major Core | CS-102|CS-103 | Spring\nCS-210 | Web Development | 3 | Computer Science BS | Major Elective | CS-101 | Both\nCS-220 | Databases | 3 | Computer Science BS | Major Core | CS-102 | Both\n\nDS-101 | Intro to Data Science | 3 | Data Science BS | Major Core | GEN-110|CS-101 | Both\nDS-201 | Linear Algebra for DS | 3 | Data Science BS | Major Core | GEN-103 | Both\nDS-202 | Probability & Statistics II | 3 | Data Science BS | Major Core | GEN-110 | Both\nDS-210 | Data Visualization | 3 | Data Science BS | Major Elective | DS-101 | Both\n\nBUS-101 | Principles of Management | 3 | Business Administration BBA | Major Core | | Both\nBUS-102 | Microeconomics | 3 | Business Administration BBA | Major Core | | Both\nBUS-103 | Macroeconomics | 3 | Business Administration BBA | Major Core | | Both\nBUS-201 | Financial Accounting | 3 | Business Administration BBA | Major Core | GEN-110 | Both\nBUS-202 | Marketing Principles | 3 | Business Administration BBA | Major Core | BUS-101 | Both\nBUS-210 | Business Analytics with Excel | 3 | Business Administration BBA | Major Elective | GEN-110 | Both\n\nPSY-101 | Introduction to Psychology | 3 | Psychology BA | Major Core | | Both\nPSY-201 | Research Methods in Psychology | 3 | Psychology BA | Major Core | GEN-110|PSY-101 | Both\nPSY-210 | Cognitive Psychology | 3 | Psychology BA | Major Elective | PSY-101 | Fall\n\nBIO-101 | General Biology I (Lab) | 4 | Biology BS (Pre-Med) | Major Core | | Fall\nBIO-102 | General Biology II (Lab) | 4 | Biology BS (Pre-Med) | Major Core | BIO-101 | Spring\nCHM-101 | General Chemistry I (Lab) | 4 | Biology BS (Pre-Med) | Major Core | | Fall\nCHM-102 | General Chemistry II (Lab) | 4 | Biology BS (Pre-Med) | Major Core | CHM-101 | Spring\nBIO-201 | Genetics | 3 | Biology BS (Pre-Med) | Major Core | BIO-102|GEN-110 | Fall\nBIO-210 | Cell Biology | 3 | Biology BS (Pre-Med) | Major Elective | BIO-102 | Spring\n\nENGR-101 | Intro to Engineering | 3 | Mechanical Engineering BS | Major Core | | Both\nENGR-102 | Engineering Graphics | 3 | Mechanical Engineering BS | Major Core | | Both\nMTH-121 | Calculus I | 4 | Mechanical Engineering BS | Major Core | GEN-103 | Both\nMTH-122 | Calculus II | 4 | Mechanical Engineering BS | Major Core | MTH-121 | Both\nPHY-151 | Physics I (Calc-Based, Lab) | 4 | Mechanical Engineering BS | Major Core | MTH-121 | Fall\nPHY-152 | Physics II (Calc-Based, Lab) | 4 | Mechanical Engineering BS | Major Core | PHY-151|MTH-122 | Spring\nME-201 | Statics | 3 | Mechanical Engineering BS | Major Core | PHY-151|MTH-122 | Fall\nME-210 | Materials Science | 3 | Mechanical Engineering BS | Major Elective | CHM-101 | Spring\n\nNUR-101 | Foundations of Nursing | 4 | Nursing BSN | Major Core | | Fall\nNUR-102 | Health Assessment | 3 | Nursing BSN | Major Core | NUR-101 | Spring\nNUR-201 | Pathophysiology | 3 | Nursing BSN | Major Core | CHM-101|BIO-101 | Fall\nNUR-210 | Pharmacology | 3 | Nursing BSN | Major Core | NUR-201 | Spring\n\nENG-101 | Intro to Literary Studies | 3 | English Literature BA | Major Core | GEN-101 | Both\nENG-201 | British Literature I | 3 | English Literature BA | Major Core | ENG-101 | Fall\nENG-210 | Creative Writing Workshop | 3 | English Literature BA | Major Elective | ENG-101 | Both\n\nECON-101 | Principles of Microeconomics | 3 | Economics BA | Major Core | | Both\nECON-102 | Principles of Macroeconomics | 3 | Economics BA | Major Core | | Both\nECON-201 | Intermediate Microeconomics | 3 | Economics BA | Major Core | ECON-101|GEN-110 | Fall\nECON-202 | Intermediate Macroeconomics | 3 | Economics BA | Major Core | ECON-102|GEN-110 | Spring\n\nART-101 | Design Foundations | 3 | Graphic Design BFA | Major Core | | Both\nART-102 | Drawing I | 3 | Graphic Design BFA | Major Core | | Both\nART-201 | Typography | 3 | Graphic Design BFA | Major Core | ART-101 | Fall\nART-210 | Digital Imaging | 3 | Graphic Design BFA | Major Elective | ART-101 | Both\n\nCONSTRAINTS\n1) Exactly 5 courses per student; target total 15–17 credits.\n2) Enforce prerequisites: all listed prereqs must already be in CompletedCourses.\n3) Use only courses offered in Fall or Both for Fall 2025.\n4) Prioritize Major Core, then Major Elective, then Gen Ed. Include at least one Gen Ed if still needed.\n5) No duplicates or courses already completed.\n6) Prefer 200-level progression where available and allowed by prereqs.\n\nINPUT\n- Students: an array of records from the Google Sheet with fields:\n StudentID, Name, Program, Year, CompletedCourses (pipe-separated CourseIDs)\n\nOUTPUT\nReturn a JSON array; one object per student:\n[\n {\n \"StudentID\": \"S001\",\n \"Term\": \"Fall 2025\",\n \"Selected\": [\n \"CS-201 | Computer Systems | 3\",\n \"CS-220 | Databases | 3\",\n \"CS-210 | Web Development | 3\",\n \"GEN-107 | Introduction to Sociology | 3\",\n \"GEN-109 | Environmental Science | 4\"\n ],\n \"Rationale\": \"Student met prerequisites for sophomore-level Computer Science courses and added two Gen Eds for balance.\"\n }\n]\n\n\nIMPLEMENTATION NOTES\n- Parse CompletedCourses by splitting on \"|\".\n- Treat Prereqs as AND (e.g., \"CS-102|CS-103\" requires both).\n- \"GenEd\" courses apply to any program.\n- If a student cannot reach 5 major-appropriate courses, fill remaining slots with Gen Eds without prerequisites that are offered in Fall/Both to stay within 15–17 credits.\n",
"passthroughBinaryImages": true
},
"promptType": "define",
"hasOutputParser": true
},
"executeOnce": false,
"typeVersion": 2.2
},
{
"id": "7e482cae-9c94-4b19-a828-e067fa7cbb1b",
"name": "设置字段",
"type": "n8n-nodes-base.set",
"position": [
-544,
6384
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "f239fdfb-f2ed-4e30-bb81-560cb624cdb9",
"name": "StudentID",
"type": "string",
"value": "={{ $json.output[0].StudentID }}"
},
{
"id": "249bdf9e-6f9b-4e45-a5c9-288128c03e51",
"name": "Schedule",
"type": "string",
"value": "={{ $json['output[0].Selected'] }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "de5141a8-d7d2-4392-b516-d3b48f565e5e",
"name": "清空 sheet1",
"type": "n8n-nodes-base.googleSheets",
"position": [
-336,
6384
],
"parameters": {
"operation": "clear",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 572766543,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/10IMnD8JhiR4lTlNFQTG_Auopg8haAiEt3_G9EKWTqLw/edit#gid=572766543",
"cachedResultName": "schedule"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "10IMnD8JhiR4lTlNFQTG_Auopg8haAiEt3_G9EKWTqLw",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/10IMnD8JhiR4lTlNFQTG_Auopg8haAiEt3_G9EKWTqLw/edit?usp=drivesdk",
"cachedResultName": "Student Details"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "HlBW2puZbuCCq8jJ",
"name": "Google Sheets account 3"
}
},
"typeVersion": 4.7
},
{
"id": "9ae9d8a6-680b-4df0-b41f-95aa314f0679",
"name": "便签56",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2016,
6016
],
"parameters": {
"color": 7,
"width": 2144,
"height": 1056,
"content": "### 🎓 基于已完成先修课程的 AI 课程排课器 (Google Sheets + OpenAI)"
},
"typeVersion": 1
},
{
"id": "b55540c2-7e9d-4998-9c87-fa8ef37ff943",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2448,
6016
],
"parameters": {
"width": 400,
"height": 1056,
"content": "### ⚙️ 设置 (仅需2步)"
},
"typeVersion": 1
},
{
"id": "b23e80f6-a848-4fdc-989d-f500fae50f8d",
"name": "获取学生数据",
"type": "n8n-nodes-base.googleSheets",
"position": [
-1664,
6672
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/10IMnD8JhiR4lTlNFQTG_Auopg8haAiEt3_G9EKWTqLw/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "10IMnD8JhiR4lTlNFQTG_Auopg8haAiEt3_G9EKWTqLw",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/10IMnD8JhiR4lTlNFQTG_Auopg8haAiEt3_G9EKWTqLw/edit?usp=drivesdk",
"cachedResultName": "Student Details"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "HlBW2puZbuCCq8jJ",
"name": "Google Sheets account 3"
}
},
"typeVersion": 4.7
},
{
"id": "e8c4be35-a682-43af-806c-4a0908fad56f",
"name": "拆分课程表",
"type": "n8n-nodes-base.splitOut",
"position": [
-800,
6384
],
"parameters": {
"include": "allOtherFields",
"options": {},
"fieldToSplitOut": "output[0].Selected"
},
"typeVersion": 1
},
{
"id": "40109987-d4b5-48d5-aea6-1923956ad3e8",
"name": "附加课程表",
"type": "n8n-nodes-base.googleSheets",
"position": [
-128,
6384
],
"parameters": {
"columns": {
"value": {},
"schema": [
{
"id": "StudentID",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "StudentID",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Schedule",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Schedule",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 572766543,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/10IMnD8JhiR4lTlNFQTG_Auopg8haAiEt3_G9EKWTqLw/edit#gid=572766543",
"cachedResultName": "schedule"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "10IMnD8JhiR4lTlNFQTG_Auopg8haAiEt3_G9EKWTqLw",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/10IMnD8JhiR4lTlNFQTG_Auopg8haAiEt3_G9EKWTqLw/edit?usp=drivesdk",
"cachedResultName": "Student Details"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "HlBW2puZbuCCq8jJ",
"name": "Google Sheets account 3"
}
},
"typeVersion": 4.7
}
],
"pinData": {},
"connections": {
"Set Fields": {
"main": [
[
{
"node": "Clear sheet1",
"type": "main",
"index": 0
}
]
]
},
"Clear sheet1": {
"main": [
[
{
"node": "Append Schedule",
"type": "main",
"index": 0
}
]
]
},
"Split Schedule": {
"main": [
[
{
"node": "Set Fields",
"type": "main",
"index": 0
}
]
]
},
"Get Student Data": {
"main": [
[
{
"node": "Scheduling Agent",
"type": "main",
"index": 0
}
]
]
},
"Scheduling Agent": {
"main": [
[
{
"node": "Split Schedule",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model2": {
"ai_languageModel": [
[
{
"node": "Scheduling Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Scheduling Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Get Student Data",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用 Perplexity AI 研究业务线索并使用 OpenAI 保存到 Google Sheets
使用 Perplexity AI 研究业务线索并使用 OpenAI 保存到 Google Sheets
Set
Merge
Split Out
+8
18 节点Robert Breen
杂项
博客内容多语言自动翻译
使用GPT-4o和Markdown自动将博客内容翻译为多种语言
Set
Merge
Split Out
+5
12 节点Robert Breen
内容创作
初学者数据分析:使用 GPT-4o 在 Google Sheets 中合并、筛选和汇总
初学者数据分析:使用 GPT-4o 在 Google Sheets 中合并、筛选和汇总
If
Set
Code
+9
21 节点Robert Breen
文档提取
播客笔记记录器
使用GPT和Gemini结合性能数据创建高转化率Meta广告脚本
Set
Code
Merge
+7
24 节点Robert Breen
文档提取
播客笔记记录器
使用GPT和Gemini结合性能数据创建高转化率Meta广告脚本
Set
Google Sheets
Manual Trigger
+4
12 节点Robert Breen
内容创作
使用 Apify + GPT-4o-mini 从标签分析生成 Instagram 标题
使用 Apify + GPT-4o-mini 从标签分析生成 Instagram 标题
Set
Code
Merge
+8
17 节点Robert Breen
内容创作
工作流信息
难度等级
中级
节点数量13
分类-
节点类型8
作者
Robert Breen
@rbreenProfessional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.
外部链接
在 n8n.io 查看 →
分享此工作流