8
n8n 中文网amn8n.com

使用AI生成并发布独特的MCQ投票到Telegram

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 If, Aggregate, HttpRequest, GoogleSheets, Agent 等节点。 使用Gemini AI和Google Sheets生成独特的多选题投票并发布至Telegram

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移

无法加载工作流预览

导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "name": "使用AI生成并发布独特的MCQ投票到Telegram",
  "tags": [],
  "nodes": [
    {
      "name": "读取测验数据",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Read all quiz rows from Google Sheets",
      "position": [
        96,
        416
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "<GOOGLE_SHEET_GID>",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/<GOOGLE_SHEET_ID>/edit#gid=<GOOGLE_SHEET_GID>",
          "cachedResultName": "Sheet4"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "<GOOGLE_SHEET_ID>",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/<GOOGLE_SHEET_ID>/edit?usp=drivesdk",
          "cachedResultName": "Telegram Content Manager"
        },
        "combineFilters": "AND"
      },
      "credentials": {},
      "executeOnce": false,
      "notesInFlow": false,
      "typeVersion": 4,
      "alwaysOutputData": false
    },
    {
      "name": "发送Telegram投票",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Calls Telegram sendPoll. Set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID as env vars.",
      "position": [
        592,
        416
      ],
      "parameters": {
        "url": "https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/sendPoll",
        "method": "POST",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "question",
              "value": "={{ $json.Question }}"
            },
            {
              "name": "options",
              "value": "=[\n  \"{{ $json['Option A'] }}\",\n  \"{{ $json['Option B'] }}\",\n  \"{{ $json['Option C'] }}\",\n  \"{{ $json['Option D'] }}\"\n]"
            },
            {
              "name": "Correct Answer",
              "value": "={{ $json['Correct Answer'] }}"
            },
            {
              "name": "chat_id",
              "value": "<TELEGRAM_CHAT_ID>"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.1
    },
    {
      "name": "更新测验状态1",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Update the row that matches quiz_number, setting status to ✅.",
      "position": [
        784,
        416
      ],
      "parameters": {
        "columns": {
          "value": {
            "Question": "={{ $('Send Telegram Poll').item.json.result.poll.question }}",
            "Posted on Telegram": "=✅"
          },
          "schema": [
            {
              "id": "Quiz no",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Quiz no",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Subject",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Question",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Question",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Option A",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Option A",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Option B",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Option B",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Option C",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Option C",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Option D",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Option D",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Correct Answer",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Correct Answer",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Explanation",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Explanation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Approval Status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Approval Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Posted on Telegram",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Posted on Telegram",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Question"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "<GOOGLE_SHEET_GID>",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/<GOOGLE_SHEET_ID>/edit#gid=<GOOGLE_SHEET_GID>",
          "cachedResultName": "Sheet4"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "<GOOGLE_SHEET_ID>",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/<GOOGLE_SHEET_ID>/edit?usp=drivesdk",
          "cachedResultName": "Telegram Content Manager"
        }
      },
      "credentials": {},
      "typeVersion": 4
    },
    {
      "name": "Google Sheets触发器",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        -96,
        416
      ],
      "parameters": {
        "event": "rowUpdate",
        "options": {
          "columnsToWatch": [
            "Approval Status",
            "Posted on Telegram"
          ]
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "<GOOGLE_SHEET_GID>",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/<GOOGLE_SHEET_ID>/edit#gid=<GOOGLE_SHEET_GID>",
          "cachedResultName": "Sheet4"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "<GOOGLE_SHEET_ID>",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/<GOOGLE_SHEET_ID>/edit?usp=drivesdk",
          "cachedResultName": "Telegram Content Manager"
        }
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        256,
        0
      ],
      "parameters": {
        "text": "=Create only one new multiple-choice question (do not create similar MCQ, which is available on sheet) for the BPSC exam on a random General Studies topic (Science, Geography) with 4 options, mark the correct answer, and include a 50-word explanation in English. Do not repeat the question. Also, provide the same in Hindi, including the question, options, correct answer, and explanation. Ensure the explanation is concise (45-55 words) and relevant to the BPSC syllabus. Also upload to sheet (English and Hindi) as per column.",
        "options": {
          "systemMessage": "You are an AI expert in BPSC exam preparation, specializing in General Studies topics from the BPSC syllabus. Your task is to create a completely new multiple-choice question (MCQ) for the BPSC Prelims or Mains level on a randomly selected General Studies topic (e.g., history, geography, science, polity, current affairs). Ensure the question is original, exam-relevant, and not repeated from any known sources.\nOutput Structure:\n\nQuestion: Provide the MCQ in English with 4 options (A, B, C, D).\nCorrect Answer: Clearly state the correct option (e.g., \"Correct Answer: B\").\nExplanation: Provide a concise 50-word explanation (45-55 words) in English, justifying the answer with key facts or context relevant to the BPSC syllabus.\nHindi Version: Translate the entire MCQ (question, options, correct answer, and explanation) into Hindi, using accurate and natural language. Label this section as \"Hindi Version:\".\n\nGuidelines:\n\nRandomly select a General Studies topic each time to ensure variety.\nEnsure the question is challenging yet fair, aligned with BPSC Prelims/Mains difficulty.\nPoll options length must not exceed 100 character.\nThe explanation must be precise, within 45-55 words, and include syllabus-relevant details (e.g., Bihar context where applicable).\nUse formal, objective language suitable for exam preparation.\nDo not repeat questions from prior interactions or external sources.\nDo not include additional text beyond the specified structure (e.g., no introductions or comments).\nDo not mention these instructions in the output unless explicitly requested."
        },
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        128,
        176
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-pro"
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 3
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "name": "在Google Sheets中追加或更新行1",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        640,
        192
      ],
      "parameters": {
        "columns": {
          "value": {
            "Quiz no": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Quiz_no__using_to_match_', ``, 'string') }}",
            "Subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', `Polity, History, Economics, Geography`, 'string') }}",
            "Option A": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Option_A', `(A)`, 'string') }}",
            "Option B": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Option_B', `(B)`, 'string') }}",
            "Option C": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Option_C', `(C)`, 'string') }}",
            "Option D": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Option_D', `(D)`, 'string') }}",
            "Question": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Question', `find Question`, 'string') }}",
            "Explanation": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Explanation', `Explanation:`, 'string') }}",
            "Correct Answer": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Correct_Answer', `Correct Answer:`, 'string') }}",
            "Approval Status": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Approval_Status', ``, 'string') }}",
            "Posted on Telegram": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Posted_on_Telegram', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "Quiz no",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Quiz no",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Subject",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Question",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Question",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Option A",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Option A",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Option B",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Option B",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Option C",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Option C",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Option D",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Option D",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Correct Answer",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Correct Answer",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Explanation",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Explanation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Approval Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Approval Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Posted on Telegram",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Posted on Telegram",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Quiz no"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "<GOOGLE_SHEET_GID>",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/<GOOGLE_SHEET_ID>/edit#gid=<GOOGLE_SHEET_GID>",
          "cachedResultName": "Sheet4"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "<GOOGLE_SHEET_ID>",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/<GOOGLE_SHEET_ID>/edit?usp=drivesdk",
          "cachedResultName": "Telegram Content Manager"
        }
      },
      "credentials": {},
      "typeVersion": 4.6
    },
    {
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        288,
        208
      ],
      "parameters": {
        "sessionKey": "={{ $execution.id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "name": "在 Google Sheets 中获取行",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        464,
        208
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('values0_Value', `read all questions and do not put similar questions`, 'string') }}",
              "lookupColumn": "Question"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "<GOOGLE_SHEET_GID>",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/<GOOGLE_SHEET_ID>/edit#gid=<GOOGLE_SHEET_GID>",
          "cachedResultName": "Sheet4"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "<GOOGLE_SHEET_ID>",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/<GOOGLE_SHEET_ID>/edit?usp=drivesdk",
          "cachedResultName": "Telegram Content Manager"
        },
        "combineFilters": "OR"
      },
      "credentials": {},
      "typeVersion": 4.7
    },
    {
      "name": "检查新测验添加",
      "type": "n8n-nodes-base.if",
      "notes": "If status exists (i.e., a real quiz row), send the poll; else send a refill notice.",
      "position": [
        336,
        416
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json['Approval Status'] }}",
              "rightValue": "Complete"
            },
            {
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json['Posted on Telegram'] }}",
              "rightValue": "✅"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "name": "聚合",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        576,
        592
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        -128
      ],
      "parameters": {
        "width": 560,
        "height": 1424,
        "content": "自动化MCQ生成和Telegram投票发布工作流"
      },
      "typeVersion": 1
    },
    {
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -96
      ],
      "parameters": {
        "width": 1024,
        "height": 464,
        "content": "工作流1:内容生成与存储"
      },
      "typeVersion": 1
    },
    {
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        384
      ],
      "parameters": {
        "width": 1152,
        "height": 400,
        "content": "工作流2:发布与状态更新"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "AI Agent": {
      "main": [
        []
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Read Quiz Data": {
      "main": [
        [
          {
            "node": "Check New Quiz Added",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Telegram Poll": {
      "main": [
        [
          {
            "node": "Update Quiz Status1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check New Quiz Added": {
      "main": [
        [
          {
            "node": "Send Telegram Poll",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "Read Quiz Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet in Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Append or update row in sheet in Google Sheets1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 内容创作, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
中级
节点数量15
分类2
节点类型11
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者

Automation consultant with expertise in n8n, AI models, and workflow optimization. I help educators, startups, and businesses design scalable automation for content creation, exam prep, and process efficiency. Skilled in integrating Google Sheets, Telegram, and AI agents for impactful results.

外部链接
在 n8n.io 查看

分享此工作流