8
n8n 中文网amn8n.com

使用Telegram、Google表格和AI创建产品满意度调查

高级

这是一个Engineering, Product, AI领域的自动化工作流,包含 40 个节点。主要使用 If, Set, Redis, Switch, Telegram 等节点,结合人工智能技术实现智能自动化。 通过Telegram、Google表格和AI创建产品满意度调查

前置要求
  • Redis 服务器连接信息
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "c537229c-ffdf-4a4b-8cdd-1d88621e58a0",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1060,
        2060
      ],
      "webhookId": "1b9f2217-7c53-4440-b62b-aafcf1e1d45d",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "wJqs1eMdbjilZH1W",
          "name": "jimleuk_ai_survey_demo_bot"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "90426896-35d8-4449-8607-70e8485441ed",
      "name": "发送下一个问题",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2560,
        1900
      ],
      "webhookId": "4306c719-0b05-4986-8ea8-8bcda06e0ad1",
      "parameters": {
        "text": "={{ $('Get Survey State1').first().json.next_question_idx }}. {{ Object.values($('Get Columns1').first().json)[$('Get Survey State1').first().json.next_question_idx+1] }}",
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "wJqs1eMdbjilZH1W",
          "name": "jimleuk_ai_survey_demo_bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "614b6d06-7bca-4710-aebf-3a2a685ace09",
      "name": "发送响应",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1540,
        2540
      ],
      "webhookId": "dd1c616f-891c-48d4-8828-e612b13bca63",
      "parameters": {
        "text": "={{ $('Interview Agent1').first().json.output }}",
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "wJqs1eMdbjilZH1W",
          "name": "jimleuk_ai_survey_demo_bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c7f7acc4-c3f7-4fae-98dd-25dca9caae8b",
      "name": "没有记录?",
      "type": "n8n-nodes-base.if",
      "position": [
        60,
        2260
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a9f08592-d870-44a4-a7f9-d70193cf721b",
              "operator": {
                "type": "object",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "207a2647-56eb-419a-8269-9a32edabe43a",
      "name": "调查是否继续?",
      "type": "n8n-nodes-base.if",
      "position": [
        1980,
        2060
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5685829b-a2b2-42c8-b6bc-22eaa03db1d2",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              },
              "leftValue": "={{ $('Increment Index1').item.json.is_survey_complete }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a8e98579-6afa-4d7d-859d-9e635a0a1b0c",
      "name": "获取状态2",
      "type": "n8n-nodes-base.redis",
      "position": [
        -520,
        2060
      ],
      "parameters": {
        "key": "={{ $json.cacheKey }}",
        "options": {},
        "operation": "get",
        "propertyName": "data"
      },
      "credentials": {
        "redis": {
          "id": "zU4DA70qSDrZM1El",
          "name": "Redis account (localhost)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8074143c-eab7-4146-937c-16c44ef40333",
      "name": "获取列1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1440,
        2060
      ],
      "parameters": {
        "options": {
          "dataLocationOnSheet": {
            "values": {
              "firstDataRow": 1,
              "rangeDefinition": "specifyRange"
            }
          }
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1KMNqWWO36osZx7jF-i1UL53z2GZnCn9fiBjtlGpvWB4/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Set Variables1').first().json.gsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "XHvC7jIRR8A2TlUl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "1f75f3fc-7893-444d-8a1e-59ec3d42ea1d",
      "name": "设置变量1",
      "type": "n8n-nodes-base.set",
      "position": [
        -880,
        2060
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2140b769-2e90-4828-8022-1b0a9baf6e44",
              "name": "title",
              "type": "string",
              "value": "Product Satisfaction Survey: DJI Mini 2"
            },
            {
              "id": "fb7110cb-82d3-4c95-81ba-ac97a26fe05e",
              "name": "gsheetId",
              "type": "string",
              "value": "1KMNqWWO36osZx7jF-i1UL53z2GZnCn9fiBjtlGpvWB4"
            },
            {
              "id": "6d9c4b02-8326-49f4-ac22-24bdec7fdd67",
              "name": "cacheKey",
              "type": "string",
              "value": "=survey_user_{{ $json.sessionId }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "a0c06eb9-46d6-4888-85b0-e9a31a31337b",
      "name": "消息类型1",
      "type": "n8n-nodes-base.switch",
      "position": [
        -320,
        2060
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "is_bot_command",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f5fa8b7c-fdda-4c6d-b610-e243d6299598",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ ['/start','/next', '/reset'].includes($('Telegram Trigger').first().json.message.text) }}",
                    "rightValue": "="
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "is_normal_message"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "315585fe-d2e4-4cb1-9d0e-a3e8bc053da3",
      "name": "获取命令1",
      "type": "n8n-nodes-base.set",
      "position": [
        -120,
        1760
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "73335bd3-ce50-46c5-8bcf-f7b8cd992208",
              "name": "command",
              "type": "string",
              "value": "={{ $('Telegram Trigger').first().json.message.text.slice($('Telegram Trigger').first().json.message.entities[0].offset, $('Telegram Trigger').first().json.message.entities[0].length ) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7036d250-0271-4c93-9f60-01b9ccaf8be3",
      "name": "机器人操作1",
      "type": "n8n-nodes-base.switch",
      "position": [
        60,
        1760
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "new_session",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6f427c86-090d-429a-bc99-d2dd7753c153",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Get Command1').first().json.command === '/start' }}",
                    "rightValue": "/start"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "next_question",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bca60df4-278d-4598-afc9-6e8ee61b7ac5",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Get Command1').first().json.command === '/next' }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "fa755815-29c2-419e-8e36-51102ee88681",
      "name": "记忆存储3",
      "type": "@n8n/n8n-nodes-langchain.memoryRedisChat",
      "position": [
        2220,
        2060
      ],
      "parameters": {
        "sessionKey": "={{ $('Set Variables1').first().json.cacheKey }}_history",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "credentials": {
        "redis": {
          "id": "zU4DA70qSDrZM1El",
          "name": "Redis account (localhost)"
        }
      },
      "typeVersion": 1.4
    },
    {
      "id": "a231e026-e5bf-4864-a57b-29d01e32e1a8",
      "name": "获取调查状态1",
      "type": "n8n-nodes-base.set",
      "position": [
        1620,
        2060
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6836a5aa-2b51-48cc-8d8f-d64a85d8a52f",
              "name": "title",
              "type": "string",
              "value": "={{ Object.values($json)[1] }}"
            },
            {
              "id": "7b2fdf1b-4f55-4b55-be54-a7b97dd094cb",
              "name": "num_questions",
              "type": "number",
              "value": "={{ Object.keys($json).length - 2 }}"
            },
            {
              "id": "dc6d5c41-0f35-49c9-b9c9-b6b4f2ceb66c",
              "name": "next_question_idx",
              "type": "number",
              "value": "={{ (Number($('Get State3').first().json.data?.current_question_idx) || 0) + 1 }}"
            },
            {
              "id": "8b17703f-fbff-40d2-a7bb-d450f2edfea3",
              "name": "is_survey_complete",
              "type": "boolean",
              "value": "={{ ((Number($('Get State3').first().json.data?.current_question_idx) || 0) + 1) >= (Object.keys($json).length - 1) }}"
            }
          ]
        }
      },
      "executeOnce": true,
      "typeVersion": 3.4
    },
    {
      "id": "a3bb744d-c59f-45a9-8b9d-3c291fa8d860",
      "name": "重置代理记忆1",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "position": [
        2240,
        1900
      ],
      "parameters": {
        "mode": "insert",
        "messages": {
          "messageValues": [
            {
              "message": "=You are a curious and inquisitive researcher conducting a survey with a user.\n* In this conversation, you are only interested in one of the questions from the survey which you will ask.\n* When asking an open-ended question, converse with the user to dig deeper into their answer and reveal insights into the user's experience. Do not ask other questions which do not try to expand the user's answer to the initial question.\n* If this is closed-ended question, it is okay to receive a static response and move on to the next question.\n* Only the initial question is numbered, following questions or messages should not be numbered or bulletpointed.\n* If the user goes off-topic, doesn't want to answer the question or wants to do something else which is not related to the survey, then ignore what they say/ask and politely repeat the question."
            },
            {
              "type": "ai",
              "message": "={{ $('Get Survey State1').first().json.next_question_idx }}. {{ Object.values($('Get Columns1').first().json)[$('Get Survey State1').first().json.next_question_idx+1] }}"
            }
          ]
        },
        "insertMode": "override"
      },
      "typeVersion": 1.1
    },
    {
      "id": "b9d693b7-c139-45d8-b0d8-fd8134c7ba84",
      "name": "记忆存储4",
      "type": "@n8n/n8n-nodes-langchain.memoryRedisChat",
      "position": [
        1120,
        2700
      ],
      "parameters": {
        "sessionKey": "={{ $('Set Variables1').first().json.cacheKey }}_history",
        "sessionIdType": "customKey",
        "contextWindowLength": 100
      },
      "credentials": {
        "redis": {
          "id": "zU4DA70qSDrZM1El",
          "name": "Redis account (localhost)"
        }
      },
      "typeVersion": 1.4
    },
    {
      "id": "c8fd56f5-c4c0-40cb-b727-07a94b633657",
      "name": "启动会话1",
      "type": "n8n-nodes-base.redis",
      "position": [
        440,
        1620
      ],
      "parameters": {
        "key": "={{ $('Set Variables1').first().json.cacheKey }}",
        "value": "={{\n{\n  \"has_session\": true,\n  \"session_createdAt\": $now,\n  \"current_question_idx\": 0\n}\n}}",
        "keyType": "hash",
        "operation": "set"
      },
      "credentials": {
        "redis": {
          "id": "zU4DA70qSDrZM1El",
          "name": "Redis account (localhost)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "02eaa2cf-512c-4526-948e-b68989b3a8f4",
      "name": "获取状态3",
      "type": "n8n-nodes-base.redis",
      "position": [
        1260,
        2060
      ],
      "parameters": {
        "key": "={{ $('Set Variables1').first().json.cacheKey }}",
        "options": {},
        "operation": "get",
        "propertyName": "data"
      },
      "credentials": {
        "redis": {
          "id": "zU4DA70qSDrZM1El",
          "name": "Redis account (localhost)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "85631c2a-9317-4b14-92d1-895ac022eb70",
      "name": "递增索引1",
      "type": "n8n-nodes-base.redis",
      "position": [
        1800,
        2060
      ],
      "parameters": {
        "key": "={{ $('Set Variables1').first().json.cacheKey }}",
        "value": "={{\n{\n  \"current_question_idx\": $json.next_question_idx < $json.num_questions\n    ? $json.next_question_idx\n    : $json.num_questions,\n  \"session_updated\": $now,\n}\n}}",
        "keyType": "hash",
        "operation": "set"
      },
      "credentials": {
        "redis": {
          "id": "zU4DA70qSDrZM1El",
          "name": "Redis account (localhost)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4464f6fe-d579-4e03-a8ca-918515d38b30",
      "name": "访谈代理1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1040,
        2540
      ],
      "parameters": {
        "text": "={{ $('Telegram Trigger').first().json.message.text }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "11ec3d5a-5f89-4a84-96ef-291526ae7365",
      "name": "获取记录1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -120,
        2260
      ],
      "parameters": {
        "options": {
          "returnFirstMatch": true
        },
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $('Telegram Trigger').first().json.message.from.id }}",
              "lookupColumn": "ID"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1KMNqWWO36osZx7jF-i1UL53z2GZnCn9fiBjtlGpvWB4/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Set Variables1').first().json.gsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "XHvC7jIRR8A2TlUl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5,
      "alwaysOutputData": true
    },
    {
      "id": "665d58f8-ba2f-4d87-ae56-260333c5ecdf",
      "name": "追加回复1",
      "type": "n8n-nodes-base.set",
      "position": [
        440,
        2440
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8069d106-0918-4bc3-9f49-789322129136",
              "name": "payload",
              "type": "string",
              "value": "={{\n[\n  Object.values($('Get Record1').first().json)[Number($('Get State2').first().json.data.current_question_idx || 0) + 1],\n  'User: ' + $('Telegram Trigger').first().json.message.text,\n].join('\\n\\n').trim()\n}}"
            },
            {
              "id": "d25c278c-d3a9-4a5a-9f49-01ee3ca8285a",
              "name": "cell",
              "type": "string",
              "value": "={{\n'abcdefghijklmnopqrstuvxyz'.toUpperCase().split('')[$('Message Type1').first().json.data.current_question_idx]\n}}{{ $('Get Record1').first().json.row_number }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4771e9e4-8b79-4530-8c4a-6e7ab0623d98",
      "name": "更新答案2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1360,
        2540
      ],
      "parameters": {
        "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $('Set Variables1').first().json.gsheetId }}/values/Sheet1!{{ $('Append Responses1').first().json.cell }}",
        "method": "PUT",
        "options": {},
        "jsonBody": "={{\n{\n  \"range\": `Sheet1!${$('Append Responses1').first().json.cell}`,\n  \"majorDimension\": \"ROWS\",\n  \"values\": [[\n    $('Append Responses1').first().json.payload + '\\n\\nAgent: ' + $('Interview Agent1').first().json.output]]\n}\n}}",
        "sendBody": true,
        "sendQuery": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "valueInputOption",
              "value": "RAW"
            }
          ]
        },
        "nodeCredentialType": "googleSheetsOAuth2Api"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "XHvC7jIRR8A2TlUl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b7094d87-97ce-4f1a-8d30-4d6d57d24477",
      "name": "获取最后机器人消息1",
      "type": "n8n-nodes-base.redis",
      "position": [
        260,
        2440
      ],
      "parameters": {
        "key": "={{ $('Set Variables1').item.json.cacheKey }}_history",
        "options": {},
        "operation": "get",
        "propertyName": "data"
      },
      "credentials": {
        "redis": {
          "id": "zU4DA70qSDrZM1El",
          "name": "Redis account (localhost)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6dc77f41-6c3b-4358-82bc-2ea299ef69b2",
      "name": "更新答案3",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1020,
        2180
      ],
      "parameters": {
        "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $('Set Variables1').first().json.gsheetId }}/values/Sheet1!{{ $('Append Responses1').first().json.cell }}",
        "method": "PUT",
        "options": {},
        "jsonBody": "={{\n{\n  \"range\": `Sheet1!${$('Append Responses1').first().json.cell}`,\n  \"majorDimension\": \"ROWS\",\n  \"values\": [[$('Append Responses1').first().json.payload]]\n}\n}}",
        "sendBody": true,
        "sendQuery": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "valueInputOption",
              "value": "RAW"
            }
          ]
        },
        "nodeCredentialType": "googleSheetsOAuth2Api"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "XHvC7jIRR8A2TlUl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "dd67ca61-b36c-4f9f-84fe-0b25d411e459",
      "name": "模型2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1000,
        2700
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "8gccIjcuf3gvaoEr",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "57698127-eea0-434e-af3a-4d49db4a7f15",
      "name": "模型3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        600,
        2600
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "8gccIjcuf3gvaoEr",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bad16467-bb3c-4d50-9dd8-014bac25fd61",
      "name": "需要跟进?1",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        620,
        2440
      ],
      "parameters": {
        "options": {},
        "inputText": "=AI: {{ $('Get Last Bot Message1').item.json.data?.first().parseJson().data.content ?? ''}}\nUSER: {{ $('Telegram Trigger').first().json.message.text }}",
        "categories": {
          "categories": [
            {
              "category": "should_not_ask_followup_questions",
              "description": "=Either\n* The user was asked a close-ended question and gave an adequate static response\n* There are no further insights to be learned from the user's answer"
            },
            {
              "category": "should_ask_followup_questions",
              "description": "=Either one of\n* There are possibly more insights to be learned from the user's answer if we enquire. hint: did the user explaied or justified their answer?\n* The user didn't answer the question"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "86545380-9ff1-4815-bfaf-c4137fa00fda",
      "name": "执行数据2",
      "type": "n8n-nodes-base.executionData",
      "position": [
        -700,
        2060
      ],
      "parameters": {
        "dataToSave": {
          "values": [
            {
              "key": "jobType",
              "value": "=state_message"
            },
            {
              "key": "gsheetId",
              "value": "={{ $json.gsheetId }}"
            },
            {
              "key": "title",
              "value": "={{ $json.title }}"
            },
            {
              "key": "fromId",
              "value": "={{ $('Telegram Trigger').item.json.message.from.id }}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ed16f03b-621e-4766-b8fd-f1f662b2dd0b",
      "name": "创建记录2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        260,
        2060
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Telegram Trigger').first().json.message.from.id }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "What's your name?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "What's your name?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "What were the main factors that influenced your decision to purchase the DJI Mini 2?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "What were the main factors that influenced your decision to purchase the DJI Mini 2?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Did you compare the DJI Mini 2 with other drone models before purchasing? If yes, which other drone models were you considering? ",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Did you compare the DJI Mini 2 with other drone models before purchasing? If yes, which other drone models were you considering? ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "What ultimately convinced you to choose the DJI Mini 2 over other options?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "What ultimately convinced you to choose the DJI Mini 2 over other options?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How satisfied are you with the DJI Mini 2?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "How satisfied are you with the DJI Mini 2?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "What features do you like most about the DJI Mini 2?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "What features do you like most about the DJI Mini 2?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Are there any features you feel are missing or could be improved?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Are there any features you feel are missing or could be improved?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Have you experienced any technical issues with the DJI Mini 2?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Have you experienced any technical issues with the DJI Mini 2?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How likely are you to recommend the DJI Mini 2 to others?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "How likely are you to recommend the DJI Mini 2 to others?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Where did you purchase your DJI Mini 2?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Where did you purchase your DJI Mini 2?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How was your overall purchase experience?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "How was your overall purchase experience?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Did you find all the information you needed before purchasing?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Did you find all the information you needed before purchasing?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "If you interacted with DJI customer support, how would you rate the experience?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "If you interacted with DJI customer support, how would you rate the experience?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How can DJI improve the Mini 2 or future drone models?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "How can DJI improve the Mini 2 or future drone models?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How can DJI improve the overall shopping and customer service experience?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "How can DJI improve the overall shopping and customer service experience?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Any additional comments or feedback?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Any additional comments or feedback?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1KMNqWWO36osZx7jF-i1UL53z2GZnCn9fiBjtlGpvWB4/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Set Variables1').first().json.gsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "XHvC7jIRR8A2TlUl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5,
      "alwaysOutputData": true
    },
    {
      "id": "f2119ef5-aef3-4b0f-80f5-1715a4afe3e0",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        1820
      ],
      "parameters": {
        "color": 7,
        "width": 760,
        "height": 500,
        "content": "## 1. 通过邀请用户聊天来启动调查"
      },
      "typeVersion": 1
    },
    {
      "id": "9e7ca15c-0e31-4d78-b8af-31fd6260cd61",
      "name": "发送开始",
      "type": "n8n-nodes-base.telegram",
      "position": [
        600,
        1620
      ],
      "webhookId": "c5d13268-df58-450b-84c4-a61cd2e027ed",
      "parameters": {
        "text": "={{ $('Set Variables1').first().json.title }}.\nWelcome! Thank you for taking the time to participate in our survey.\n\nYou'll be asked a couple of pre-defined questions. For each question, we may ask follow-up questions to better understand your situation. If you want to skip to the next question at any time, simply reply with the \"/next\". Your responses will be recorded.\n\nTo start the survey, simply reply with \"/next\".",
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "wJqs1eMdbjilZH1W",
          "name": "jimleuk_ai_survey_demo_bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e8be2d00-39c8-4dd1-a597-813fc4bffe10",
      "name": "发送开始1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        260,
        1900
      ],
      "webhookId": "c5d13268-df58-450b-84c4-a61cd2e027ed",
      "parameters": {
        "text": "=Sorry, that command is unrecognised. The available options are /start or /next.",
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "wJqs1eMdbjilZH1W",
          "name": "jimleuk_ai_survey_demo_bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "153bbe8b-52bc-403c-ae5f-346060a5aac3",
      "name": "已完成调查",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2220,
        2280
      ],
      "webhookId": "409dbc48-4916-415b-8c1b-caf3b359e1e4",
      "parameters": {
        "text": "=Done! Thank you for completing our survey.\nTo start the survey again, use \"/start\".",
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "wJqs1eMdbjilZH1W",
          "name": "jimleuk_ai_survey_demo_bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c2e39206-f586-4c90-aeb0-d6a141e81d1d",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -180,
        1540
      ],
      "parameters": {
        "color": 7,
        "width": 420,
        "height": 380,
        "content": "## 2. 处理机器人命令"
      },
      "typeVersion": 1
    },
    {
      "id": "6b6241ae-17b7-4f0f-9c00-f5de4d62f692",
      "name": "创建记录1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        280,
        1620
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Telegram Trigger').first().json.message.from.id }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "What's your name?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "What's your name?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "What were the main factors that influenced your decision to purchase the DJI Mini 2?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "What were the main factors that influenced your decision to purchase the DJI Mini 2?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Did you compare the DJI Mini 2 with other drone models before purchasing? If yes, which other drone models were you considering? ",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Did you compare the DJI Mini 2 with other drone models before purchasing? If yes, which other drone models were you considering? ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "What ultimately convinced you to choose the DJI Mini 2 over other options?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "What ultimately convinced you to choose the DJI Mini 2 over other options?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How satisfied are you with the DJI Mini 2?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "How satisfied are you with the DJI Mini 2?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "What features do you like most about the DJI Mini 2?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "What features do you like most about the DJI Mini 2?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Are there any features you feel are missing or could be improved?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Are there any features you feel are missing or could be improved?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Have you experienced any technical issues with the DJI Mini 2?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Have you experienced any technical issues with the DJI Mini 2?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How likely are you to recommend the DJI Mini 2 to others?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "How likely are you to recommend the DJI Mini 2 to others?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Where did you purchase your DJI Mini 2?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Where did you purchase your DJI Mini 2?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How was your overall purchase experience?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "How was your overall purchase experience?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Did you find all the information you needed before purchasing?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Did you find all the information you needed before purchasing?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "If you interacted with DJI customer support, how would you rate the experience?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "If you interacted with DJI customer support, how would you rate the experience?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How can DJI improve the Mini 2 or future drone models?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "How can DJI improve the Mini 2 or future drone models?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How can DJI improve the overall shopping and customer service experience?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "How can DJI improve the overall shopping and customer service experience?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Any additional comments or feedback?",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Any additional comments or feedback?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1KMNqWWO36osZx7jF-i1UL53z2GZnCn9fiBjtlGpvWB4/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Set Variables1').first().json.gsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "XHvC7jIRR8A2TlUl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5,
      "alwaysOutputData": true
    },
    {
      "id": "f8f6b582-75d7-40a1-95a5-c1b80fa41c64",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        520,
        2180
      ],
      "parameters": {
        "color": 7,
        "width": 440,
        "height": 420,
        "content": "## 3. 支持跟进问题"
      },
      "typeVersion": 1
    },
    {
      "id": "5aa8956b-787d-4b4a-b4dc-a2415434a331",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        980,
        2340
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 500,
        "content": "## 4. 通过对话式 AI 代理获得更深入的洞察"
      },
      "typeVersion": 1
    },
    {
      "id": "aa304745-6d30-4fdb-8279-eb505ee06a61",
      "name": "便利贴5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        1820
      ],
      "parameters": {
        "color": 7,
        "width": 740,
        "height": 380,
        "content": "## 5. 使用外部状态管理对话流程"
      },
      "typeVersion": 1
    },
    {
      "id": "4ce7ce73-d771-4794-b1fb-87c15ccdbdaf",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2160,
        1680
      ],
      "parameters": {
        "color": 7,
        "width": 620,
        "height": 520,
        "content": "## 6. 为每个问题重置聊天记忆"
      },
      "typeVersion": 1
    },
    {
      "id": "2b26317c-6ba6-4ff0-92a6-525cce9e725d",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1740,
        1300
      ],
      "parameters": {
        "width": 580,
        "height": 1020,
        "content": "## 试试看"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Interview Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Should Follow Up?1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Memory3": {
      "ai_memory": [
        [
          {
            "node": "Reset Agent Memory1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Memory4": {
      "ai_memory": [
        [
          {
            "node": "Interview Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Get State2": {
      "main": [
        [
          {
            "node": "Message Type1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get State3": {
      "main": [
        [
          {
            "node": "Get Columns1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Start": {
      "main": [
        []
      ]
    },
    "Get Record1": {
      "main": [
        [
          {
            "node": "Has No Record?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Start1": {
      "main": [
        []
      ]
    },
    "Bot Actions1": {
      "main": [
        [
          {
            "node": "Create Record1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get State3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Start1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Columns1": {
      "main": [
        [
          {
            "node": "Get Survey State1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Command1": {
      "main": [
        [
          {
            "node": "Bot Actions1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message Type1": {
      "main": [
        [
          {
            "node": "Get Command1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Record1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Response": {
      "main": [
        []
      ]
    },
    "Create Record1": {
      "main": [
        [
          {
            "node": "Start Session1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Record2": {
      "main": [
        [
          {
            "node": "Get State3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has No Record?": {
      "main": [
        [
          {
            "node": "Create Record2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Last Bot Message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Variables1": {
      "main": [
        [
          {
            "node": "Execution Data2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Session1": {
      "main": [
        [
          {
            "node": "Send Start",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Answer2": {
      "main": [
        [
          {
            "node": "Send Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Answer3": {
      "main": [
        [
          {
            "node": "Get State3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execution Data2": {
      "main": [
        [
          {
            "node": "Get State2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Increment Index1": {
      "main": [
        [
          {
            "node": "Is Survey Continue?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Interview Agent1": {
      "main": [
        [
          {
            "node": "Update Answer2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Set Variables1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Responses1": {
      "main": [
        [
          {
            "node": "Should Follow Up?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Survey State1": {
      "main": [
        [
          {
            "node": "Increment Index1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Next Question": {
      "main": [
        []
      ]
    },
    "Should Follow Up?1": {
      "main": [
        [
          {
            "node": "Update Answer3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Interview Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Survey Continue?": {
      "main": [
        [
          {
            "node": "Reset Agent Memory1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Completed Survey",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reset Agent Memory1": {
      "main": [
        [
          {
            "node": "Send Next Question",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Last Bot Message1": {
      "main": [
        [
          {
            "node": "Append Responses1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 工程, 产品, 人工智能

需要付费吗?

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

工作流信息
难度等级
高级
节点数量40
分类3
节点类型15
难度说明

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

作者
Jimleuk

Jimleuk

@jimleuk

Freelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at hello@jimle.uk LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk

外部链接
在 n8n.io 查看

分享此工作流