8
n8n 中文网amn8n.com

在Google Sheets中跟踪Shopify订单并发送Discord通知

初级

这是一个CRM领域的自动化工作流,包含 5 个节点。主要使用 Code, Discord, GoogleSheets, ShopifyTrigger 等节点。 在Google Sheets中跟踪Shopify订单并发送Discord通知

前置要求
  • Discord Bot Token 或 Webhook
  • Google Sheets API 凭证
  • Shopify Admin API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "4dec90995ececbc62e9e87d2686828c375ae5080bb5c39789af3396400555208",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "afd5e841-93cd-4052-a3bb-247e6ef1b097",
      "name": "Shopify 触发器",
      "type": "n8n-nodes-base.shopifyTrigger",
      "position": [
        -256,
        -32
      ],
      "webhookId": "bd2b5f44-d7d6-4797-a998-760fbe11f8e9",
      "parameters": {
        "topic": "orders/create",
        "authentication": "accessToken"
      },
      "credentials": {
        "shopifyAccessTokenApi": {
          "id": "yf8JPxTJSGMz0Pgc",
          "name": "Shopify Access Token account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a4616c22-8956-46e7-8464-597bfd482d3c",
      "name": "在表格中追加行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        160,
        -32
      ],
      "parameters": {
        "columns": {
          "value": {
            "Tax": "={{ $('Shopify Trigger').item.json.current_total_tax }}",
            "City": "={{ $('Shopify Trigger').item.json.billing_address.city }}",
            "Country": "={{ $('Shopify Trigger').item.json.billing_address.country }}",
            "Currency": "={{ $('Shopify Trigger').item.json.current_total_discounts_set.shop_money.currency_code }}",
            "Subtotal": "={{ $('Shopify Trigger').item.json.current_subtotal_price }}",
            "Order Date": "={{ $('Shopify Trigger').item.json.customer.created_at }}",
            "Order Link": "={{ $('Shopify Trigger').item.json.order_status_url }}",
            "Order Total": "={{ $('Shopify Trigger').item.json.total_price }}",
            "Order Number": "={{ $('Shopify Trigger').item.json.order_number }}\n",
            "Customer Name": "={{ $('Shopify Trigger').item.json.billing_address.name }}",
            "Customer Email": "={{ $('Shopify Trigger').item.json.email }}",
            "Payment Gateway": "={{ $('Shopify Trigger').item.json.payment_gateway_names[0] }}",
            "Financial Status": "={{ $('Shopify Trigger').item.json.financial_status }}",
            "Line Item Prices": "={{ $json.line_item_prices }}",
            "Line Item Titles": "={{ $json.line_item_titles }}"
          },
          "schema": [
            {
              "id": "Order Number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Order Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Customer Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Customer Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "City",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "City",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Country",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Country",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Order Total",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Order Total",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Subtotal",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Subtotal",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tax",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Tax",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Financial Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Financial Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Payment Gateway",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Payment Gateway",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Order Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Order Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Line Item Titles",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Line Item Titles",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Line Item Prices",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Line Item Prices",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Order Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Order Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/178dfbyBMouRfyXP2OngRHylputb4qdzkwQV63Lk5Ev0/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "178dfbyBMouRfyXP2OngRHylputb4qdzkwQV63Lk5Ev0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/178dfbyBMouRfyXP2OngRHylputb4qdzkwQV63Lk5Ev0/edit?usp=drivesdk",
          "cachedResultName": "shopify orders"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "2FD7aGP6CZedl0hf",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "a6a9d2f7-9455-4b92-b90f-a2b9274c454b",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        -48,
        -32
      ],
      "parameters": {
        "language": "python",
        "pythonCode": "# Assume the incoming JSON has a top-level \"line_items\" array\nline_items = items[0][\"json\"][\"line_items\"]\n\ntitles = \", \".join([item[\"title\"] for item in line_items])\nprices = \", \".join([str(item[\"price\"]) for item in line_items])\n\nreturn [\n    {\n        \"json\": {\n            \"line_item_titles\": titles,\n            \"line_item_prices\": prices,\n        }\n    }\n]"
      },
      "typeVersion": 2
    },
    {
      "id": "f0ef6c18-5d58-4caa-a030-93a84e8b3592",
      "name": "Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        576,
        -32
      ],
      "webhookId": "2f437086-2fe4-4984-a339-fd2aae49e727",
      "parameters": {
        "content": "={{ $json.content }}",
        "options": {},
        "authentication": "webhook"
      },
      "credentials": {
        "discordWebhookApi": {
          "id": "mjyYtcAJU6FJo0Vq",
          "name": "shopify-order"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "33a7c414-e55f-4ed8-a10f-a561311b69f6",
      "name": "代码1",
      "type": "n8n-nodes-base.code",
      "position": [
        368,
        -32
      ],
      "parameters": {
        "jsCode": "const order = items[0].json;\n\nconst prices = order[\"Line Item Prices\"].split(', ');\nconst titles = order[\"Line Item Titles\"].split(', ');\n\nconst message = `🛍️ **New Order Received!**\n\n**Order #:** ${order[\"Order Number\"]}\n**Customer:** ${order[\"Customer Name\"]} (${order[\"Customer Email\"]})\n**Location:** ${order[\"City\"]}, ${order[\"Country\"]}\n**Date:** ${order[\"Order Date\"]}\n\n🧾 **Items Ordered:**\n${titles.map((title, i) => `- ${title} (${prices[i]} ${order[\"Currency\"]})`).join('\\n')}\n\n💳 **Total:** ${order[\"Order Total\"]} ${order[\"Currency\"]}\n**Subtotal:** ${order[\"Subtotal\"]} | **Tax:** ${order[\"Tax\"]} ${order[\"Currency\"]}\n**Payment Status:** ${order[\"Financial Status\"]}\n**Payment Method:** ${order[\"Payment Gateway\"]}\n\n🔗 [View Order](${order[\"Order Link\"]})\n`;\n\nreturn [{ json: { content: message } }];\n"
      },
      "typeVersion": 2
    }
  ],
  "pinData": {},
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Shopify Trigger": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

初级 - 客户关系管理

需要付费吗?

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

工作流信息
难度等级
初级
节点数量5
分类1
节点类型4
难度说明

适合 n8n 新手,包含 1-5 个节点的简单工作流

外部链接
在 n8n.io 查看

分享此工作流