{
  "name": "Flowforge · E-commerce Order Sync",
  "nodes": [
    {
      "parameters": {
        "content": "## E-commerce Order Sync\nEvery Shopify order is routed to the right warehouse (ShipStation US or the EU 3PL) with full billing/shipping address and line items, the customer is upserted to HubSpot with last-order properties, the order lands in the finance ledger sheet and VIP orders ping #ops. Orders outside both regions go to \"Manual review\".\n\nPaste your ShipStation warehouse ID into \"Map Order\". Set Workflow settings → Error workflow to \"Flowforge · Error Reporter\".",
        "height": 240,
        "width": 460,
        "color": 5
      },
      "id": "00000075-f10f-4f0e-9a1b-000000001117",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -40
      ]
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "topic": "orders/create"
      },
      "id": "0000006b-f10f-4f0e-9a1b-000000001107",
      "name": "Shopify: Order Created",
      "type": "n8n-nodes-base.shopifyTrigger",
      "typeVersion": 1,
      "position": [
        240,
        400
      ],
      "webhookId": "c3a4e5f6-5b0f-4a1e-8c33-000000000006",
      "credentials": {
        "shopifyAccessTokenApi": {
          "id": "cr09",
          "name": "Shopify – Store Admin"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0000005b-f10f-4f0e-9a1b-000000001091",
              "name": "orderId",
              "value": "={{ $json.id }}",
              "type": "string"
            },
            {
              "id": "0000005c-f10f-4f0e-9a1b-000000001092",
              "name": "orderNumber",
              "value": "={{ $json.name }}",
              "type": "string"
            },
            {
              "id": "0000005d-f10f-4f0e-9a1b-000000001093",
              "name": "email",
              "value": "={{ $json.email }}",
              "type": "string"
            },
            {
              "id": "0000005e-f10f-4f0e-9a1b-000000001094",
              "name": "customer",
              "value": "={{ $json.customer.first_name }} {{ $json.customer.last_name }}",
              "type": "string"
            },
            {
              "id": "0000005f-f10f-4f0e-9a1b-000000001095",
              "name": "total",
              "value": "={{ parseFloat($json.total_price) }}",
              "type": "number"
            },
            {
              "id": "00000060-f10f-4f0e-9a1b-000000001096",
              "name": "currency",
              "value": "={{ $json.currency }}",
              "type": "string"
            },
            {
              "id": "00000061-f10f-4f0e-9a1b-000000001097",
              "name": "country",
              "value": "={{ $json.shipping_address.country_code }}",
              "type": "string"
            },
            {
              "id": "00000062-f10f-4f0e-9a1b-000000001098",
              "name": "region",
              "value": "={{ [\"US\",\"CA\"].includes($json.shipping_address.country_code) ? \"north-america\" : ([\"GB\",\"DE\",\"FR\",\"NL\",\"ES\",\"IT\",\"BE\",\"AT\"].includes($json.shipping_address.country_code) ? \"europe\" : \"rest\") }}",
              "type": "string"
            },
            {
              "id": "00000063-f10f-4f0e-9a1b-000000001099",
              "name": "items",
              "value": "={{ $json.line_items.map(i => i.quantity + '× ' + i.sku).join(', ') }}",
              "type": "string"
            },
            {
              "id": "00000064-f10f-4f0e-9a1b-000000001100",
              "name": "shipstationWarehouseId",
              "value": "REPLACE_WITH_SHIPSTATION_WAREHOUSE_ID",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "0000006c-f10f-4f0e-9a1b-000000001108",
      "name": "Map Order",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        480,
        400
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "loose"
                },
                "conditions": [
                  {
                    "id": "00000065-f10f-4f0e-9a1b-000000001101",
                    "leftValue": "={{ $json.region }}",
                    "rightValue": "north-america",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "north-america"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "loose"
                },
                "conditions": [
                  {
                    "id": "00000066-f10f-4f0e-9a1b-000000001102",
                    "leftValue": "={{ $json.region }}",
                    "rightValue": "europe",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "europe"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "id": "0000006d-f10f-4f0e-9a1b-000000001109",
      "name": "Switch: Region",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        720,
        400
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://ssapi.shipstation.com/orders/createorder",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify((() => { const o = $('Shopify: Order Created').item.json; const s = o.shipping_address || {}; const b = o.billing_address || s; const addr = a => ({ name: a.name || ((o.customer && o.customer.first_name) || '') + ' ' + ((o.customer && o.customer.last_name) || ''), company: a.company || '', street1: a.address1 || '', street2: a.address2 || '', city: a.city || '', state: a.province_code || '', postalCode: a.zip || '', country: a.country_code || '', phone: a.phone || o.phone || '' }); return { orderNumber: o.name, orderKey: String(o.id), orderDate: o.created_at, orderStatus: 'awaiting_shipment', customerEmail: o.email, billTo: addr(b), shipTo: addr(s), items: o.line_items.map(i => ({ lineItemKey: String(i.id), sku: i.sku || '', name: i.name, quantity: i.quantity, unitPrice: parseFloat(i.price) })), amountPaid: parseFloat(o.total_price), advancedOptions: { warehouseId: parseInt($('Map Order').item.json.shipstationWarehouseId, 10), source: 'shopify' } }; })()) }}",
        "options": {
          "timeout": 20000
        }
      },
      "id": "0000006e-f10f-4f0e-9a1b-000000001110",
      "name": "ShipStation: Create Order",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        280
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "cr10",
          "name": "ShipStation API Key"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.nl-fulfil.example/v2/shipments",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify((() => { const o = $('Shopify: Order Created').item.json; const s = o.shipping_address || {}; const b = o.billing_address || s; const addr = a => ({ name: a.name || ((o.customer && o.customer.first_name) || '') + ' ' + ((o.customer && o.customer.last_name) || ''), company: a.company || '', street1: a.address1 || '', street2: a.address2 || '', city: a.city || '', state: a.province_code || '', postalCode: a.zip || '', country: a.country_code || '', phone: a.phone || o.phone || '' }); return { reference: o.name, shipTo: addr(s), lines: o.line_items.map(i => ({ sku: i.sku || '', qty: i.quantity })) }; })()) }}",
        "options": {
          "timeout": 20000
        }
      },
      "id": "0000006f-f10f-4f0e-9a1b-000000001111",
      "name": "3PL EU: Create Shipment",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        520
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "cr12",
          "name": "EU 3PL API Key"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "00000067-f10f-4f0e-9a1b-000000001103",
              "name": "orderNumber",
              "value": "={{ $('Map Order').item.json.orderNumber }}",
              "type": "string"
            },
            {
              "id": "00000068-f10f-4f0e-9a1b-000000001104",
              "name": "warehouse",
              "value": "={{ $('Map Order').item.json.region === 'north-america' ? 'ShipStation US' : ($('Map Order').item.json.region === 'europe' ? 'EU 3PL' : 'Manual review') }}",
              "type": "string"
            },
            {
              "id": "00000069-f10f-4f0e-9a1b-000000001105",
              "name": "total",
              "value": "={{ $('Map Order').item.json.total }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "00000070-f10f-4f0e-9a1b-000000001112",
      "name": "Set Warehouse",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1200,
        400
      ]
    },
    {
      "parameters": {
        "authentication": "appToken",
        "resource": "contact",
        "operation": "upsert",
        "email": "={{ $('Map Order').item.json.email }}",
        "additionalFields": {
          "lifeCycleStage": "customer",
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "property": "last_order_number",
                "value": "={{ $('Map Order').item.json.orderNumber }}"
              },
              {
                "property": "last_order_value",
                "value": "={{ $('Map Order').item.json.total }}"
              }
            ]
          }
        }
      },
      "id": "00000071-f10f-4f0e-9a1b-000000001113",
      "name": "HubSpot: Upsert Customer",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2,
      "position": [
        1440,
        400
      ],
      "credentials": {
        "hubspotAppToken": {
          "id": "cr04",
          "name": "HubSpot – Private App"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "REPLACE_WITH_ORDERS_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Orders",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Date": "={{ $now.toISODate() }}",
            "Order": "={{ $('Map Order').item.json.orderNumber }}",
            "Customer": "={{ $('Map Order').item.json.customer }}",
            "Country": "={{ $('Map Order').item.json.country }}",
            "Items": "={{ $('Map Order').item.json.items }}",
            "Total": "={{ $('Map Order').item.json.total }}",
            "Currency": "={{ $('Map Order').item.json.currency }}",
            "Warehouse": "={{ $('Set Warehouse').item.json.warehouse }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Order",
              "displayName": "Order",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer",
              "displayName": "Customer",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country",
              "displayName": "Country",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Items",
              "displayName": "Items",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Total",
              "displayName": "Total",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "displayName": "Currency",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Warehouse",
              "displayName": "Warehouse",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {
          "cellFormat": "RAW"
        }
      },
      "id": "00000072-f10f-4f0e-9a1b-000000001114",
      "name": "Sheets: Orders Ledger",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1680,
        400
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "cr02",
          "name": "Google Sheets – Ops"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "0000006a-f10f-4f0e-9a1b-000000001106",
              "leftValue": "={{ $('Map Order').item.json.total }}",
              "rightValue": 500,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "00000073-f10f-4f0e-9a1b-000000001115",
      "name": "IF: Order ≥ $500",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1920,
        400
      ]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "#ops",
          "mode": "name"
        },
        "text": "=:package: *VIP order {{ $('Map Order').item.json.orderNumber }}* – {{ $('Map Order').item.json.total }} {{ $('Map Order').item.json.currency }} from {{ $('Map Order').item.json.customer }} ({{ $('Map Order').item.json.country }}). Routed to {{ $('Set Warehouse').item.json.warehouse }}. Add a handwritten note.",
        "otherOptions": {
          "includeLinkToWorkflow": false,
          "unfurl_links": false
        }
      },
      "id": "00000074-f10f-4f0e-9a1b-000000001116",
      "name": "Slack: #ops VIP",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        2160,
        280
      ],
      "credentials": {
        "slackApi": {
          "id": "cr03",
          "name": "Slack – Flowforge Bot"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000
    }
  ],
  "connections": {
    "Shopify: Order Created": {
      "main": [
        [
          {
            "node": "Map Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Order": {
      "main": [
        [
          {
            "node": "Switch: Region",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch: Region": {
      "main": [
        [
          {
            "node": "ShipStation: Create Order",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "3PL EU: Create Shipment",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set Warehouse",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ShipStation: Create Order": {
      "main": [
        [
          {
            "node": "Set Warehouse",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3PL EU: Create Shipment": {
      "main": [
        [
          {
            "node": "Set Warehouse",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Warehouse": {
      "main": [
        [
          {
            "node": "HubSpot: Upsert Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HubSpot: Upsert Customer": {
      "main": [
        [
          {
            "node": "Sheets: Orders Ledger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sheets: Orders Ledger": {
      "main": [
        [
          {
            "node": "IF: Order ≥ $500",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF: Order ≥ $500": {
      "main": [
        [
          {
            "node": "Slack: #ops VIP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "errorWorkflow": "REPLACE_WITH_ERROR_WORKFLOW_ID"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "flowforge-concept-demo"
  },
  "tags": [
    {
      "id": "ff-tag-ecommerce",
      "name": "ecommerce"
    },
    {
      "id": "ff-tag-shopify",
      "name": "shopify"
    },
    {
      "id": "ff-tag-ops",
      "name": "ops"
    }
  ]
}