AutomationFlowsAI & RAG › Send Gpt-4 Telegram Polls to Multiple Groups with Google Sheets Analytics

Send Gpt-4 Telegram Polls to Multiple Groups with Google Sheets Analytics

ByOneclick AI Squad @oneclick-ai on n8n.io

An enterprise-grade n8n workflow that leverages OpenAI GPT-4 to generate contextually relevant poll questions and automatically distributes them across multiple Telegram groups and channels. Includes comprehensive analytics tracking, smart error handling, real-time admin…

Cron / scheduled trigger★★★★☆ complexityAI-powered23 nodesGoogle SheetsAgentOpenAI ChatTelegramEmail Send
AI & RAG Trigger: Cron / scheduled Nodes: 23 Complexity: ★★★★☆ AI nodes: yes Added:
Send Gpt-4 Telegram Polls to Multiple Groups with Google Sheets Analytics — n8n workflow card showing Google Sheets, Agent, OpenAI Chat integration

This workflow corresponds to n8n.io template #10383 — we link there as the canonical source.

This workflow follows the Agent → Emailsend recipe pattern — see all workflows that pair these two integrations.

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 →

Download .json
{
  "id": "W3mFlFpV1gzKnEa3",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI-Powered Telegram Poll Automation with Analytics and Multi-Group Deploy",
  "tags": [],
  "nodes": [
    {
      "id": "fa145afe-a1a4-434d-8f5a-b1c7d4f20611",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1952,
        96
      ],
      "parameters": {
        "width": 780,
        "height": 1068,
        "content": "## AI-Powered Telegram Poll Automation with Analytics & Multi-Group Deploy\n\nAn enterprise-grade n8n workflow that leverages OpenAI GPT-4 to generate contextually relevant poll questions and automatically distributes them across multiple Telegram groups and channels. Includes comprehensive analytics tracking, smart error handling, real-time admin notifications, and priority-based topic scheduling.\n\nPerfect for community managers, HR teams, educators, marketing departments, and organizations running multiple Telegram communities who want to maintain consistent engagement without manual effort.\n\n### How it works\n\n1. **Schedule Trigger** - Fires on a configurable cron (default: 9 AM & 5 PM weekdays)\n2. **Load Topic Queue** - Reads priority-ranked topics from Google Sheets topic registry\n3. **Select Best Topic** - Picks the highest-priority, freshest topic with 24-hour dedup guard\n4. **GPT-4 Poll Generation** - Creates engaging, on-brand poll questions with emoji options\n5. **Validate Poll** - Enforces Telegram API limits and content safety before sending\n6. **Multi-Group Deploy** - Distributes poll + context message to every enabled Telegram group\n7. **Analytics Logging** - Writes per-poll deployment stats to Google Sheets\n8. **Admin Telegram Alert** - Sends real-time deploy summary to admin chat\n9. **Topic Queue Update** - Marks topic used, updates next-scheduled date\n\n### Google Sheets Setup\n**Sheet 1 \u2014 Topic Queue:** `topic | category | priority | language | tone | targetAudience | lastUsed | usageCount | enabled`\n**Sheet 2 \u2014 Group Registry:** `groupId | groupName | groupType | language | enabled`\n**Sheet 3 \u2014 Analytics Log:** `pollId | topic | question | totalGroups | successfulGroups | successRate | completedAt`\n\n### Credentials Needed\n- **OpenAI API** \u2014 GPT-4o poll generation\n- **Telegram Bot API** \u2014 Sending polls and messages\n- **Google Sheets** \u2014 Topic queue, group registry, analytics\n- **SMTP** \u2014 Error alert emails\n\n### Key Features\n- Priority-based topic scheduling with staleness detection\n- Telegram API constraint enforcement (255 char question, 100 char options)\n- Per-group error isolation \u2014 one failed group never blocks others\n- Real-time admin Telegram notification with success/fail breakdown\n- Full SOC-ready audit log for every poll deployment\n\n---\n\n**Explore More Automation:**\n[Contact us](https://www.oneclickitsolution.com/contact-us/) to design AI-powered lead nurturing, content engagement, and multi-platform reply workflows tailored to your growth strategy."
      },
      "typeVersion": 1
    },
    {
      "id": "aa0ff31a-4f92-4d56-87bb-76540c5068e9",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        464
      ],
      "parameters": {
        "color": 4,
        "width": 616,
        "height": 328,
        "content": "## 1. Schedule & Topic Selection"
      },
      "typeVersion": 1
    },
    {
      "id": "ad144a6e-38fe-4324-98c7-11123bcef653",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        288
      ],
      "parameters": {
        "color": 4,
        "width": 508,
        "height": 684,
        "content": "## 2. GPT-4 Generation & Validation"
      },
      "typeVersion": 1
    },
    {
      "id": "67b5ec41-9e25-43cb-9f3c-da19f39f5f12",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        256
      ],
      "parameters": {
        "color": 4,
        "width": 608,
        "height": 732,
        "content": "## 3. Multi-Group Telegram Deploy"
      },
      "typeVersion": 1
    },
    {
      "id": "1d51d614-e5d9-4c25-a645-30a500a35196",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        256
      ],
      "parameters": {
        "color": 4,
        "width": 1260,
        "height": 844,
        "content": "## 4. Analytics, Admin Alert, Error Handling & Queue Update"
      },
      "typeVersion": 1
    },
    {
      "id": "6484390c-3bcd-4add-b054-5d90b6d605f2",
      "name": "Poll Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1040,
        624
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9,17 * * 1-5"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "63567ee5-4e7e-4084-9fb5-b9b3023ee45b",
      "name": "Load Topic Queue from Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -816,
        624
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "="
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "="
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5,
      "continueOnFail": true
    },
    {
      "id": "cf38c882-0451-4ca0-9d2d-1e782e387e5d",
      "name": "Select Highest Priority Topic",
      "type": "n8n-nodes-base.code",
      "position": [
        -592,
        624
      ],
      "parameters": {
        "jsCode": "// Collect all topic rows\nconst topics = $input.all().map(i => i.json);\n\nif (!topics || topics.length === 0) {\n  throw new Error('Topic queue is empty. Please add topics to your Google Sheets topic registry.');\n}\n\n// Filter enabled topics only\nconst enabled = topics.filter(t => String(t.enabled).toLowerCase() === 'true');\nif (enabled.length === 0) {\n  throw new Error('No enabled topics found. Set enabled=true for at least one topic.');\n}\n\n// 24-hour dedup: skip recently used topics\nconst yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000);\nconst fresh = enabled.filter(t => !t.lastUsed || new Date(t.lastUsed) < yesterday);\n\n// Sort by priority desc, then by lastUsed asc (least recently used first)\nconst pool = (fresh.length > 0 ? fresh : enabled).sort((a, b) => {\n  const pd = (parseInt(b.priority) || 5) - (parseInt(a.priority) || 5);\n  if (pd !== 0) return pd;\n  const au = a.lastUsed ? new Date(a.lastUsed).getTime() : 0;\n  const bu = b.lastUsed ? new Date(b.lastUsed).getTime() : 0;\n  return au - bu;\n});\n\nconst selected = pool[0];\n\nconst pollSession = {\n  pollId: `POLL-${Date.now()}-${Math.random().toString(36).substr(2,7).toUpperCase()}`,\n  topic: (selected.topic || 'General Community').trim(),\n  category: (selected.category || 'General').trim(),\n  priority: parseInt(selected.priority) || 5,\n  language: selected.language || 'en',\n  tone: selected.tone || 'professional',\n  targetAudience: selected.targetAudience || 'community members',\n  usageCount: parseInt(selected.usageCount || 0) + 1,\n  totalTopics: enabled.length,\n  freshTopics: fresh.length,\n  scheduledAt: new Date().toISOString()\n};\n\nreturn [{ json: { pollSession } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "38a3ef73-cf36-4dd3-bf06-fb365f0483b7",
      "name": "Load Telegram Group Registry",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -304,
        480
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "="
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "="
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5,
      "continueOnFail": true
    },
    {
      "id": "b8393df3-941e-4f14-9916-8f1b7e051f3b",
      "name": "GPT-4 Poll Question Generation",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -368,
        784
      ],
      "parameters": {
        "text": "=You are an expert community engagement specialist and poll designer for Telegram communities.\n\nGenerate a highly engaging, on-brand Telegram poll for the topic below.\n\n**Context:**\n- Topic: {{ $json.pollSession.topic }}\n- Category: {{ $json.pollSession.category }}\n- Language: {{ $json.pollSession.language }}\n- Tone: {{ $json.pollSession.tone }}\n- Target Audience: {{ $json.pollSession.targetAudience }}\n- Poll ID: {{ $json.pollSession.pollId }}\n\n**Hard Rules (Telegram API constraints):**\n1. Question MUST be under 255 characters\n2. Generate EXACTLY 4 answer options\n3. Each option MUST be under 100 characters\n4. Options must be mutually exclusive and non-overlapping\n5. Zero offensive, political, or divisive content\n6. Start each option with a distinct emoji for visual appeal\n7. Make the question feel natural and conversational\n8. Never generate generic Yes/No/Maybe options\n\n**Tone Guide:**\n- professional: Clear, respectful, business-appropriate\n- casual: Friendly, conversational, light humour OK\n- educational: Informative angle, learning-oriented\n- fun: Creative, emoji-rich, playful\n\n**Respond in strict JSON only \u2014 no markdown, no explanation outside the JSON:**\n{\n  \"question\": \"Your poll question here (max 255 chars)?\",\n  \"options\": [\n    \"\ud83d\ude80 Option one here\",\n    \"\u26a1 Option two here\",\n    \"\ud83c\udfaf Option three here\",\n    \"\ud83d\udca1 Option four here\"\n  ],\n  \"isAnonymous\": true,\n  \"allowsMultipleAnswers\": false,\n  \"openPeriod\": 86400,\n  \"hashtags\": [\"#Hashtag1\", \"#Hashtag2\", \"#Hashtag3\"],\n  \"contentRating\": \"safe\",\n  \"engagementScore\": 85,\n  \"explanation\": \"One sentence on why this poll will resonate with the audience.\"\n}",
        "options": {
          "systemMessage": "You are a Telegram community engagement expert. Generate poll content that maximises participation and discussion. Output valid JSON only \u2014 no markdown fences, no preamble, no trailing text. All content must be safe, inclusive, and brand-appropriate."
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "f3cd5065-b0c3-401e-b876-02338da5648c",
      "name": "GPT-4o Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -288,
        1008
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {
          "maxTokens": 800,
          "temperature": 0.75
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8bf39649-2878-4623-8084-8638f5f50e2f",
      "name": "Validate Poll Quality and Safety",
      "type": "n8n-nodes-base.code",
      "position": [
        -16,
        624
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Parse GPT-4 output\nconst aiResponse = $input.item.json;\nlet aiText = aiResponse.response || aiResponse.output || aiResponse.text || '';\nif (aiResponse.content && Array.isArray(aiResponse.content)) {\n  aiText = aiResponse.content[0]?.text || aiResponse.content[0]?.message?.content || '';\n}\nconst clean = aiText.replace(/```json\\s*/g,'').replace(/```\\s*/g,'').trim();\n\nlet poll;\ntry { poll = JSON.parse(clean); }\ncatch(e) { throw new Error(`GPT-4 JSON parse failed: ${e.message}. Raw: ${clean.substring(0,200)}`); }\n\n// Validation errors array\nconst errors = [];\n\n// Question checks\nif (!poll.question || !poll.question.trim()) errors.push('Question is empty');\nelse if (poll.question.length > 255) errors.push(`Question ${poll.question.length} chars \u2014 max 255`);\n\n// Options checks\nif (!Array.isArray(poll.options)) errors.push('Options must be an array');\nelse if (poll.options.length < 2) errors.push('Need at least 2 options');\nelse if (poll.options.length > 10) errors.push(`Too many options: ${poll.options.length} \u2014 max 10`);\nelse poll.options.forEach((o,i) => {\n  if (!o || !o.trim()) errors.push(`Option ${i+1} is empty`);\n  else if (o.length > 100) errors.push(`Option ${i+1}: ${o.length} chars \u2014 max 100`);\n});\n\n// Content safety\nconst blocked = ['hate','violence','explicit','illegal','discrimination'];\nconst allText = ((poll.question||'') + ' ' + (poll.options||[]).join(' ')).toLowerCase();\nconst hits = blocked.filter(w => allText.includes(w));\nif (hits.length) errors.push(`Blocked keywords: ${hits.join(', ')}`);\nif (poll.contentRating && poll.contentRating !== 'safe') errors.push(`Content flagged: ${poll.contentRating}`);\n\nif (errors.length > 0) throw new Error(`Poll validation failed: ${errors.join(' | ')}`);\n\n// Load groups from upstream\nconst pollSession = $('Select Highest Priority Topic').first().json.pollSession;\nconst groupRegistry = $('Load Telegram Group Registry').all().map(i => i.json);\nconst enabledGroups = groupRegistry.filter(g => String(g.enabled).toLowerCase() === 'true');\n\nif (enabledGroups.length === 0) {\n  throw new Error('No enabled groups in registry. Add groups to the Google Sheets group registry.');\n}\n\n// Safe-trim options\nconst safeOptions = poll.options.map(o => o.substring(0,100).trim());\n\nreturn {\n  json: {\n    pollSession,\n    pollContent: {\n      question: poll.question.trim(),\n      options: safeOptions,\n      isAnonymous: poll.isAnonymous !== false,\n      allowsMultipleAnswers: poll.allowsMultipleAnswers === true,\n      openPeriod: Math.min(parseInt(poll.openPeriod) || 86400, 604800),\n      hashtags: poll.hashtags || [],\n      engagementScore: poll.engagementScore || 0,\n      explanation: poll.explanation || ''\n    },\n    targetGroups: enabledGroups,\n    groupCount: enabledGroups.length,\n    validatedAt: new Date().toISOString()\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "67e59347-0de0-4d99-85c8-f100b0d27b75",
      "name": "Split Groups for Parallel Deploy",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        208,
        624
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "3702e66e-2a9e-43e4-bb16-4f57a8ffe6ad",
      "name": "Send Poll to Telegram Group",
      "type": "n8n-nodes-base.telegram",
      "position": [
        432,
        528
      ],
      "parameters": {
        "text": "=",
        "chatId": "=",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2,
      "continueOnFail": true
    },
    {
      "id": "57b627c6-f71e-48da-8e03-118534bd898b",
      "name": "Send Context Message with Hashtags",
      "type": "n8n-nodes-base.telegram",
      "position": [
        432,
        720
      ],
      "parameters": {
        "text": "={{ '\ud83d\uddf3\ufe0f <b>Poll of the Day</b> \u2014 ' + $json.pollSession.category + '\\n\\n' + ($json.pollContent.hashtags || []).join(' ') + '\\n\\n\ud83d\udcca Tap your answer above and see how the community thinks! \ud83d\udc46' }}",
        "chatId": "={{ $json.targetGroups[$runIndex % $json.groupCount]?.groupId || $json.targetGroups[0].groupId }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "disable_notification": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2,
      "continueOnFail": true
    },
    {
      "id": "4f5bc2dd-2792-4db9-94f0-c6401468060e",
      "name": "Collect Deploy Result Per Group",
      "type": "n8n-nodes-base.code",
      "position": [
        656,
        624
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const pollResp = $('Send Poll to Telegram Group').item.json;\nconst msgResp = $('Send Context Message with Hashtags').item.json;\nconst validated = $('Validate Poll Quality and Safety').first().json;\n\nconst idx = $runIndex || 0;\nconst grp = validated.targetGroups[idx] || validated.targetGroups[0];\n\nconst pollOk = pollResp?.ok === true || pollResp?.result?.message_id != null;\nconst pollErr = !pollOk ? (pollResp?.description || pollResp?.error || 'Unknown Telegram error') : null;\nconst msgOk = msgResp?.ok === true || msgResp?.result?.message_id != null;\n\nreturn {\n  json: {\n    pollSession: validated.pollSession,\n    pollContent: validated.pollContent,\n    groupResult: {\n      groupId: grp?.groupId || 'UNKNOWN',\n      groupName: grp?.groupName || 'Unknown Group',\n      groupType: grp?.groupType || 'group',\n      pollSent: pollOk,\n      contextMsgSent: msgOk,\n      pollMessageId: pollResp?.result?.message_id || null,\n      errorMessage: pollErr,\n      deployedAt: new Date().toISOString()\n    }\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "e8d6bc92-30e5-4add-a1ca-f11d7d209212",
      "name": "Merge All Group Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        880,
        624
      ],
      "parameters": {
        "mode": "mergeByPosition"
      },
      "typeVersion": 3
    },
    {
      "id": "ac913e0b-4054-4e08-97f6-6b3b49ae8b91",
      "name": "Build Analytics Summary",
      "type": "n8n-nodes-base.code",
      "position": [
        1104,
        624
      ],
      "parameters": {
        "jsCode": "const all = $input.all().map(i => i.json);\nif (!all.length) throw new Error('No deploy results to summarise.');\n\nconst first = all[0];\nconst pollSession = first.pollSession;\nconst pollContent = first.pollContent;\nconst groupResults = all.map(r => r.groupResult);\n\nconst ok = groupResults.filter(g => g.pollSent);\nconst fail = groupResults.filter(g => !g.pollSent);\nconst successRate = groupResults.length > 0 ? Math.round((ok.length / groupResults.length) * 100) : 0;\n\n// Telegram admin message (MarkdownV2-safe)\nconst adminLines = [\n  `\ud83d\udcca *Poll Deployed*`,\n  ``,\n  `\ud83c\udd94 \\`${pollSession.pollId}\\``,\n  `\ud83d\udccc *${pollSession.topic}*`,\n  `\ud83c\udff7\ufe0f Category: ${pollSession.category}`,\n  `\u2753 _${pollContent.question}_`,\n  ``,\n  `\ud83d\udce4 Groups targeted: *${groupResults.length}*`,\n  `\u2705 Successful: *${ok.length}*`,\n  `\u274c Failed: *${fail.length}*`,\n  `\ud83d\udcc8 Success rate: *${successRate}%*`,\n  `\ud83c\udfaf Engagement score: *${pollContent.engagementScore}/100*`,\n  ``\n];\nif (fail.length > 0) {\n  adminLines.push(`\u26a0\ufe0f *Failed groups:*`);\n  fail.forEach(g => adminLines.push(`\u2022 ${g.groupName}: ${g.errorMessage || 'error'}`) );\n}\nadminLines.push(`\\n\u23f1\ufe0f ${new Date().toISOString()}`);\n\nreturn [{\n  json: {\n    pollSession,\n    pollContent,\n    groupResults,\n    deploymentSummary: {\n      totalGroups: groupResults.length,\n      successfulGroups: ok.length,\n      failedGroups: fail.length,\n      successRate,\n      failedGroupDetails: fail.map(g => ({ groupId: g.groupId, groupName: g.groupName, error: g.errorMessage })),\n      completedAt: new Date().toISOString()\n    },\n    adminSummaryText: adminLines.join('\\n')\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "b334e64f-dadc-4bd8-8761-7b3377ecca35",
      "name": "Log Analytics to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1328,
        336
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "="
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "="
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5,
      "continueOnFail": true
    },
    {
      "id": "8f589c91-05f1-4806-8e59-3d8fb3b88700",
      "name": "Send Admin Telegram Notification",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1328,
        528
      ],
      "parameters": {
        "text": "={{ $json.adminSummaryText }}",
        "chatId": "YOUR_ADMIN_TELEGRAM_CHAT_ID",
        "additionalFields": {
          "parse_mode": "Markdown",
          "disable_notification": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2,
      "continueOnFail": true
    },
    {
      "id": "596f8666-0e28-492b-b776-d69a1d7b7798",
      "name": "Send Error Alert Email on Failures",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1328,
        720
      ],
      "parameters": {
        "options": {},
        "subject": "=[Telegram Poll] {{ $json.deploymentSummary.failedGroups }} Group(s) Failed \u2014 {{ $json.pollSession.pollId }}",
        "toEmail": "=",
        "fromEmail": "="
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1,
      "continueOnFail": true
    },
    {
      "id": "f5275907-79c8-4012-94c8-295a5917d6fd",
      "name": "Update Topic Queue \u2014 Mark Used",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1328,
        912
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "="
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "="
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5,
      "continueOnFail": true
    },
    {
      "id": "42fb3d31-c6c5-4e09-8f0b-41c57e34579f",
      "name": "Build Final Deployment Report",
      "type": "n8n-nodes-base.code",
      "position": [
        1552,
        624
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const d = $input.item.json;\nreturn {\n  json: {\n    success: true,\n    pollId: d.pollSession.pollId,\n    topic: d.pollSession.topic,\n    category: d.pollSession.category,\n    question: d.pollContent.question,\n    options: d.pollContent.options,\n    engagementScore: d.pollContent.engagementScore,\n    deployment: d.deploymentSummary,\n    scheduledAt: d.pollSession.scheduledAt,\n    completedAt: d.deploymentSummary.completedAt,\n    credit: {\n      poweredBy: 'GPT-4o via n8n OpenAI integration',\n      moreAutomation: 'https://www.oneclickitsolution.com/contact-us/'\n    }\n  }\n};"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3b08e829-cac2-4c89-b251-f5f8c4c92744",
  "connections": {
    "GPT-4o Model": {
      "ai_languageModel": [
        [
          {
            "node": "GPT-4 Poll Question Generation",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Poll Schedule Trigger": {
      "main": [
        [
          {
            "node": "Load Topic Queue from Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Analytics Summary": {
      "main": [
        [
          {
            "node": "Log Analytics to Google Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Admin Telegram Notification",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Error Alert Email on Failures",
            "type": "main",
            "index": 0
          },
          {
            "node": "Update Topic Queue \u2014 Mark Used",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge All Group Results": {
      "main": [
        [
          {
            "node": "Build Analytics Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Poll to Telegram Group": {
      "main": [
        [
          {
            "node": "Collect Deploy Result Per Group",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Telegram Group Registry": {
      "main": [
        [
          {
            "node": "Validate Poll Quality and Safety",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Topic Queue from Sheets": {
      "main": [
        [
          {
            "node": "Select Highest Priority Topic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Highest Priority Topic": {
      "main": [
        [
          {
            "node": "Load Telegram Group Registry",
            "type": "main",
            "index": 0
          },
          {
            "node": "GPT-4 Poll Question Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4 Poll Question Generation": {
      "main": [
        [
          {
            "node": "Validate Poll Quality and Safety",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Analytics to Google Sheets": {
      "main": [
        [
          {
            "node": "Build Final Deployment Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Deploy Result Per Group": {
      "main": [
        [
          {
            "node": "Merge All Group Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Admin Telegram Notification": {
      "main": [
        [
          {
            "node": "Build Final Deployment Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Groups for Parallel Deploy": {
      "main": [
        [
          {
            "node": "Send Poll to Telegram Group",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Context Message with Hashtags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Topic Queue \u2014 Mark Used": {
      "main": [
        [
          {
            "node": "Build Final Deployment Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Poll Quality and Safety": {
      "main": [
        [
          {
            "node": "Split Groups for Parallel Deploy",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Context Message with Hashtags": {
      "main": [
        [
          {
            "node": "Collect Deploy Result Per Group",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Error Alert Email on Failures": {
      "main": [
        [
          {
            "node": "Build Final Deployment Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

An enterprise-grade n8n workflow that leverages OpenAI GPT-4 to generate contextually relevant poll questions and automatically distributes them across multiple Telegram groups and channels. Includes comprehensive analytics tracking, smart error handling, real-time admin…

Source: https://n8n.io/workflows/10383/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

staying consistent with personal brand content is hard when you're running everything yourself. you know what you want to say — but turning raw thoughts into polished posts takes hours.

Output Parser Structured, Telegram, OpenAI +4
AI & RAG

Online Marketing Weekly Report. Uses scheduleTrigger, lmChatOpenAi, toolWorkflow, executeWorkflowTrigger. Scheduled trigger; 51 nodes.

OpenAI Chat, Tool Workflow, Execute Workflow Trigger +8
AI & RAG

This workflow retrieves Online Marketing data (Google Analytics for several domains, Google Ads, Meta Ads) from the last 7 days and the same period in the previous year. The data is then prepared by A

OpenAI Chat, Tool Workflow, Execute Workflow Trigger +8
AI & RAG

This workflow automates the process of generating, reviewing, and publishing blog posts across multiple platforms, now enhanced with support for RSS Feeds as a content source. It streamlines the manag

HTTP Request, Html Extract, RSS Feed Read +9
AI & RAG

Template Name: AI Personal Assistant - Task & Email Management Price: $27 Category: Productivity & Automation Difficulty: Intermediate Use Case: Personal productivity automation for busy professionals

Telegram, HTTP Request, OpenAI +8