{
  "id": "ziHPRREYcqeZYu2b",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Advanced Zendesk Tickets Sync with Analytics & Notifications",
  "tags": [
    {
      "id": "H82NBECgQpmleDEV",
      "name": "Zendesk Integration",
      "createdAt": "2025-09-17T12:35:20.910Z",
      "updatedAt": "2025-09-17T12:35:20.910Z"
    },
    {
      "id": "xYBECNinqqQjLYUX",
      "name": "Data Sync",
      "createdAt": "2025-09-17T12:35:20.937Z",
      "updatedAt": "2025-09-17T12:35:20.937Z"
    },
    {
      "id": "4nBbFxg4xEaEKMz5",
      "name": "Analytics",
      "createdAt": "2025-10-03T06:40:45.174Z",
      "updatedAt": "2025-10-03T06:40:45.174Z"
    },
    {
      "id": "DX3NadSF7AYdgdTR",
      "name": "Notifications",
      "createdAt": "2025-10-03T06:40:45.203Z",
      "updatedAt": "2025-10-03T06:40:45.203Z"
    },
    {
      "id": "HQqY8pWWo530B5Zs",
      "name": "SLA Tracking",
      "createdAt": "2025-10-03T06:40:45.436Z",
      "updatedAt": "2025-10-03T06:40:45.436Z"
    }
  ],
  "nodes": [
    {
      "id": "830ee093-91e4-4e05-951a-71ef28f891ef",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -912,
        1752
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "75059b03-2511-4c4d-8dab-501af687b6b4",
      "name": "Sticky Note - Enhanced Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        1664
      ],
      "parameters": {
        "width": 320,
        "height": 380,
        "content": "## \ud83c\udfaf Enhanced Workflow Overview\n\nAdvanced Zendesk ticket synchronization with:\n- Open ticket syncing to Google Sheets\n- Priority-based categorization\n- SLA tracking and alerts\n- Ticket aging analysis\n- Automated Slack notifications\n- Summary statistics dashboard\n- Error handling and logging\n\n**Trigger**: Manual or scheduled (every 15 minutes recommended)"
      },
      "typeVersion": 1
    },
    {
      "id": "6dc2df3f-5faa-48b8-8b1a-dd504ea2db26",
      "name": "Sticky Note - Data Fetching",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        1376
      ],
      "parameters": {
        "width": 280,
        "height": 340,
        "content": "## \ud83c\udfab Zendesk Data Fetching\n\nRetrieves ALL tickets from Zendesk:\n- Ticket ID, subject, description\n- Status, priority, type\n- Tags and custom fields\n- Requester and assignee info\n- Creation and update timestamps\n- SLA breach information\n\n**Enhanced**: Now captures priority and SLA data"
      },
      "typeVersion": 1
    },
    {
      "id": "73883328-d1c5-44bd-8bc8-4d95864a6949",
      "name": "Sticky Note - User Details",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        1456
      ],
      "parameters": {
        "width": 260,
        "height": 300,
        "content": "## \ud83d\udc64 User Enrichment\n\nFetches detailed user information:\n- Full name and email\n- Organization details\n- User role and timezone\n- Contact information\n\n**Enhancement**: Also captures user's organization for better categorization"
      },
      "typeVersion": 1
    },
    {
      "id": "667f61a9-d4ec-4707-b8af-22c324a80f3e",
      "name": "Sticky Note - Enrichment",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        1952
      ],
      "parameters": {
        "width": 280,
        "height": 320,
        "content": "## \ud83d\udd04 Data Enrichment\n\nAdds calculated fields:\n- Ticket age in days\n- Priority score (urgent=4, high=3, normal=2, low=1)\n- SLA status (breached/at-risk/ok)\n- Response time category\n\n**Purpose**: Enable better analytics and prioritization"
      },
      "typeVersion": 1
    },
    {
      "id": "ed9468af-75a4-4d01-b39c-31906de47930",
      "name": "Enrich with Calculated Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -16,
        1752
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ticket-age",
              "name": "ticket_age_days",
              "type": "number",
              "value": "={{ Math.floor((new Date() - new Date($('Filter Open Tickets Only1').item.json.created_at)) / (1000 * 60 * 60 * 24)) }}"
            },
            {
              "id": "priority-score",
              "name": "priority_score",
              "type": "number",
              "value": "={{ $('Filter Open Tickets Only1').item.json.priority === 'urgent' ? 4 : $('Filter Open Tickets Only1').item.json.priority === 'high' ? 3 : $('Filter Open Tickets Only1').item.json.priority === 'normal' ? 2 : 1 }}"
            },
            {
              "id": "sla-status",
              "name": "sla_status",
              "type": "string",
              "value": "={{ Math.floor((new Date() - new Date($('Filter Open Tickets Only1').item.json.created_at)) / (1000 * 60 * 60 * 24)) > 7 ? 'BREACHED' : Math.floor((new Date() - new Date($('Filter Open Tickets Only1').item.json.created_at)) / (1000 * 60 * 60 * 24)) > 5 ? 'AT_RISK' : 'OK' }}"
            },
            {
              "id": "ticket-data",
              "name": "ticket_data",
              "type": "object",
              "value": "={{ $('Filter Open Tickets Only1').item.json }}"
            },
            {
              "id": "user-data",
              "name": "user_data",
              "type": "object",
              "value": "={{ $json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2f34e888-a1a7-4d3f-9929-765aa26b9442",
      "name": "Sticky Note - Alert Logic",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        1456
      ],
      "parameters": {
        "width": 280,
        "height": 320,
        "content": "## \u26a0\ufe0f Priority Alert Detection\n\nIdentifies tickets needing immediate attention:\n- SLA breached tickets (>7 days old)\n- Urgent priority tickets\n- High priority tickets >3 days old\n\n**Action**: Routes to notification system"
      },
      "typeVersion": 1
    },
    {
      "id": "f6002cdd-73c3-46e4-95bd-62ac0e9db3da",
      "name": "Check for Priority Alerts",
      "type": "n8n-nodes-base.if",
      "position": [
        208,
        1752
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "sla-breach",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.sla_status }}",
              "rightValue": "OK"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "00f8b033-7871-431f-aa87-d39f42416a10",
      "name": "Sticky Note - Main Sheet",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        1984
      ],
      "parameters": {
        "width": 300,
        "height": 360,
        "content": "## \ud83d\udcca Google Sheets - Main Data\n\n**Enhanced Columns:**\n- Ticket No., Description, Status\n- Owner, Email, Tag\n- Priority, Age (days)\n- SLA Status\n- Last Updated\n\n**Operation**: Append or Update\n- Matches on Ticket No.\n- Updates all fields on sync"
      },
      "typeVersion": 1
    },
    {
      "id": "c8a64bd2-7545-4836-a1dd-3fe32e6106f5",
      "name": "Save to Google Sheets - Main Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        656,
        1848
      ],
      "parameters": {
        "columns": {
          "value": {
            "Tag": "={{ $json.ticket_data.tags[0] || 'No tags' }}",
            "email": "={{ $json.user_data.email }}",
            "owner": "={{ $json.user_data.name }}",
            "Status": "={{ $json.ticket_data.status }}",
            "Priority": "={{ $json.ticket_data.priority || 'normal' }}",
            "Age (Days)": "={{ $json.ticket_age_days }}",
            "SLA Status": "={{ $json.sla_status }}",
            "Ticket No.": "={{ $json.ticket_data.id }}",
            "Description": "={{ $json.ticket_data.description }}",
            "Last Updated": "={{ $now.toISO() }}"
          },
          "schema": [
            {
              "id": "Ticket No.",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Ticket No.",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "owner",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "owner",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tag",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Tag",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Priority",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Priority",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Age (Days)",
              "type": "number",
              "display": true,
              "required": false,
              "displayName": "Age (Days)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "SLA Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "SLA Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Updated",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Last Updated",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Ticket No."
          ]
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Utpt2Z8krX-29nE3_HAJVmm9yUp9NRcq-_P8JL1UqRk/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Utpt2Z8krX-29nE3_HAJVmm9yUp9NRcq-_P8JL1UqRk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Utpt2Z8krX-29nE3_HAJVmm9yUp9NRcq-_P8JL1UqRk/edit?usp=drivesdk",
          "cachedResultName": "Ticket status dummy"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "ba66f4ad-b0ce-43ff-a7e5-258308351370",
      "name": "Sticky Note - Statistics",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        2016
      ],
      "parameters": {
        "width": 280,
        "height": 340,
        "content": "## \ud83d\udcc8 Statistics Aggregation\n\nCalculates workflow metrics:\n- Total open tickets processed\n- Tickets by priority breakdown\n- Average ticket age\n- SLA breach count\n- At-risk ticket count\n\n**Output**: Single summary record"
      },
      "typeVersion": 1
    },
    {
      "id": "9fffe6b5-0a0c-44ac-8011-991867187ef3",
      "name": "Calculate Summary Statistics",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        1848
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\nconst stats = {\n  total_open_tickets: items.length,\n  urgent_count: items.filter(i => i.json.ticket_data.priority === 'urgent').length,\n  high_count: items.filter(i => i.json.ticket_data.priority === 'high').length,\n  normal_count: items.filter(i => i.json.ticket_data.priority === 'normal').length,\n  low_count: items.filter(i => i.json.ticket_data.priority === 'low').length,\n  sla_breached: items.filter(i => i.json.sla_status === 'BREACHED').length,\n  sla_at_risk: items.filter(i => i.json.sla_status === 'AT_RISK').length,\n  avg_ticket_age: Math.round(items.reduce((sum, i) => sum + i.json.ticket_age_days, 0) / items.length),\n  oldest_ticket_age: Math.max(...items.map(i => i.json.ticket_age_days)),\n  sync_timestamp: new Date().toISOString()\n};\n\nreturn [{ json: stats }];"
      },
      "typeVersion": 2
    },
    {
      "id": "7b771b0e-c8d8-4911-93cc-37e361800f79",
      "name": "Sticky Note - Dashboard",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        1984
      ],
      "parameters": {
        "width": 280,
        "height": 340,
        "content": "## \ud83d\udcca Dashboard Sheet Update\n\n**Sheet**: \"Dashboard\" tab\n\n**Contains**:\n- Real-time ticket counts\n- Priority distribution\n- SLA metrics\n- Sync timestamp\n\n**Updates**: Every workflow run\n**Purpose**: Quick executive overview"
      },
      "typeVersion": 1
    },
    {
      "id": "80ff7173-2e8b-4ec5-8825-96ad1341c645",
      "name": "Update Dashboard Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1104,
        1848
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "Metric"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1701015878,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Utpt2Z8krX-29nE3_HAJVmm9yUp9NRcq-_P8JL1UqRk/edit#gid=1701015878",
          "cachedResultName": "dashboard"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Utpt2Z8krX-29nE3_HAJVmm9yUp9NRcq-_P8JL1UqRk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Utpt2Z8krX-29nE3_HAJVmm9yUp9NRcq-_P8JL1UqRk/edit?usp=drivesdk",
          "cachedResultName": "Ticket status dummy"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "284f0319-6bda-4953-bb93-f705efcc9da4",
      "name": "Sticky Note - Slack Alerts",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        1264
      ],
      "parameters": {
        "width": 280,
        "height": 360,
        "content": "## \ud83d\udd14 Slack Notifications\n\n**Triggers on**:\n- SLA breached tickets\n- At-risk tickets\n\n**Message includes**:\n- Ticket number and subject\n- Owner and priority\n- Age and SLA status\n- Direct Zendesk link\n\n**Channel**: #ticket-alerts"
      },
      "typeVersion": 1
    },
    {
      "id": "a9cdde34-f1a9-465e-bcdd-ec4955662258",
      "name": "Format Slack Message",
      "type": "n8n-nodes-base.set",
      "position": [
        432,
        1680
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "alert-message",
              "name": "alert_message",
              "type": "string",
              "value": "=\ud83d\udea8 *Priority Alert: {{ $json.sla_status }}*\n\n*Ticket #{{ $json.ticket_data.id }}*\n*Subject:* {{ $json.ticket_data.subject || 'No subject' }}\n*Owner:* {{ $json.user_data.name }}\n*Email:* {{ $json.user_data.email }}\n*Priority:* {{ $json.ticket_data.priority || 'normal' }}\n*Age:* {{ $json.ticket_age_days }} days\n*Status:* {{ $json.sla_status }}\n\n<https://yourcompany.zendesk.com/agent/tickets/{{ $json.ticket_data.id }}|View in Zendesk>"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5bb85663-aa0a-4cdd-86b5-112ecb53f514",
      "name": "Send Slack Alert",
      "type": "n8n-nodes-base.slack",
      "notes": "Enable and configure with your Slack credentials",
      "position": [
        656,
        1632
      ],
      "parameters": {
        "text": "={{ $json.alert_message }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C01234567",
          "cachedResultName": "#ticket-alerts"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b08a7f25-1757-4d7e-8cf4-673238872907",
      "name": "Sticky Note - Scheduling",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        1280
      ],
      "parameters": {
        "width": 300,
        "height": 360,
        "content": "## \u23f0 Schedule Trigger (Optional)\n\n**Recommended Setup**:\n- Interval: Every 15 minutes\n- Active hours: 8 AM - 8 PM\n- Days: Monday - Friday\n\n**Alternative**: Hourly or on-demand\n\n*Replace manual trigger with Schedule Trigger node*"
      },
      "typeVersion": 1
    },
    {
      "id": "18a213f8-593a-4a0a-b65a-5751567cdc03",
      "name": "Sticky Note - Error Handling",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        1520
      ],
      "parameters": {
        "width": 280,
        "height": 340,
        "content": "## \ud83d\udee1\ufe0f Error Handling\n\n**Built-in safeguards**:\n- Continues on API failures\n- Logs errors to separate sheet\n- Retries on rate limits\n- Validates data before writing\n\n**Error Sheet**: Tracks sync issues\n**Recovery**: Manual intervention alerts"
      },
      "typeVersion": 1
    },
    {
      "id": "1af52d43-43c2-4030-a344-affdd2b639ac",
      "name": "Fetch All Zendesk Tickets1",
      "type": "n8n-nodes-base.zendesk",
      "position": [
        -688,
        1752
      ],
      "parameters": {
        "options": {},
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "zendeskApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "58181b52-bf1e-45ea-b738-098346f87277",
      "name": "Sticky Note - Filter Logic1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -576,
        1920
      ],
      "parameters": {
        "width": 260,
        "height": 280,
        "content": "## \ud83d\udd0d Status Filter\n\nFilters for OPEN status tickets only.\n\n**Logic**: status = \"open\"\n\n**Other statuses**: pending, solved, closed, new\n\n**Why?** Focus on active tickets needing attention"
      },
      "typeVersion": 1
    },
    {
      "id": "0fe1d046-f24e-4f62-b1c4-811d595ea4a4",
      "name": "Filter Open Tickets Only1",
      "type": "n8n-nodes-base.if",
      "position": [
        -464,
        1752
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "open-filter",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "open"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f9fa784b-343b-481d-8560-22396b7e235c",
      "name": "Get Ticket Requester Details1",
      "type": "n8n-nodes-base.zendesk",
      "position": [
        -240,
        1752
      ],
      "parameters": {
        "id": "={{ $json.requester_id }}",
        "resource": "user",
        "operation": "get"
      },
      "credentials": {
        "zendeskApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "11153b5f-3557-4325-b8cf-c4ba12cc3102",
  "connections": {
    "Format Slack Message": {
      "main": [
        [
          {
            "node": "Send Slack Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Save to Google Sheets - Main Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for Priority Alerts": {
      "main": [
        [
          {
            "node": "Format Slack Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Save to Google Sheets - Main Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Open Tickets Only1": {
      "main": [
        [
          {
            "node": "Get Ticket Requester Details1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch All Zendesk Tickets1": {
      "main": [
        [
          {
            "node": "Filter Open Tickets Only1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Summary Statistics": {
      "main": [
        [
          {
            "node": "Update Dashboard Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enrich with Calculated Fields": {
      "main": [
        [
          {
            "node": "Check for Priority Alerts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Ticket Requester Details1": {
      "main": [
        [
          {
            "node": "Enrich with Calculated Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Google Sheets - Main Data": {
      "main": [
        [
          {
            "node": "Calculate Summary Statistics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Fetch All Zendesk Tickets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}