{
  "id": "En7pWb2RKeMpoenb",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "(Retail) Shopify to CRM Contact Sync",
  "tags": [],
  "nodes": [
    {
      "id": "d5a45ed7-4e37-4261-91a3-9193a27c347a",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -2560,
        224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "minOrderValueForHighValueTag",
              "type": "number",
              "value": 500
            },
            {
              "id": "id-2",
              "name": "lifetimeSpendThreshold",
              "type": "number",
              "value": 1000
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "b363f35a-c792-463c-89ec-a7d65a964c84",
      "name": "Extract Customer Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -2000,
        224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-5",
              "name": "orderTotal",
              "type": "number",
              "value": "={{ $json.total_price || 0 }}"
            },
            {
              "id": "id-6",
              "name": "orderCount",
              "type": "number",
              "value": "={{ $json.customer?.orders_count || 1 }}"
            },
            {
              "id": "id-7",
              "name": "lifetimeSpend",
              "type": "number",
              "value": "={{ $json.customer?.total_spent || $json.total_price || 0 }}"
            },
            {
              "id": "id-8",
              "name": "customerTags",
              "type": "string",
              "value": "={{ $json.customer?.tags || '' }}"
            },
            {
              "id": "id-9",
              "name": "isHighValue",
              "type": "boolean",
              "value": "={{ ($json.total_price || 0) >= $('Workflow Configuration').first().json.minOrderValueForHighValueTag }}"
            },
            {
              "id": "id-10",
              "name": "shopifyCustomerId",
              "type": "string",
              "value": "={{ $json.customer?.id || $json.id }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "dbba9633-e915-40c8-8346-86c5a965b9cf",
      "name": "Search for Existing Contact",
      "type": "n8n-nodes-base.zohoCrm",
      "position": [
        -1760,
        224
      ],
      "parameters": {
        "limit": 2,
        "options": {
          "fields": [
            "Email"
          ]
        },
        "resource": "contact",
        "operation": "getAll"
      },
      "credentials": {
        "zohoOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "82fb867d-c567-4b7f-95d6-c9f10b730a19",
      "name": "Create New Contact",
      "type": "n8n-nodes-base.zohoCrm",
      "position": [
        -576,
        336
      ],
      "parameters": {
        "lastName": "={{ $('Extract Customer Data').item.json.fulfillments[0].line_items[0].name }}",
        "resource": "contact",
        "additionalFields": {}
      },
      "credentials": {
        "zohoOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "1b1965a3-58e5-4dc8-8ade-7d0f2710997f",
      "name": "Update Existing Contact",
      "type": "n8n-nodes-base.zohoCrm",
      "position": [
        -592,
        160
      ],
      "parameters": {
        "resource": "contact",
        "contactId": "={{ $json.id }}",
        "operation": "update",
        "updateFields": {
          "customFields": {
            "customFields": [
              {
                "value": "={{ $('Extract Customer Data').item.json.lifetimeSpend }}",
                "fieldId": "Engagement_Score"
              },
              {
                "value": "={{ $('Extract Customer Data').item.json.orderCount }}",
                "fieldId": "Mentions_Counts"
              }
            ]
          }
        }
      },
      "credentials": {
        "zohoOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "73054692-cac3-42ac-98e9-8d54b58905f5",
      "name": "Contact Exists?",
      "type": "n8n-nodes-base.if",
      "position": [
        -1088,
        224
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c4a2aef2-89cc-4de4-bca6-8a7e99de0e03",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $('Search for Existing Contact').item.json.id }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "05d8bd07-acc2-4f3d-a73b-1b6ab147c9c1",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3632,
        -96
      ],
      "parameters": {
        "width": 496,
        "height": 688,
        "content": "# How It Works\n### This workflow automates the synchronization of Shopify customer activity with Zoho CRM, ensuring sales and support teams have up-to-date purchase history and engagement metrics.\n\n# Setup Steps\n## Trigger\nConfigure the Shopify Trigger node with your store's Access Token and set the topic to `customers/create` or `orders/create`.\n\n## Connections\nLink credentials for Shopify (source) and Zoho CRM (destination).\n\n## Configuration\nDefine your high-value customer thresholds (e.g., Min Order Value: 500) in the configuration node to automate customer segmentation.\n\n## Intelligence Sync\nThe system automatically checks if a contact exists in Zoho. If they do, it updates their lifetime spend and order count; if not, it creates a new record."
      },
      "typeVersion": 1
    },
    {
      "id": "7cbd833f-746c-4c43-ab71-4cd60ed3719e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2992,
        16
      ],
      "parameters": {
        "color": 7,
        "width": 720,
        "height": 496,
        "content": "## Shopify Trigger & Set Configuration\nThe process begins with a Shopify Trigger listening for new customers or orders created in your store. This is followed by a Workflow Configuration node that establishes global operational parameters, such as the minimum order value required for high-value tagging and lifetime spend thresholds.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4a116ce9-7419-4e8a-af5b-7f486b7857ef",
      "name": "Trigger on New Customer or Order",
      "type": "n8n-nodes-base.shopifyTrigger",
      "position": [
        -2800,
        224
      ],
      "parameters": {
        "topic": "customers/create",
        "authentication": "accessToken"
      },
      "credentials": {
        "shopifyAccessTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8eadec49-e00a-49b9-8070-a6037b7df313",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2208,
        16
      ],
      "parameters": {
        "color": 7,
        "width": 784,
        "height": 496,
        "content": "## Data Extraction & CRM Search\nThis stage processes the raw shopify data by using the Extract Customer Data node to calculate key engagement metrics, such as lifetime spend, order frequency and high-value customer status. These details are then passed to the Search for Existing Contact node, which queries Zoho CRM to check if the customer already exists in your database, ensuring that activity is recorded against the correct profile without creating duplicates.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "95c533aa-cf89-452f-bf0c-394da380a60c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1360,
        16
      ],
      "parameters": {
        "color": 7,
        "width": 1072,
        "height": 496,
        "content": "## Conditional Routing & CRM Synchronization\nThe final stage uses a Contact Exists? IF node to determine the appropriate path in Zoho CRM based on whether a matching record was found. If the contact is new, the workflow routes to the Create New Contact node to generate a fresh profile using the Shopify data. If the contact already exists, it routes to the Update Existing Contact node, which automatically synchronizes current Shopify metrics\u2014such as engagement scores and order counts\u2014directly to the customer's CRM record.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bf59b482-b86f-4c00-b79b-1bd8b7225849",
  "connections": {
    "Contact Exists?": {
      "main": [
        [
          {
            "node": "Update Existing Contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create New Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Customer Data": {
      "main": [
        [
          {
            "node": "Search for Existing Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Extract Customer Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search for Existing Contact": {
      "main": [
        [
          {
            "node": "Contact Exists?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger on New Customer or Order": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}