8
n8n 中文网amn8n.com

WhatsApp/Telegram WooCommerce订单支持

高级

这是一个Support Chatbot, AI Chatbot领域的自动化工作流,包含 25 个节点。主要使用 Set, Gmail, Merge, Switch, Telegram 等节点。 通过Telegram和Gmail使用Gemini和GPT自动化WooCommerce客户支持

前置要求
  • Google 账号和 Gmail API 凭证
  • Telegram Bot Token
  • OpenAI API Key
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "4w6vXQK63QpwF3JW",
  "meta": {
    "instanceId": "f50c4225657041a867073dfd116003f9f3659e08e71fb6a5bb5c90807373de2c",
    "templateCredsSetupCompleted": true
  },
  "name": "Whatsapp/Telegram WooCommerce Order support",
  "tags": [],
  "nodes": [
    {
      "id": "2835d72f-10eb-4b94-8e56-90413c74e89a",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        1072,
        1312
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "653d7db3-92d9-49e0-8f9e-a914bfb0754c",
      "name": "Get an order in WooCommerce",
      "type": "n8n-nodes-base.wooCommerceTool",
      "position": [
        2224,
        1616
      ],
      "parameters": {
        "orderId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Order_ID', ``, 'string') }}",
        "resource": "order",
        "operation": "get"
      },
      "credentials": {
        "wooCommerceApi": {
          "id": "VcCK1mcn5dJXCE8v",
          "name": "WooCommerce account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e5582697-96c2-41e1-b535-c1792bcfe362",
      "name": "Fetch user query",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        672,
        1024
      ],
      "webhookId": "b9ec78fc-178e-44fa-be5f-7b174f2e5921",
      "parameters": {
        "updates": [
          "message",
          "*"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "YlmcnSgYYsULTVHI",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b43894b4-bbc2-42f5-8be2-31283c2623c1",
      "name": "Fetch support mail",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        672,
        1472
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "readStatus": "unread"
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "LijDETbM9Mct4ycg",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "601f74d3-b435-4612-9ce5-eb7249f10d1f",
      "name": "Primary Model [Gemini 2.5 Flash]",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1504,
        1600
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "KbJ7zta7PFGQpS8v",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae55ba67-1a8e-4415-996d-1431529ffb25",
      "name": "Fallback Model [GPT 4.1 mini]",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1648,
        1600
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "jLsJ8GoQRONiXr61",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a1ad0dde-d2e9-48c6-bc27-a9cfa046f0b7",
      "name": "对话记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1936,
        1600
      ],
      "parameters": {
        "sessionKey": "={{ $('Set Manual Fields').item.json.conversation_id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "52e1e028-60aa-4f26-9e01-fed0c3637266",
      "name": "Set Manual Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1456,
        1312
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5595792e-a575-4e1c-9bbd-5b398f79613d",
              "name": "platform",
              "type": "string",
              "value": "={{ $json.message ? 'telegram' : 'gmail' }}"
            },
            {
              "id": "acab6a28-4cc4-430d-8f1d-32bb46e6ddae",
              "name": "sender_id",
              "type": "string",
              "value": "={{ $json.message ? $json.message.chat.id : $json.from.value[0].address }}"
            },
            {
              "id": "a2215038-320e-4130-a2e7-6e220c2ba614",
              "name": "query_text",
              "type": "string",
              "value": "={{ $json.message ? $json.message.text : ($json.text || $json.snippet) }}"
            },
            {
              "id": "155368c4-3720-45c3-88a8-32afe2d7cedd",
              "name": "reply_to_id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "7fbf6c01-9f2b-4326-8307-db17688f4cf2",
              "name": "conversation_id",
              "type": "string",
              "value": "={{ $json.message ? $json.message.chat.id : $json.threadId }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "873e594c-9a80-43fd-bb5b-697945fca750",
      "name": "Reply to Specific Platform",
      "type": "n8n-nodes-base.switch",
      "position": [
        2320,
        1312
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Telegram",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5dac6afb-45bd-47a8-9a4b-d1bcbbe25f02",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Set Manual Fields').item.json.platform }}",
                    "rightValue": "=telegram"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Mail",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2d5cbefc-3d7b-4015-89e4-1c612b5c1791",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Set Manual Fields').item.json.platform }}",
                    "rightValue": "gmail"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "21780180-84e5-4b4c-8ed0-2fa5056ba4c9",
      "name": "Send Telegram Response",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2672,
        1120
      ],
      "webhookId": "81d481f5-4374-4e96-b910-0e310320469b",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Set Manual Fields').item.json.sender_id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "YlmcnSgYYsULTVHI",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "33a5bc09-4397-4960-8888-c955739052ed",
      "name": "Send Response via Mail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2672,
        1424
      ],
      "webhookId": "e0201351-c15b-40d8-a106-c6dfc22b96f4",
      "parameters": {
        "message": "={{ $json.output }}",
        "options": {},
        "emailType": "text",
        "messageId": "={{ $('Set Manual Fields').item.json.reply_to_id }}",
        "operation": "reply"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "LijDETbM9Mct4ycg",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a050a96b-7439-49ad-b98d-237cb952faf8",
      "name": "Mark received mail as read",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3040,
        1424
      ],
      "webhookId": "40866be3-0ed6-4104-8dcb-7112eed93e6e",
      "parameters": {
        "messageId": "={{ $('Set Manual Fields').item.json.reply_to_id }}",
        "operation": "markAsRead"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "LijDETbM9Mct4ycg",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "8c082d22-44b4-44e0-8847-b588985cd8b8",
      "name": "WooCommerce Customer support Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1840,
        1312
      ],
      "parameters": {
        "text": "=You are a specialized customer support assistant for a WooCommerce store communicating via {{ $json.platform }}. Your one and only capability is to retrieve information about a customer's order.\n\nYou have access to a single tool: `Get an order in WooCommerce`. This tool requires an Order ID to work.\n\nFollow these rules strictly:\n\n1.  If the user asks about their order and provides a number that looks like an Order ID, use the `Get an order in WooCommerce` tool with that ID to find their order details.\n2.  If the user asks about their order status (e.g., \"Where is my package?\") but does NOT provide an Order ID, you MUST ask them for it. Do not attempt to answer without the ID. Simply respond with: \"I can help with that. Could you please provide your Order ID?\"\n3.  If the user asks any other question that is not about finding a specific order (e.g., \"What products do you have?\", \"What is your return policy?\", or general small talk), you must politely decline and state your purpose. Respond with: \"I can only assist with inquiries about existing orders. If you have an order you'd like to check on, please provide the Order ID.\"\n\n\n**Users Query:** {{ $json.query_text }}",
        "options": {},
        "promptType": "define",
        "needsFallback": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "3e44e6e8-dc34-4b26-9ee5-1c3cc82974c3",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        832
      ],
      "parameters": {
        "width": 368,
        "height": 400,
        "content": "## ✈️ Fetch user query\n\n* Acts as the real-time entry point for Telegram.\n* Uses a webhook for instant triggering.\n* Captures user message and chat ID.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2817c251-4b9d-4a30-9279-d6a9395ec4e1",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        1248
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 400,
        "content": "## 📥  Fetch support mail\n\n* Polls the Gmail inbox every minute.\n* Filters for `UNREAD` emails only.\n* \"Get Message\" option is ON to fetch the full body and headers.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "be7c848b-7187-453c-b3f3-1d3594c06b14",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        1024
      ],
      "parameters": {
        "color": 2,
        "width": 368,
        "height": 464,
        "content": "## 🔀 Merge\n\n* Unifies inputs from all triggers (Telegram & Gmail).\n* Creates a single data stream for processing.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "cb002988-3e3d-4168-b21c-c81d7d87937b",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1312,
        1024
      ],
      "parameters": {
        "color": 6,
        "width": 384,
        "height": 464,
        "content": "## 🏷️ Set Manual Fields\n\n* Normalizes data from all platforms into a standard format.\n* Creates universal fields like `platform`, `sender_id`, and `query_text`.\n* **CRUCIAL:** Makes the rest of the workflow channel-agnostic."
      },
      "typeVersion": 1
    },
    {
      "id": "f7526f40-942d-4697-89d1-c66873a36173",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1712,
        1024
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 464,
        "content": "## 🧠 WooCommerce Customer support Agent\n\n- **Function:** Acts as the AI \"brain\" to understand user intent, use tools, and formulate replies.\n- **Input:** The normalized `query_text`, conversation history from Memory, and available Tools.\n- **Output:** A JSON object containing the final `output` text to be sent to the user.\n- **Note:** This node orchestrates the entire conversation and logic flow."
      },
      "typeVersion": 1
    },
    {
      "id": "e712bf53-d3d3-4dca-8a84-3b35b66ffb28",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        1504
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 400,
        "content": "## 🚀 AI Language Engines\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n* Provide the language processing power for the AI Agent.\n* Uses Primary (Gemini) first, then Fallback (GPT) on error.\n* Ensures high reliability for the bot.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "d1e67a2c-07db-409f-88da-31f2c8fa29e6",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1840,
        1504
      ],
      "parameters": {
        "color": 4,
        "width": 272,
        "height": 400,
        "content": "## 📜 Conversation Memory\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n* Provides short-term memory to the AI Agent.\n* Uses `conversation_id` to track individual conversations.\n* Essential for handling follow-up questions."
      },
      "typeVersion": 1
    },
    {
      "id": "889b0dbc-f2eb-4a01-96f6-1ace353ed96a",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2128,
        1504
      ],
      "parameters": {
        "width": 272,
        "height": 400,
        "content": "## 🛒 Get an order from WooCommerce\n\n\n\n\n\n\n\n\n\n\n\n\n\n* A specialized \"Tool\" available to the AI Agent.\n* Connects to WooCommerce to fetch order details.\n* Only runs when called by the agent with a valid Order ID.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "cda68193-1a66-4fb6-81a8-5aaa00e65056",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2208,
        1024
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 464,
        "content": "## 📮 Reply to Specific Platform\n\n* Routes the AI's final response to the correct channel.\n* Checks the `platform` field ('telegram' or 'gmail').\n* Ensures replies are sent back to the source platform.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a2c815cc-71bf-4253-ac53-1d0e219fbb07",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2544,
        944
      ],
      "parameters": {
        "color": 2,
        "width": 352,
        "height": 352,
        "content": "## 🗣️ Send Telegram Response\n\n* Final action for the Telegram path.\n* Sends the AI's response to the user's chat ID.\n\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0c96b670-31c1-44bc-8b9b-b3aa9ce51f8e",
      "name": "便签 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2544,
        1312
      ],
      "parameters": {
        "color": 6,
        "width": 352,
        "height": 400,
        "content": "## 📨 Send Response via Mail\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n* Final action for the Gmail path.\n* Sends the AI's response as a threaded email reply.\n* Uses the `reply_to_id` to maintain the conversation thread."
      },
      "typeVersion": 1
    },
    {
      "id": "dd7376e7-724b-40af-8fe4-8abec4c711c7",
      "name": "便签 11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2912,
        1312
      ],
      "parameters": {
        "color": 4,
        "width": 336,
        "height": 400,
        "content": "## 🚫 Mark received mail as read\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n* Vital control node for the Gmail trigger.\n* Marks the original incoming email as 'Read' after processing.\n* CRITICAL: Prevents infinite reply loops."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "938f9a4c-e86d-4219-aa44-8118b0bdb6ec",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Set Manual Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch user query": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Manual Fields": {
      "main": [
        [
          {
            "node": "WooCommerce Customer support Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch support mail": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Conversation Memory": {
      "ai_memory": [
        [
          {
            "node": "WooCommerce Customer support Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Send Response via Mail": {
      "main": [
        [
          {
            "node": "Mark received mail as read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply to Specific Platform": {
      "main": [
        [
          {
            "node": "Send Telegram Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Response via Mail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get an order in WooCommerce": {
      "ai_tool": [
        [
          {
            "node": "WooCommerce Customer support Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Fallback Model [GPT 4.1 mini]": {
      "ai_languageModel": [
        [
          {
            "node": "WooCommerce Customer support Agent1",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "Primary Model [Gemini 2.5 Flash]": {
      "ai_languageModel": [
        [
          {
            "node": "WooCommerce Customer support Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "WooCommerce Customer support Agent1": {
      "main": [
        [
          {
            "node": "Reply to Specific Platform",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客服机器人, AI 聊天机器人

需要付费吗?

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

工作流信息
难度等级
高级
节点数量25
分类2
节点类型13
难度说明

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

作者
AppStoneLab Technologies LLP

AppStoneLab Technologies LLP

@appstonelab

Dive into the digital era with a trusted partner. From idea to execution, we transform visions into interactive realities. Let's shape the future, together.

外部链接
在 n8n.io 查看

分享此工作流