Shopify order UTM to Baserow

工作流概述

这是一个包含12个节点的复杂工作流,主要用于自动化处理各种任务。

工作流源代码

下载
{
  "id": "ZI0PxugfKsyepqeH",
  "meta": {
    "instanceId": "e2c978396c9c745cf0aaa9ed3abe4464dbcef93c5fe2df809b9e14440e628df6"
  },
  "name": "Shopify order UTM to Baserow",
  "tags": [],
  "nodes": [
    {
      "id": "2ba892fc-59c9-442b-aa21-a5c23b6076e5",
      "name": "Baserow",
      "type": "n8n-nodes-base.baserow",
      "position": [
        2860,
        380
      ],
      "parameters": {
        "tableId": 646,
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": 6164,
              "fieldValue": "={{ $json.order }}"
            },
            {
              "fieldId": 6165,
              "fieldValue": "={{ $json.campaign }}"
            },
            {
              "fieldId": 6166,
              "fieldValue": "={{ $json.content }}"
            },
            {
              "fieldId": 6167,
              "fieldValue": "={{ $json.medium }}"
            },
            {
              "fieldId": 6168,
              "fieldValue": "={{ $json.source }}"
            },
            {
              "fieldId": 6170,
              "fieldValue": "={{ $json.revenue }}"
            }
          ]
        },
        "operation": "create",
        "databaseId": 121
      },
      "credentials": {
        "baserowApi": {
          "id": "VaQgKQ8NPXVMrvMl",
          "name": "Baserow account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e35a0417-7a6a-46bb-8970-20aa7c19d168",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2860,
        720
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "76e327e9-2cc2-42dd-b31a-1aa1e9b02cd1",
      "name": "Set Shopify Subdomain",
      "type": "n8n-nodes-base.set",
      "position": [
        1900,
        320
      ],
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "Shopify Subdomain",
              "stringValue": "you-domain"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "85c0f561-a75d-44a4-a8a5-3791c10a2891",
      "name": "Get orders from Shopify",
      "type": "n8n-nodes-base.graphql",
      "position": [
        1900,
        560
      ],
      "parameters": {
        "query": "=query yersterdaysOrders {
  orders(query: \"created_at:{{$today.minus({days: 1})}}\", first: 100) {
    edges {
      node {
        id
        name
        totalReceived
        customerJourneySummary {
          firstVisit {
            id
            source
            referrerUrl
            landingPage
            utmParameters {
              campaign
              content
              medium
              source
              term
            }
          }
        }
      }
    }
  }
}",
        "endpoint": "=https://{{ $('Set Shopify Subdomain').params[\"fields\"][\"values\"][0][\"stringValue\"] }}.myshopify.com/admin/api/2024-01/graphql.json",
        "authentication": "headerAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "dPZdfPnUTz1YJ54o",
          "name": "Shopify Header Auth - lanakk.com"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4ddbe343-6d4f-4079-9c60-bdf2c34fb015",
      "name": "Every day at 00:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        1660,
        560
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "6b3dd6f7-a761-4a01-bb77-cb8689fe64a0",
      "name": "Split Shopify data into n8n items",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2120,
        560
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "data.orders.edges"
      },
      "typeVersion": 1
    },
    {
      "id": "c50ca221-1330-44c9-9877-3b5bd36a05fb",
      "name": "Transform incoming data structure",
      "type": "n8n-nodes-base.set",
      "position": [
        2340,
        560
      ],
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "order",
              "stringValue": "={{ $json.node.name }}"
            },
            {
              "name": "campaign",
              "stringValue": "={{ $json.node.customerJourneySummary.firstVisit.utmParameters.campaign }}"
            },
            {
              "name": "content",
              "stringValue": "={{ $json.node.customerJourneySummary.firstVisit.utmParameters.content || \"\" }}"
            },
            {
              "name": "medium",
              "stringValue": "={{ $json.node.customerJourneySummary.firstVisit.utmParameters.medium || \"\" }}"
            },
            {
              "name": "source",
              "stringValue": "={{ $json.node.customerJourneySummary.firstVisit.utmParameters.medium || \"\" }}"
            },
            {
              "name": "term",
              "stringValue": "={{ $json.node.customerJourneySummary.firstVisit.utmParameters.term || \"\" }}"
            },
            {
              "name": "revenue",
              "type": "numberValue",
              "numberValue": "={{ $json.node.totalReceived }}"
            }
          ]
        },
        "include": "none",
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "c84c3619-fd41-4d06-8894-1ba7998477fb",
      "name": "Check if \"Campaign\" is present",
      "type": "n8n-nodes-base.if",
      "position": [
        2560,
        560
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "61fe8905-1b9f-45d9-9742-2d5799200d18",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.campaign }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "b0f07670-4fdd-4b64-8d77-87ea5cc399ac",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1240,
        460
      ],
      "parameters": {
        "color": 4,
        "width": 360.408084305475,
        "height": 315.5897364788551,
        "content": "## Shopify API

This workflow uses GraphQL calls to the Shopify Admin API. In order to get a better understanding for the queries and mutations please check the API Docs.


[Shopify GraphQL API docs](https://shopify.dev/docs/api/admin-graphql)

To make it easy to build queries for the GraphQL API easy please check out the [GraphiQL App for the Admin API](https://shopify.dev/docs/apps/tools/graphiql-admin-api) from Shopify"
      },
      "typeVersion": 1
    },
    {
      "id": "742d92d7-9c3e-4515-a9ca-d840685d8ebf",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1720,
        120
      ],
      "parameters": {
        "width": 279.1188177339898,
        "content": "## Set your Shopify Subdomain here"
      },
      "typeVersion": 1
    },
    {
      "id": "a4feb388-0d60-41ee-a269-d39717c6267c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1900,
        760
      ],
      "parameters": {
        "width": 279.1188177339898,
        "content": "## Shopify 
The n8n Shopify node cannot get the customer journey, so we get this from the Shopify GraphQL API"
      },
      "typeVersion": 1
    },
    {
      "id": "adc71ed1-fcb9-40fa-b3c8-ccca7e2fc699",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3060,
        360
      ],
      "parameters": {
        "width": 279.1188177339898,
        "height": 157.78205353137358,
        "content": "## Baserow
Please map the fields coming from the IF node to your own structure in Baserow"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c7fd635a-81e5-461b-885f-5b375bc51138",
  "connections": {
    "Every day at 00:00": {
      "main": [
        [
          {
            "node": "Set Shopify Subdomain",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get orders from Shopify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get orders from Shopify": {
      "main": [
        [
          {
            "node": "Split Shopify data into n8n items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if \"Campaign\" is present": {
      "main": [
        [
          {
            "node": "Baserow",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Shopify data into n8n items": {
      "main": [
        [
          {
            "node": "Transform incoming data structure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform incoming data structure": {
      "main": [
        [
          {
            "node": "Check if \"Campaign\" is present",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

功能特点

  • 自动检测新邮件
  • AI智能内容分析
  • 自定义分类规则
  • 批量处理能力
  • 详细的处理日志

技术分析

节点类型及作用

  • Baserow
  • Noop
  • Set
  • Graphql
  • Scheduletrigger

复杂度评估

配置难度:
★★★★☆
维护难度:
★★☆☆☆
扩展性:
★★★★☆

实施指南

前置条件

  • 有效的Gmail账户
  • n8n平台访问权限
  • Google API凭证
  • AI分类服务订阅

配置步骤

  1. 在n8n中导入工作流JSON文件
  2. 配置Gmail节点的认证信息
  3. 设置AI分类器的API密钥
  4. 自定义分类规则和标签映射
  5. 测试工作流执行
  6. 配置定时触发器(可选)

关键参数

参数名称 默认值 说明
maxEmails 50 单次处理的最大邮件数量
confidenceThreshold 0.8 分类置信度阈值
autoLabel true 是否自动添加标签

最佳实践

优化建议

  • 定期更新AI分类模型以提高准确性
  • 根据邮件量调整处理批次大小
  • 设置合理的分类置信度阈值
  • 定期清理过期的分类规则

安全注意事项

  • 妥善保管API密钥和认证信息
  • 限制工作流的访问权限
  • 定期审查处理日志
  • 启用双因素认证保护Gmail账户

性能优化

  • 使用增量处理减少重复工作
  • 缓存频繁访问的数据
  • 并行处理多个邮件分类任务
  • 监控系统资源使用情况

故障排除

常见问题

邮件未被正确分类

检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。

Gmail认证失败

确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。

调试技巧

  • 启用详细日志记录查看每个步骤的执行情况
  • 使用测试邮件验证分类逻辑
  • 检查网络连接和API服务状态
  • 逐步执行工作流定位问题节点

错误处理

工作流包含以下错误处理机制:

  • 网络超时自动重试(最多3次)
  • API错误记录和告警
  • 处理失败邮件的隔离机制
  • 异常情况下的回滚操作