{
  "name": "Securafy AI Services — All Workflows",
  "description": "Complete collection of 32 AI automation workflows for Securafy AI Services across all verticals",
  "workflows": [
    {
      "name": "LAW-01: New Client Intake Assistant",
      "nodes": [
        {
          "id": "node_1",
          "name": "📥 New Lead Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "law-intake",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_2",
          "name": "Extract Lead Data",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            280,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "a1",
                  "name": "name",
                  "type": "string",
                  "value": "={{ $json.body.name }}"
                },
                {
                  "id": "a2",
                  "name": "email",
                  "type": "string",
                  "value": "={{ $json.body.email }}"
                },
                {
                  "id": "a3",
                  "name": "phone",
                  "type": "string",
                  "value": "={{ $json.body.phone }}"
                },
                {
                  "id": "a4",
                  "name": "message",
                  "type": "string",
                  "value": "={{ $json.body.message }}"
                },
                {
                  "id": "a5",
                  "name": "source",
                  "type": "string",
                  "value": "={{ $json.body.source || 'Website' }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_3",
          "name": "🤖 AI: Classify & Draft Response",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are an intake assistant for a law firm. Analyze the client inquiry and: 1) Classify the matter type (personal injury, family law, criminal, business, estate, employment, real estate, other), 2) Assess urgency (urgent/standard), 3) Check for any obvious conflict-of-interest red flags, 4) Draft a warm, professional acknowledgement email (2-3 paragraphs) that references their specific situation. Respond in JSON: {matterType, urgency, conflictFlags, subject, emailBody, internalNote}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Client Name: ${$node['Extract Lead Data'].json.name}\\nEmail: ${$node['Extract Lead Data'].json.email}\\nMessage: ${$node['Extract Lead Data'].json.message}\\nSource: ${$node['Extract Lead Data'].json.source}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_4",
          "name": "Parse AI Response",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            840,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "b1",
                  "name": "aiData",
                  "type": "string",
                  "value": "={{ JSON.parse($json.content[0].text) }}"
                },
                {
                  "id": "b2",
                  "name": "matterType",
                  "type": "string",
                  "value": "={{ JSON.parse($json.content[0].text).matterType }}"
                },
                {
                  "id": "b3",
                  "name": "urgency",
                  "type": "string",
                  "value": "={{ JSON.parse($json.content[0].text).urgency }}"
                },
                {
                  "id": "b4",
                  "name": "emailSubject",
                  "type": "string",
                  "value": "={{ JSON.parse($json.content[0].text).subject }}"
                },
                {
                  "id": "b5",
                  "name": "emailBody",
                  "type": "string",
                  "value": "={{ JSON.parse($json.content[0].text).emailBody }}"
                },
                {
                  "id": "b6",
                  "name": "internalNote",
                  "type": "string",
                  "value": "={{ JSON.parse($json.content[0].text).internalNote }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_5",
          "name": "📧 Send Acknowledgement to Client",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            1120,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $node['Extract Lead Data'].json.email }}",
            "subject": "={{ $node['Parse AI Response'].json.emailSubject }}",
            "message": "={{ $node['Parse AI Response'].json.emailBody }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_6",
          "name": "📋 Create CRM Contact",
          "type": "n8n-nodes-base.hubspot",
          "typeVersion": 2,
          "position": [
            1120,
            160
          ],
          "parameters": {
            "operation": "create",
            "resource": "contact",
            "additionalFields": {
              "email": "={{ $node['Extract Lead Data'].json.email }}",
              "firstName": "={{ $node['Extract Lead Data'].json.name.split(' ')[0] }}",
              "lastName": "={{ $node['Extract Lead Data'].json.name.split(' ').slice(1).join(' ') }}",
              "phone": "={{ $node['Extract Lead Data'].json.phone }}",
              "hubspot_owner_id": "={{ $env.INTAKE_OWNER_ID }}"
            }
          },
          "credentials": {
            "hubspotAppToken": {
              "id": "hubspot_cred",
              "name": "HubSpot"
            }
          }
        },
        {
          "id": "node_7",
          "name": "🔔 Notify Intake Coordinator",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            1120,
            320
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_INTAKE_CHANNEL }}",
            "text": "=🆕 *New Intake — {{ $node['Parse AI Response'].json.matterType }}* ({{ $node['Parse AI Response'].json.urgency.toUpperCase() }})\\n*Name:* {{ $node['Extract Lead Data'].json.name }}\\n*Email:* {{ $node['Extract Lead Data'].json.email }}\\n*Note:* {{ $node['Parse AI Response'].json.internalNote }}\\n*Acknowledgement sent ✓*",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_1",
          "sourceOutput": 0,
          "target": "node_2",
          "targetInput": 0
        },
        {
          "source": "node_2",
          "sourceOutput": 0,
          "target": "node_3",
          "targetInput": 0
        },
        {
          "source": "node_3",
          "sourceOutput": 0,
          "target": "node_4",
          "targetInput": 0
        },
        {
          "source": "node_4",
          "sourceOutput": 0,
          "target": "node_5",
          "targetInput": 0
        },
        {
          "source": "node_4",
          "sourceOutput": 0,
          "target": "node_6",
          "targetInput": 0
        },
        {
          "source": "node_4",
          "sourceOutput": 0,
          "target": "node_7",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "law_01_new_client_intake_assistant",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Law Firms",
        "Intake"
      ],
      "notes": "Triggers when a new lead arrives via web form or email. AI classifies matter type, checks for conflict keywords, drafts personalised acknowledgement, creates CRM contact, and notifies intake coordinator."
    },
    {
      "name": "LAW-02: Deadline & Court Date Reminder System",
      "nodes": [
        {
          "id": "node_8",
          "name": "⏰ Daily 7am Check",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 7 * * *"
                }
              ]
            }
          }
        },
        {
          "id": "node_9",
          "name": "📅 Fetch Upcoming Deadlines from Clio",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.CLIO_BASE_URL }}/api/v4/matters?fields=id,display_number,description,client{name,email},custom_field_values&status=open",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_10",
          "name": "Filter Deadlines (14/7/2 days)",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            560,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "c1",
                  "name": "dueMatters",
                  "type": "string",
                  "value": "={{ $json.data.filter(m => {\n  const deadlines = m.custom_field_values?.filter(f => f.field_type === 'date' && f.field_name?.toLowerCase().includes('deadline'));\n  return deadlines?.some(d => {\n    const days = Math.floor((new Date(d.value) - new Date()) / 86400000);\n    return days === 14 || days === 7 || days === 2;\n  });\n}) }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_11",
          "name": "🤖 AI: Draft Deadline Reminder",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            840,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a legal assistant. Draft professional deadline reminder communications for both the attorney and the client. For the attorney: concise internal note with action items. For the client: warm but clear reminder explaining what is needed and by when. Respond in JSON: {attorneySubject, attorneyBody, clientSubject, clientBody}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Matter: ${$json.display_number} - ${$json.description}\\nClient: ${$json.client.name}\\nDeadline in: ${$json.daysUntil} days\\nDeadline date: ${$json.deadlineDate}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_12",
          "name": "📧 Email Client Reminder",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            1120,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.client.email }}",
            "subject": "={{ $node['🤖 AI: Draft Deadline Reminder'].json.content[0].text | parseJSON | attr('clientSubject') }}",
            "message": "={{ $node['🤖 AI: Draft Deadline Reminder'].json.content[0].text | parseJSON | attr('clientBody') }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_13",
          "name": "🔔 Alert Attorney",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            1120,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_ATTORNEYS_CHANNEL }}",
            "text": "=⚖️ *Deadline Alert — {{ $json.daysUntil }} days*\\n*Matter:* {{ $json.display_number }} — {{ $json.description }}\\n*Client:* {{ $json.client.name }}\\n*Date:* {{ $json.deadlineDate }}\\n_Client reminder sent ✓_",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_8",
          "sourceOutput": 0,
          "target": "node_9",
          "targetInput": 0
        },
        {
          "source": "node_9",
          "sourceOutput": 0,
          "target": "node_10",
          "targetInput": 0
        },
        {
          "source": "node_10",
          "sourceOutput": 0,
          "target": "node_11",
          "targetInput": 0
        },
        {
          "source": "node_11",
          "sourceOutput": 0,
          "target": "node_12",
          "targetInput": 0
        },
        {
          "source": "node_11",
          "sourceOutput": 0,
          "target": "node_13",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "law_02_deadline_court_date_reminder_system",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Law Firms",
        "Deadlines"
      ],
      "notes": "Runs daily. Checks Clio/practice management for upcoming deadlines within 14/7/2 days. AI drafts personalised reminders for attorney and client. Escalates if no acknowledgement received within 24 hours."
    },
    {
      "name": "LAW-03: Document Summary & Review Prep",
      "nodes": [
        {
          "id": "node_14",
          "name": "📄 Document Upload Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "law-document-upload",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_15",
          "name": "⬇️ Fetch Document Text",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $json.body.documentUrl }}",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_16",
          "name": "🤖 AI: Analyse Document",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a legal document analyst. Review this document and extract: 1) Document type and parties involved, 2) Key dates (effective date, deadlines, expiry, renewal), 3) Key obligations for each party, 4) Payment terms or amounts, 5) Any unusual, non-standard, or potentially problematic clauses, 6) A 3-sentence executive summary. Respond in JSON: {docType, parties, keyDates, obligations, paymentTerms, unusualClauses, summary, reviewPriority}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Document Name: ${$json.body.documentName}\\nMatter: ${$json.body.matterNumber}\\nContent: ${$json.data || $json.body.extractedText}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_17",
          "name": "Format Attorney Brief",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            840,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "d1",
                  "name": "briefContent",
                  "type": "string",
                  "value": "={{ (() => {\n  const ai = JSON.parse($node['🤖 AI: Analyse Document'].json.content[0].text);\n  return `DOCUMENT BRIEF\\n\\nDocument: ${$json.body.documentName}\\nMatter: ${$json.body.matterNumber}\\nType: ${ai.docType}\\nReview Priority: ${ai.reviewPriority}\\n\\nSUMMARY\\n${ai.summary}\\n\\nPARTIES\\n${ai.parties}\\n\\nKEY DATES\\n${ai.keyDates}\\n\\nKEY OBLIGATIONS\\n${ai.obligations}\\n\\nUNUSUAL CLAUSES\\n${ai.unusualClauses || 'None identified'}\\n\\nPAYMENT TERMS\\n${ai.paymentTerms || 'N/A'}`;\n})() }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_18",
          "name": "📧 Deliver Brief to Attorney",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            1120,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.attorneyEmail }}",
            "subject": "=📋 Document Brief: {{ $json.body.documentName }} — {{ $json.body.matterNumber }}",
            "message": "={{ $node['Format Attorney Brief'].json.briefContent }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_14",
          "sourceOutput": 0,
          "target": "node_15",
          "targetInput": 0
        },
        {
          "source": "node_15",
          "sourceOutput": 0,
          "target": "node_16",
          "targetInput": 0
        },
        {
          "source": "node_16",
          "sourceOutput": 0,
          "target": "node_17",
          "targetInput": 0
        },
        {
          "source": "node_17",
          "sourceOutput": 0,
          "target": "node_18",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "law_03_document_summary_review_prep",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Law Firms",
        "Documents"
      ],
      "notes": "Triggers when a new document is uploaded to a matter folder. AI extracts key dates, parties, obligations, and unusual clauses. Delivers brief to attorney before review."
    },
    {
      "name": "LAW-04: Invoice & AR Follow-Up Bot",
      "nodes": [
        {
          "id": "node_19",
          "name": "⏰ Daily AR Check 8am",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 8 * * 1-5"
                }
              ]
            }
          }
        },
        {
          "id": "node_20",
          "name": "💰 Fetch Overdue Bills from Clio",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.CLIO_BASE_URL }}/api/v4/bills?fields=id,number,balance,due_at,client{name,email},matter{display_number}&status=outstanding",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_21",
          "name": "Calculate Days Overdue",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            560,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "e1",
                  "name": "overdueItems",
                  "type": "string",
                  "value": "={{ $json.data.map(b => ({\n  ...b,\n  daysOverdue: Math.floor((new Date() - new Date(b.due_at)) / 86400000)\n})).filter(b => [14,30,45].includes(b.daysOverdue)) }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_22",
          "name": "🤖 AI: Draft Follow-Up Email",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            840,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a billing coordinator for a law firm. Draft a professional, firm but respectful overdue invoice reminder. The tone should escalate based on days overdue: 14 days = gentle reminder, 30 days = firm reminder, 45 days = urgent with consequences mentioned. Always reference the specific matter. Never be aggressive. Respond in JSON: {subject, body, escalateToPartner}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Client: ${$json.client.name}\\nInvoice #: ${$json.number}\\nBalance Due: $${$json.balance}\\nDays Overdue: ${$json.daysOverdue}\\nMatter: ${$json.matter.display_number}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_23",
          "name": "📧 Send Follow-Up to Client",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            1120,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.client.email }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Draft Follow-Up Email'].json.content[0].text).subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Draft Follow-Up Email'].json.content[0].text).body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_24",
          "name": "🚨 Escalate to Billing Partner (45d)",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            1120,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_BILLING_CHANNEL }}",
            "text": "=💰 *AR Escalation Required*\\n*Client:* {{ $json.client.name }}\\n*Invoice:* {{ $json.number }} — ${{ $json.balance }}\\n*Days Overdue:* {{ $json.daysOverdue }}\\n*Matter:* {{ $json.matter.display_number }}\\n_Please review for partner follow-up_",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_19",
          "sourceOutput": 0,
          "target": "node_20",
          "targetInput": 0
        },
        {
          "source": "node_20",
          "sourceOutput": 0,
          "target": "node_21",
          "targetInput": 0
        },
        {
          "source": "node_21",
          "sourceOutput": 0,
          "target": "node_22",
          "targetInput": 0
        },
        {
          "source": "node_22",
          "sourceOutput": 0,
          "target": "node_23",
          "targetInput": 0
        },
        {
          "source": "node_22",
          "sourceOutput": 0,
          "target": "node_24",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "law_04_invoice_ar_follow_up_bot",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Law Firms",
        "Billing"
      ],
      "notes": "Runs daily. Checks Clio Payments/QuickBooks for overdue invoices. Sends staged AI-drafted follow-ups at 14/30/45 days. Escalates to billing partner at 45 days."
    },
    {
      "name": "LAW-05: Client Matter Status Update",
      "nodes": [
        {
          "id": "node_25",
          "name": "⏰ Monday 9am Status Run",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 9 * * 1"
                }
              ]
            }
          }
        },
        {
          "id": "node_26",
          "name": "📂 Fetch Active Matters",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.CLIO_BASE_URL }}/api/v4/matters?fields=id,display_number,description,status,client{name,email},activity_entries{date,type,note}&status=open&updated_since={{ new Date(Date.now()-604800000).toISOString() }}",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_27",
          "name": "🤖 AI: Draft Client Status Update",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a client relations coordinator for a law firm. Write a warm, professional weekly update email to the client. Summarise what has happened on their matter this week in plain English (no legal jargon), explain what the next steps are, and reassure them their matter is progressing. Keep it to 3-4 short paragraphs. Respond in JSON: {subject, body}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Client Name: ${$json.client.name}\\nMatter: ${$json.display_number} — ${$json.description}\\nThis week's activity: ${JSON.stringify($json.activity_entries?.slice(0,5))}\\nCurrent status: ${$json.status}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_28",
          "name": "📧 Send Status Update to Client",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.client.email }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Draft Client Status Update'].json.content[0].text).subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Draft Client Status Update'].json.content[0].text).body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_25",
          "sourceOutput": 0,
          "target": "node_26",
          "targetInput": 0
        },
        {
          "source": "node_26",
          "sourceOutput": 0,
          "target": "node_27",
          "targetInput": 0
        },
        {
          "source": "node_27",
          "sourceOutput": 0,
          "target": "node_28",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "law_05_client_matter_status_update",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Law Firms",
        "Client Communication"
      ],
      "notes": "Runs weekly on Monday. Fetches all active matters from Clio, generates AI-written personalised status updates for each client summarising recent activity and next steps."
    },
    {
      "name": "LAW-06: New Staff Onboarding Journey",
      "nodes": [
        {
          "id": "node_29",
          "name": "👤 New Employee Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "law-new-hire",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_30",
          "name": "Extract Employee Data",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            280,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "f1",
                  "name": "name",
                  "type": "string",
                  "value": "={{ $json.body.name }}"
                },
                {
                  "id": "f2",
                  "name": "email",
                  "type": "string",
                  "value": "={{ $json.body.email }}"
                },
                {
                  "id": "f3",
                  "name": "role",
                  "type": "string",
                  "value": "={{ $json.body.role }}"
                },
                {
                  "id": "f4",
                  "name": "managerEmail",
                  "type": "string",
                  "value": "={{ $json.body.managerEmail }}"
                },
                {
                  "id": "f5",
                  "name": "startDate",
                  "type": "string",
                  "value": "={{ $json.body.startDate }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_31",
          "name": "📧 Day 1: Welcome Email",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            560,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $node['Extract Employee Data'].json.email }}",
            "subject": "=Welcome to the team, {{ $node['Extract Employee Data'].json.name }}!",
            "message": "=Dear {{ $node['Extract Employee Data'].json.name }},\n\nWelcome to the firm! We're thrilled to have you join us as {{ $node['Extract Employee Data'].json.role }}.\n\nYour first week will focus on getting you set up, meeting the team, and understanding how we work. Your manager will check in with you today to walk you through your schedule.\n\nKey things for Day 1:\n• IT setup instructions will arrive separately in the next few minutes\n• Your Clio login credentials are being prepared and will be emailed to you shortly  \n• Please review the Employee Handbook in your onboarding portal when you get a moment\n\nWe're glad you're here. Don't hesitate to reach out with any questions.\n\nWarm regards,\nThe Securafy Onboarding System",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_32",
          "name": "⏳ Wait 3 Days",
          "type": "n8n-nodes-base.wait",
          "typeVersion": 1.1,
          "position": [
            840,
            0
          ],
          "parameters": {
            "resume": "timeInterval",
            "time": 3,
            "unit": "days"
          }
        },
        {
          "id": "node_33",
          "name": "📧 Day 3: Systems & Access Email",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            1120,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $node['Extract Employee Data'].json.email }}",
            "subject": "=Your firm systems access — Day 3 checklist",
            "message": "=Hi {{ $node['Extract Employee Data'].json.name }},\n\nChecking in on Day 3! Here's your systems access checklist:\n\n□ Clio (Practice Management) — credentials sent Day 1\n□ Microsoft 365 / Google Workspace — see IT email\n□ Document storage — ask your manager for folder access\n□ Time tracking — your manager will set this up with you today\n□ Client portal access — if applicable to your role\n\nIf anything is missing or not working, contact IT at {{ $env.IT_EMAIL }} — they'll prioritise same-day resolution for new starters.\n\nSee you at the team meeting at 2pm!",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_34",
          "name": "⏳ Wait 7 More Days",
          "type": "n8n-nodes-base.wait",
          "typeVersion": 1.1,
          "position": [
            1400,
            0
          ],
          "parameters": {
            "resume": "timeInterval",
            "time": 7,
            "unit": "days"
          }
        }
      ],
      "connections": [
        {
          "source": "node_29",
          "sourceOutput": 0,
          "target": "node_30",
          "targetInput": 0
        },
        {
          "source": "node_30",
          "sourceOutput": 0,
          "target": "node_31",
          "targetInput": 0
        },
        {
          "source": "node_31",
          "sourceOutput": 0,
          "target": "node_32",
          "targetInput": 0
        },
        {
          "source": "node_32",
          "sourceOutput": 0,
          "target": "node_33",
          "targetInput": 0
        },
        {
          "source": "node_33",
          "sourceOutput": 0,
          "target": "node_34",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "law_06_new_staff_onboarding_journey",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Law Firms",
        "HR"
      ],
      "notes": "Triggers when a new employee is added to HR system. Delivers a personalised 30-day onboarding sequence: Day 1 welcome, Day 3 IT setup, Day 7 policy review, Day 14 check-in, Day 30 review prompt."
    },
    {
      "name": "CPA-01: Client Document Request & Chase System",
      "nodes": [
        {
          "id": "node_35",
          "name": "📂 New Engagement Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "cpa-engagement-open",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_36",
          "name": "Build Document Checklist",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            280,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "g1",
                  "name": "clientName",
                  "type": "string",
                  "value": "={{ $json.body.clientName }}"
                },
                {
                  "id": "g2",
                  "name": "clientEmail",
                  "type": "string",
                  "value": "={{ $json.body.clientEmail }}"
                },
                {
                  "id": "g3",
                  "name": "engagementType",
                  "type": "string",
                  "value": "={{ $json.body.engagementType }}"
                },
                {
                  "id": "g4",
                  "name": "taxYear",
                  "type": "string",
                  "value": "={{ $json.body.taxYear }}"
                },
                {
                  "id": "g5",
                  "name": "dueDate",
                  "type": "string",
                  "value": "={{ $json.body.dueDate }}"
                },
                {
                  "id": "g6",
                  "name": "accountantEmail",
                  "type": "string",
                  "value": "={{ $json.body.accountantEmail }}"
                },
                {
                  "id": "g7",
                  "name": "uploadPortalUrl",
                  "type": "string",
                  "value": "={{ $env.CLIENT_PORTAL_URL }}/{{ $json.body.clientId }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_37",
          "name": "🤖 AI: Generate Document Request",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a client services coordinator at a CPA firm. Based on the engagement type, create a friendly, itemised list of documents the client needs to provide. Use plain English, not accounting jargon. Include a brief explanation of why each item is needed. Respond in JSON: {subject, introText, documentList, closingText}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Client: ${$json.clientName}\\nEngagement Type: ${$json.engagementType}\\nTax Year: ${$json.taxYear}\\nDue Date: ${$json.dueDate}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_38",
          "name": "📧 Send Document Request to Client",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $node['Build Document Checklist'].json.clientEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Generate Document Request'].json.content[0].text).subject }}",
            "message": "={{ (() => {\n  const ai = JSON.parse($node['🤖 AI: Generate Document Request'].json.content[0].text);\n  return `${ai.introText}\\n\\nDocuments Needed:\\n${ai.documentList}\\n\\n${ai.closingText}\\n\\nPlease upload your documents here: ${$node['Build Document Checklist'].json.uploadPortalUrl}\\n\\nDeadline: ${$node['Build Document Checklist'].json.dueDate}`;\n})() }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_39",
          "name": "⏳ Wait 7 Days Then Chase",
          "type": "n8n-nodes-base.wait",
          "typeVersion": 1.1,
          "position": [
            1120,
            0
          ],
          "parameters": {
            "resume": "timeInterval",
            "time": 7,
            "unit": "days"
          }
        },
        {
          "id": "node_40",
          "name": "📧 7-Day Chase Reminder",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            1400,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $node['Build Document Checklist'].json.clientEmail }}",
            "subject": "=Reminder: Documents needed for your {{ $node['Build Document Checklist'].json.engagementType }} — {{ $node['Build Document Checklist'].json.taxYear }}",
            "message": "=Hi {{ $node['Build Document Checklist'].json.clientName }},\n\nJust a friendly reminder that we're still waiting on some documents for your {{ $node['Build Document Checklist'].json.engagementType }}.\n\nYour deadline is {{ $node['Build Document Checklist'].json.dueDate }}. To avoid any delays or filing extensions, please upload your documents as soon as possible:\n\n{{ $node['Build Document Checklist'].json.uploadPortalUrl }}\n\nIf you've already uploaded everything, please ignore this message — our team will review shortly.\n\nIf you have any questions about what's needed, just reply to this email.\n\nThank you,\n{{ $env.FIRM_NAME }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_35",
          "sourceOutput": 0,
          "target": "node_36",
          "targetInput": 0
        },
        {
          "source": "node_36",
          "sourceOutput": 0,
          "target": "node_37",
          "targetInput": 0
        },
        {
          "source": "node_37",
          "sourceOutput": 0,
          "target": "node_38",
          "targetInput": 0
        },
        {
          "source": "node_38",
          "sourceOutput": 0,
          "target": "node_39",
          "targetInput": 0
        },
        {
          "source": "node_39",
          "sourceOutput": 0,
          "target": "node_40",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "cpa_01_client_document_request_chase_system",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "CPA",
        "Document Management"
      ],
      "notes": "Triggers when a new engagement is opened. Sends personalised document request checklist to client. Sends reminders at 14/7/3 days before deadline. Alerts accountant if critical items still missing."
    },
    {
      "name": "CPA-02: New Client Onboarding Workflow",
      "nodes": [
        {
          "id": "node_41",
          "name": "✍️ Engagement Signed Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "cpa-engagement-signed",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_42",
          "name": "🤖 AI: Generate Welcome Package",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a client onboarding coordinator at a CPA firm. Create a warm, professional welcome package for a new client. Include: 1) A personalised welcome email, 2) A plain-English summary of what the engagement covers and what to expect, 3) Next steps with specific dates. Respond in JSON: {welcomeSubject, welcomeBody, nextSteps}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Client Name: ${$json.body.clientName}\\nBusiness Name: ${$json.body.businessName || 'N/A'}\\nEngagement Type: ${$json.body.engagementType}\\nLead Accountant: ${$json.body.accountantName}\\nSigned Date: ${new Date().toLocaleDateString()}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_43",
          "name": "📧 Send Welcome Email",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            560,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.clientEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Generate Welcome Package'].json.content[0].text).welcomeSubject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Generate Welcome Package'].json.content[0].text).welcomeBody }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_44",
          "name": "🔔 Notify Accountant & Create Tasks",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            560,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_ACCOUNTANTS_CHANNEL }}",
            "text": "=🎉 *New Client Onboarded*\\n*Client:* {{ $json.body.clientName }} {{ $json.body.businessName ? '(' + $json.body.businessName + ')' : '' }}\\n*Engagement:* {{ $json.body.engagementType }}\\n*Portal Invite:* Sent ✓\\n*Welcome Email:* Sent ✓\\n*Action Required:* Schedule kickoff call — target within 5 business days",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_41",
          "sourceOutput": 0,
          "target": "node_42",
          "targetInput": 0
        },
        {
          "source": "node_42",
          "sourceOutput": 0,
          "target": "node_43",
          "targetInput": 0
        },
        {
          "source": "node_42",
          "sourceOutput": 0,
          "target": "node_44",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "cpa_02_new_client_onboarding_workflow",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "CPA",
        "Onboarding"
      ],
      "notes": "Triggers when a new engagement letter is signed. Generates personalised welcome email, engagement letter summary, portal invite, and kickoff scheduling — all within 2 hours of signing."
    },
    {
      "name": "CPA-03: Tax Deadline Reminder System",
      "nodes": [
        {
          "id": "node_45",
          "name": "⏰ Daily Deadline Check 7:30am",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "30 7 * * 1-5"
                }
              ]
            }
          }
        },
        {
          "id": "node_46",
          "name": "📅 Fetch Client Deadlines",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.PRACTICE_MGMT_URL }}/api/clients/deadlines?upcoming_days=30",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_47",
          "name": "🤖 AI: Draft Deadline Reminder",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a tax coordinator. Draft a clear, friendly deadline reminder for a tax client. Explain what is due, when, and what they need to do (if anything). Vary tone based on urgency: 30d = gentle heads-up, 14d = reminder, 7d = action required, 2d = urgent. Respond in JSON: {subject, body}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Client: ${$json.clientName}\\nReturn Type: ${$json.returnType}\\nDeadline: ${$json.deadline}\\nDays Until Deadline: ${$json.daysUntil}\\nStatus: ${$json.status}\\nAccountant: ${$json.accountantName}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_48",
          "name": "📧 Send Deadline Reminder",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.clientEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Draft Deadline Reminder'].json.content[0].text).subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Draft Deadline Reminder'].json.content[0].text).body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_45",
          "sourceOutput": 0,
          "target": "node_46",
          "targetInput": 0
        },
        {
          "source": "node_46",
          "sourceOutput": 0,
          "target": "node_47",
          "targetInput": 0
        },
        {
          "source": "node_47",
          "sourceOutput": 0,
          "target": "node_48",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "cpa_03_tax_deadline_reminder_system",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "CPA",
        "Tax Deadlines"
      ],
      "notes": "Runs daily. Checks upcoming filing deadlines for all active clients. Sends personalised reminders at 30/14/7/2 days. Notifies client when return is ready for review. Sends e-file confirmation."
    },
    {
      "name": "CPA-04: Invoice & AR Follow-Up Bot",
      "nodes": [
        {
          "id": "node_49",
          "name": "⏰ Daily AR Check 8am Weekdays",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 8 * * 1-5"
                }
              ]
            }
          }
        },
        {
          "id": "node_50",
          "name": "💰 Fetch Overdue Invoices from QuickBooks",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.QB_BASE_URL }}/v3/company/{{ $env.QB_REALM_ID }}/query?query=SELECT * FROM Invoice WHERE Balance > '0' AND DueDate < '{{ new Date().toISOString().split('T')[0] }}'",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_51",
          "name": "Calculate Overdue Buckets",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            560,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "h1",
                  "name": "overdue14",
                  "type": "string",
                  "value": "={{ $json.QueryResponse.Invoice.filter(inv => Math.floor((new Date()-new Date(inv.DueDate))/86400000) === 14) }}"
                },
                {
                  "id": "h2",
                  "name": "overdue30",
                  "type": "string",
                  "value": "={{ $json.QueryResponse.Invoice.filter(inv => Math.floor((new Date()-new Date(inv.DueDate))/86400000) === 30) }}"
                },
                {
                  "id": "h3",
                  "name": "overdue45",
                  "type": "string",
                  "value": "={{ $json.QueryResponse.Invoice.filter(inv => Math.floor((new Date()-new Date(inv.DueDate))/86400000) === 45) }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_52",
          "name": "🤖 AI: Draft AR Follow-Up",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            840,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a billing coordinator at a CPA firm. Draft a professional accounts receivable follow-up email. Tone: 14 days = polite reminder, 30 days = firm request, 45 days = formal notice with urgency. Reference the specific invoice and engagement. Never be threatening. Respond in JSON: {subject, body}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Client: ${$json.CustomerRef.name}\\nInvoice #: ${$json.DocNumber}\\nAmount Due: $${$json.Balance}\\nOriginal Due Date: ${$json.DueDate}\\nDays Overdue: ${$json.daysOverdue}\\nEngagement: ${$json.PrivateNote || 'Professional Services'}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_53",
          "name": "📧 Send AR Follow-Up",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            1120,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.BillEmail?.Address }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Draft AR Follow-Up'].json.content[0].text).subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Draft AR Follow-Up'].json.content[0].text).body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_49",
          "sourceOutput": 0,
          "target": "node_50",
          "targetInput": 0
        },
        {
          "source": "node_50",
          "sourceOutput": 0,
          "target": "node_51",
          "targetInput": 0
        },
        {
          "source": "node_51",
          "sourceOutput": 0,
          "target": "node_52",
          "targetInput": 0
        },
        {
          "source": "node_52",
          "sourceOutput": 0,
          "target": "node_53",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "cpa_04_invoice_ar_follow_up_bot",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "CPA",
        "Billing"
      ],
      "notes": "Runs daily Monday-Friday. Checks QuickBooks/Xero for overdue invoices. Sends staged AI-drafted follow-ups at 14/30/45 days. Notifies partner at 45 days."
    },
    {
      "name": "CPA-05: Client Inquiry Triage & Routing",
      "nodes": [
        {
          "id": "node_54",
          "name": "📥 Gmail Inbox Monitor",
          "type": "n8n-nodes-base.gmailTrigger",
          "typeVersion": 1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "pollTimes": {
              "item": [
                {
                  "mode": "everyMinute"
                }
              ]
            },
            "filters": {
              "readStatus": "unread",
              "labels": [
                "=inbox"
              ]
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_55",
          "name": "🤖 AI: Classify & Triage Email",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are an email triage specialist for a CPA firm. Classify this client email and determine the appropriate response. Categories: TAX_QUERY, DOCUMENT_REQUEST, STATUS_CHECK, BILLING_QUESTION, APPOINTMENT_REQUEST, URGENT, GENERAL. For simple queries (status checks, hours, portal access), draft a complete response. For complex queries, draft a routing note for the accountant. Respond in JSON: {category, priority, assignTo, canAutoRespond, responseSubject, responseBody, internalNote}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`From: ${$json.From}\\nSubject: ${$json.Subject}\\nBody: ${$json.snippet}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_56",
          "name": "Parse Triage Decision",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            560,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "i1",
                  "name": "triageData",
                  "type": "string",
                  "value": "={{ JSON.parse($node['🤖 AI: Classify & Triage Email'].json.content[0].text) }}"
                },
                {
                  "id": "i2",
                  "name": "canAutoRespond",
                  "type": "boolean",
                  "value": "={{ JSON.parse($node['🤖 AI: Classify & Triage Email'].json.content[0].text).canAutoRespond }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_57",
          "name": "📧 Auto-Respond to Simple Queries",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.From }}",
            "subject": "=Re: {{ $json.Subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Classify & Triage Email'].json.content[0].text).responseBody }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_58",
          "name": "🔔 Route Complex Query to Accountant",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            840,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_ACCOUNTANTS_CHANNEL }}",
            "text": "=📧 *New Client Email — {{ JSON.parse($node['🤖 AI: Classify & Triage Email'].json.content[0].text).category }}* ({{ JSON.parse($node['🤖 AI: Classify & Triage Email'].json.content[0].text).priority }})\\n*From:* {{ $json.From }}\\n*Subject:* {{ $json.Subject }}\\n*Assign To:* {{ JSON.parse($node['🤖 AI: Classify & Triage Email'].json.content[0].text).assignTo }}\\n*Note:* {{ JSON.parse($node['🤖 AI: Classify & Triage Email'].json.content[0].text).internalNote }}",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_54",
          "sourceOutput": 0,
          "target": "node_55",
          "targetInput": 0
        },
        {
          "source": "node_55",
          "sourceOutput": 0,
          "target": "node_56",
          "targetInput": 0
        },
        {
          "source": "node_56",
          "sourceOutput": 0,
          "target": "node_57",
          "targetInput": 0
        },
        {
          "source": "node_56",
          "sourceOutput": 0,
          "target": "node_58",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "cpa_05_client_inquiry_triage_routing",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "CPA",
        "Inbox Management"
      ],
      "notes": "Monitors shared inbox. AI classifies incoming client emails by type (tax query, doc request, status check, billing, urgent). Routes to correct accountant. Drafts and sends responses for simple routine queries automatically."
    },
    {
      "name": "CPA-06: Bookkeeping Anomaly & Variance Alert",
      "nodes": [
        {
          "id": "node_59",
          "name": "⏰ Weekly Friday 4pm Review",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 16 * * 5"
                }
              ]
            }
          }
        },
        {
          "id": "node_60",
          "name": "📊 Fetch Client Transaction Data",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.QB_BASE_URL }}/v3/company/{{ $env.QB_REALM_ID }}/query?query=SELECT * FROM Transaction WHERE TxnDate >= '{{ new Date(Date.now()-604800000).toISOString().split('T')[0] }}'",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_61",
          "name": "🤖 AI: Identify Anomalies",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a bookkeeping review specialist. Analyse these transactions for: 1) Unusually large amounts compared to typical patterns, 2) Transactions missing category/class, 3) Potential duplicate entries, 4) Round-number transactions (possible estimates), 5) Transactions to/from unusual vendors, 6) Category mismatches. Provide a prioritised exception report. Respond in JSON: {anomalyCount, criticalItems, warningItems, infoItems, summary, recommendedActions}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Client: ${$json.clientName}\\nPeriod: Last 7 days\\nTransaction Count: ${$json.QueryResponse?.Transaction?.length || 0}\\nTransactions: ${JSON.stringify($json.QueryResponse?.Transaction?.slice(0,50))}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_62",
          "name": "📧 Send Exception Report to Accountant",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.accountantEmail }}",
            "subject": "=📊 Weekly Bookkeeping Review: {{ $json.clientName }} — {{ JSON.parse($node['🤖 AI: Identify Anomalies'].json.content[0].text).anomalyCount }} items flagged",
            "message": "={{ (() => {\n  const ai = JSON.parse($node['🤖 AI: Identify Anomalies'].json.content[0].text);\n  return `BOOKKEEPING EXCEPTION REPORT\\nClient: ${$json.clientName}\\nPeriod: Last 7 days\\n\\nSUMMARY\\n${ai.summary}\\n\\nCRITICAL ITEMS (Action Required)\\n${ai.criticalItems || 'None'}\\n\\nWARNING ITEMS (Review Recommended)\\n${ai.warningItems || 'None'}\\n\\nINFO ITEMS (Awareness Only)\\n${ai.infoItems || 'None'}\\n\\nRECOMMENDED ACTIONS\\n${ai.recommendedActions}`;\n})() }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_59",
          "sourceOutput": 0,
          "target": "node_60",
          "targetInput": 0
        },
        {
          "source": "node_60",
          "sourceOutput": 0,
          "target": "node_61",
          "targetInput": 0
        },
        {
          "source": "node_61",
          "sourceOutput": 0,
          "target": "node_62",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "cpa_06_bookkeeping_anomaly_variance_alert",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "CPA",
        "Bookkeeping"
      ],
      "notes": "Runs weekly. Pulls client bookkeeping data from QuickBooks/Xero. AI reviews for unusual entries, large variances, missing categorisation, and duplicate transactions. Delivers exception report to accountant."
    },
    {
      "name": "CLUB-01: Member Inquiry & Communication Assistant",
      "nodes": [
        {
          "id": "node_63",
          "name": "📥 Member Inquiry Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "club-inquiry",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_64",
          "name": "🤖 AI: Classify & Draft Response",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a member services coordinator at a prestigious private club. Classify this member inquiry and draft a warm, personalised acknowledgement. The club's tone is professional, warm, and attentive. Categories: DINING_RESERVATION, GOLF_TEE_TIME, EVENT_INQUIRY, MEMBERSHIP_QUESTION, FACILITY_BOOKING, BILLING, COMPLAINT, GENERAL. Respond in JSON: {category, priority, routeTo, subject, acknowledgeBody, internalNote}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Member Name: ${$json.body.memberName}\\nMembership #: ${$json.body.membershipNumber || 'unknown'}\\nInquiry: ${$json.body.message}\\nChannel: ${$json.body.channel || 'email'}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_65",
          "name": "📧 Send Acknowledgement to Member",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            560,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.memberEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Classify & Draft Response'].json.content[0].text).subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Classify & Draft Response'].json.content[0].text).acknowledgeBody }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_66",
          "name": "🔔 Route to Correct Department",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            560,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env['SLACK_' + JSON.parse($node['🤖 AI: Classify & Draft Response'].json.content[0].text).routeTo + '_CHANNEL'] || $env.SLACK_MEMBER_SERVICES_CHANNEL }}",
            "text": "=🏌️ *Member Inquiry — {{ JSON.parse($node['🤖 AI: Classify & Draft Response'].json.content[0].text).category }}*\\n*Member:* {{ $json.body.memberName }} ({{ $json.body.membershipNumber }})\\n*Priority:* {{ JSON.parse($node['🤖 AI: Classify & Draft Response'].json.content[0].text).priority }}\\n*Note:* {{ JSON.parse($node['🤖 AI: Classify & Draft Response'].json.content[0].text).internalNote }}\\n_Acknowledgement sent ✓_",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        },
        {
          "id": "node_67",
          "name": "📋 Log in Club Management System",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            320
          ],
          "parameters": {
            "method": "POST",
            "url": "={{ $env.CLUB_MGMT_URL }}/api/member-inquiries",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "memberId",
                    "value": "={{ $json.body.memberId }}"
                  },
                  {
                    "name": "category",
                    "value": "={{ JSON.parse($node['🤖 AI: Classify & Draft Response'].json.content[0].text).category }}"
                  },
                  {
                    "name": "note",
                    "value": "={{ JSON.parse($node['🤖 AI: Classify & Draft Response'].json.content[0].text).internalNote }}"
                  },
                  {
                    "name": "status",
                    "value": "acknowledged"
                  }
                ]
              }
            },
            "options": {}
          }
        }
      ],
      "connections": [
        {
          "source": "node_63",
          "sourceOutput": 0,
          "target": "node_64",
          "targetInput": 0
        },
        {
          "source": "node_64",
          "sourceOutput": 0,
          "target": "node_65",
          "targetInput": 0
        },
        {
          "source": "node_64",
          "sourceOutput": 0,
          "target": "node_66",
          "targetInput": 0
        },
        {
          "source": "node_64",
          "sourceOutput": 0,
          "target": "node_67",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "club_01_member_inquiry_communication_assistant",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Country Clubs",
        "Member Services"
      ],
      "notes": "Monitors member email, web form submissions, and voicemail transcriptions. AI classifies inquiry type and routes to correct department. Drafts and sends warm, personalised acknowledgement within minutes."
    },
    {
      "name": "CLUB-02: Event & Tournament Coordination System",
      "nodes": [
        {
          "id": "node_68",
          "name": "🎉 New Event Created Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "club-new-event",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_69",
          "name": "🤖 AI: Generate Event Communications",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are an events coordinator at a prestigious private club. Create a complete event communication package. The club's tone is warm, exclusive, and inviting. Generate: 1) A compelling invitation email, 2) A 7-day reminder, 3) A 2-day final reminder, 4) A post-event thank-you with feedback request. Respond in JSON: {invitationSubject, invitationBody, reminder7Subject, reminder7Body, reminder2Subject, reminder2Body, thankYouSubject, thankYouBody}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Event Name: ${$json.body.eventName}\\nDate: ${$json.body.eventDate}\\nTime: ${$json.body.eventTime}\\nLocation: ${$json.body.location}\\nDescription: ${$json.body.description}\\nDress Code: ${$json.body.dressCode || 'Smart Casual'}\\nCapacity: ${$json.body.capacity}\\nRSVP Deadline: ${$json.body.rsvpDeadline}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_70",
          "name": "📋 Fetch Invited Member List",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.CLUB_MGMT_URL }}/api/members?segment={{ $json.body.memberSegment || 'all' }}&status=active",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_71",
          "name": "📧 Send Invitations to Members",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.email }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Generate Event Communications'].json.content[0].text).invitationSubject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Generate Event Communications'].json.content[0].text).invitationBody + '\\n\\nRSVP here: ' + $env.RSVP_BASE_URL + '/' + $node['🎉 New Event Created Webhook'].json.body.eventId + '?member=' + $json.memberId }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_72",
          "name": "🔔 Notify Events Team",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            840,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_EVENTS_CHANNEL }}",
            "text": "=🎉 *Event invitations sent*\\n*Event:* {{ $node['🎉 New Event Created Webhook'].json.body.eventName }}\\n*Date:* {{ $node['🎉 New Event Created Webhook'].json.body.eventDate }}\\n*Invitations sent to:* {{ $node['📋 Fetch Invited Member List'].json.length }} members\\n*Reminder schedule:* 14d, 7d, 2d automations queued ✓",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_68",
          "sourceOutput": 0,
          "target": "node_69",
          "targetInput": 0
        },
        {
          "source": "node_68",
          "sourceOutput": 0,
          "target": "node_70",
          "targetInput": 0
        },
        {
          "source": "node_70",
          "sourceOutput": 0,
          "target": "node_71",
          "targetInput": 0
        },
        {
          "source": "node_71",
          "sourceOutput": 0,
          "target": "node_72",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "club_02_event_tournament_coordination_system",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Country Clubs",
        "Events"
      ],
      "notes": "Triggers when a new event is created. Generates invitations and sends to member list. Fires reminders at 14/7/2 days. Compiles live RSVP dashboard. Sends post-event thank-you and feedback request."
    },
    {
      "name": "CLUB-03: New Member Onboarding Journey",
      "nodes": [
        {
          "id": "node_73",
          "name": "🏌️ New Member Approved Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "club-new-member",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_74",
          "name": "🤖 AI: Generate Welcome Series",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a member relations coordinator at a prestigious private club. Create a warm, personalised 30-day welcome email series for a new member. The tone is exclusive, warm, and attentive. Generate Day 1 welcome, Day 7 facilities guide, Day 14 introduction to events, Day 30 first month check-in. Tailor content to their stated interests. Respond in JSON: {day1Subject, day1Body, day7Subject, day7Body, day14Subject, day14Body, day30Subject, day30Body}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Member Name: ${$json.body.memberName}\\nMembership Type: ${$json.body.membershipType}\\nInterests: ${$json.body.interests?.join(', ') || 'general'}\\nSpouse/Family: ${$json.body.familyMembers || 'N/A'}\\nJoin Date: ${new Date().toLocaleDateString()}\\nMember Number: ${$json.body.memberNumber}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_75",
          "name": "📧 Day 1: Welcome Email",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            560,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.memberEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Generate Welcome Series'].json.content[0].text).day1Subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Generate Welcome Series'].json.content[0].text).day1Body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_76",
          "name": "🔔 Alert Membership Director",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            560,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_MEMBERSHIP_CHANNEL }}",
            "text": "=🎉 *New Member Onboarded*\\n*Name:* {{ $json.body.memberName }}\\n*Type:* {{ $json.body.membershipType }}\\n*Interests:* {{ $json.body.interests?.join(', ') }}\\n*30-day welcome sequence activated ✓*\\nPlease schedule a personal welcome call within 5 days.",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        },
        {
          "id": "node_77",
          "name": "⏳ Wait 7 Days",
          "type": "n8n-nodes-base.wait",
          "typeVersion": 1.1,
          "position": [
            840,
            0
          ],
          "parameters": {
            "resume": "timeInterval",
            "time": 7,
            "unit": "days"
          }
        }
      ],
      "connections": [
        {
          "source": "node_73",
          "sourceOutput": 0,
          "target": "node_74",
          "targetInput": 0
        },
        {
          "source": "node_74",
          "sourceOutput": 0,
          "target": "node_75",
          "targetInput": 0
        },
        {
          "source": "node_74",
          "sourceOutput": 0,
          "target": "node_76",
          "targetInput": 0
        },
        {
          "source": "node_75",
          "sourceOutput": 0,
          "target": "node_77",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "club_03_new_member_onboarding_journey",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Country Clubs",
        "Membership"
      ],
      "notes": "Triggers when a new member is approved. Delivers a personalised 30-day welcome sequence introducing the club's facilities, key contacts, upcoming events relevant to their interests, and dining reservations."
    },
    {
      "name": "CLUB-04: Dining & Facility Reservation Follow-Up",
      "nodes": [
        {
          "id": "node_78",
          "name": "🍽️ New Reservation Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "club-reservation",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_79",
          "name": "🤖 AI: Generate Reservation Communications",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a hospitality coordinator at a prestigious private club. Create personalised reservation communications. The tone is warm, attentive, and exclusive. Generate: 1) A confirmation email, 2) A 24-hour reminder, 3) A post-visit thank you with discreet feedback request. Reference the specific booking details. Respond in JSON: {confirmSubject, confirmBody, reminderSubject, reminderBody, thankYouSubject, thankYouBody}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Member: ${$json.body.memberName}\\nReservation Type: ${$json.body.reservationType}\\nDate: ${$json.body.date}\\nTime: ${$json.body.time}\\nParty Size: ${$json.body.partySize}\\nSpecial Requests: ${$json.body.specialRequests || 'None'}\\nLocation: ${$json.body.facility}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_80",
          "name": "📧 Send Confirmation",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            560,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.memberEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Generate Reservation Communications'].json.content[0].text).confirmSubject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Generate Reservation Communications'].json.content[0].text).confirmBody }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_81",
          "name": "⏳ Wait Until 24hrs Before",
          "type": "n8n-nodes-base.wait",
          "typeVersion": 1.1,
          "position": [
            840,
            0
          ],
          "parameters": {
            "resume": "timeInterval",
            "time": 0,
            "unit": "days"
          }
        }
      ],
      "connections": [
        {
          "source": "node_78",
          "sourceOutput": 0,
          "target": "node_79",
          "targetInput": 0
        },
        {
          "source": "node_79",
          "sourceOutput": 0,
          "target": "node_80",
          "targetInput": 0
        },
        {
          "source": "node_80",
          "sourceOutput": 0,
          "target": "node_81",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "club_04_dining_facility_reservation_follow_up",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Country Clubs",
        "Reservations"
      ],
      "notes": "Triggers on new booking (dining, golf, tennis, spa). Sends confirmation with personalised details. 24-hour reminder. Post-visit thank-you with feedback request."
    },
    {
      "name": "CLUB-05: Member Dues & Billing Communication",
      "nodes": [
        {
          "id": "node_82",
          "name": "⏰ Monthly Dues Check 1st of Month",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 8 1 * *"
                }
              ]
            }
          }
        },
        {
          "id": "node_83",
          "name": "💰 Fetch Overdue Member Accounts",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.CLUB_MGMT_URL }}/api/billing/overdue?min_days=14",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_84",
          "name": "🤖 AI: Draft Billing Communication",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a membership coordinator at a prestigious private club. Draft a billing reminder that is discreet, respectful, and maintains the member's dignity at all times. The tone should reflect the club's high standards. Never use aggressive or threatening language. For 14 days: gentle reminder. For 30 days: warm but clearer request. Respond in JSON: {subject, body, escalateToDirector}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Member Name: ${$json.memberName}\\nMembership Type: ${$json.membershipType}\\nAmount Due: $${$json.amountDue}\\nDue Date: ${$json.dueDate}\\nDays Overdue: ${$json.daysOverdue}\\nYears of Membership: ${$json.yearsOfMembership}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_85",
          "name": "📧 Send Billing Communication",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.memberEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Draft Billing Communication'].json.content[0].text).subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Draft Billing Communication'].json.content[0].text).body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_82",
          "sourceOutput": 0,
          "target": "node_83",
          "targetInput": 0
        },
        {
          "source": "node_83",
          "sourceOutput": 0,
          "target": "node_84",
          "targetInput": 0
        },
        {
          "source": "node_84",
          "sourceOutput": 0,
          "target": "node_85",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "club_05_member_dues_billing_communication",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Country Clubs",
        "Billing"
      ],
      "notes": "Runs monthly. Generates dues statements. Sends discreet, respectful billing reminders at 14/30 days overdue. Maintains member dignity throughout. Escalates to Membership Director at 30 days."
    },
    {
      "name": "CLUB-06: Review & Reputation Management",
      "nodes": [
        {
          "id": "node_86",
          "name": "⏰ Check Reviews Every 4 Hours",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 */4 * * *"
                }
              ]
            }
          }
        },
        {
          "id": "node_87",
          "name": "⭐ Fetch New Google Reviews",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "=https://mybusiness.googleapis.com/v4/accounts/{{ $env.GOOGLE_ACCOUNT_ID }}/locations/{{ $env.GOOGLE_LOCATION_ID }}/reviews?pageSize=5&orderBy=updateTime+desc",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_88",
          "name": "🤖 AI: Draft Review Response",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are representing a prestigious private club. Draft a sophisticated, warm, and personalised response to this member/guest review. The response should: reflect the club's high standards and values, acknowledge specific points raised, be genuine and not formulaic, be 2-3 sentences for positive reviews, 3-4 sentences for negative reviews (with empathy and corrective action). Respond in JSON: {responseText, sentiment, followUpRequired, internalNote}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Reviewer: ${$json.reviewer?.displayName || 'Member'}\\nRating: ${$json.starRating}/5\\nReview: ${$json.comment}\\nDate: ${$json.createTime}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_89",
          "name": "🔔 Send Draft Response for Approval",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_GM_CHANNEL }}",
            "text": "=⭐ *New Review — {{ $json.starRating }}/5 stars*\\n*Reviewer:* {{ $json.reviewer?.displayName }}\\n*Review:* {{ $json.comment.substring(0,200) }}...\\n\\n*Drafted Response:*\\n{{ JSON.parse($node['🤖 AI: Draft Review Response'].json.content[0].text).responseText }}\\n\\n_Approve and post? Reply ✅ to confirm or ✏️ to edit_",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_86",
          "sourceOutput": 0,
          "target": "node_87",
          "targetInput": 0
        },
        {
          "source": "node_87",
          "sourceOutput": 0,
          "target": "node_88",
          "targetInput": 0
        },
        {
          "source": "node_88",
          "sourceOutput": 0,
          "target": "node_89",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "club_06_review_reputation_management",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Country Clubs",
        "Reputation"
      ],
      "notes": "Monitors Google Business Profile and club directories for new reviews. AI drafts sophisticated, personalised responses in the club's voice. Compiles monthly sentiment summary for GM."
    },
    {
      "name": "MFG-01: Purchase Order Follow-Up & Supplier Chase",
      "nodes": [
        {
          "id": "node_90",
          "name": "⏰ Check POs Every 4 Hours",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 */4 * * 1-5"
                }
              ]
            }
          }
        },
        {
          "id": "node_91",
          "name": "📦 Fetch Unacknowledged POs from ERP",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.ERP_BASE_URL }}/api/purchase-orders?status=sent&acknowledged=false&issued_before={{ new Date(Date.now()-86400000).toISOString() }}",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_92",
          "name": "🤖 AI: Draft Supplier Chase Email",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a purchasing coordinator. Draft a professional, firm but polite email chasing a supplier for acknowledgement of a purchase order. Reference the specific PO number and line items. Request confirmation by end of business today. Respond in JSON: {subject, body, escalateRequired}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Supplier Name: ${$json.supplierName}\\nSupplier Email: ${$json.supplierEmail}\\nPO Number: ${$json.poNumber}\\nPO Date: ${$json.issueDate}\\nDelivery Required: ${$json.requiredDelivery}\\nItems: ${JSON.stringify($json.lineItems?.slice(0,5))}\\nTotal Value: $${$json.totalValue}\\nHours Since Issued: ${Math.floor((new Date()-new Date($json.issueDate))/3600000)}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_93",
          "name": "📧 Chase Supplier",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.supplierEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Draft Supplier Chase Email'].json.content[0].text).subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Draft Supplier Chase Email'].json.content[0].text).body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_94",
          "name": "🚨 Alert Purchasing Manager",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            840,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_PURCHASING_CHANNEL }}",
            "text": "=📦 *PO Chase Sent — {{ $json.poNumber }}*\\n*Supplier:* {{ $json.supplierName }}\\n*Value:* ${{ $json.totalValue }}\\n*Required Delivery:* {{ $json.requiredDelivery }}\\n*Hours Without Response:* {{ Math.floor((new Date()-new Date($json.issueDate))/3600000) }}\\n_Chase email sent ✓ — Escalate if no response by EOD_",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_90",
          "sourceOutput": 0,
          "target": "node_91",
          "targetInput": 0
        },
        {
          "source": "node_91",
          "sourceOutput": 0,
          "target": "node_92",
          "targetInput": 0
        },
        {
          "source": "node_92",
          "sourceOutput": 0,
          "target": "node_93",
          "targetInput": 0
        },
        {
          "source": "node_92",
          "sourceOutput": 0,
          "target": "node_94",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "mfg_01_purchase_order_follow_up_supplier_chase",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Manufacturing",
        "Purchasing"
      ],
      "notes": "Runs every 4 hours. Checks ERP for POs without supplier acknowledgement within 24 hours, or delivery confirmation overdue. Sends automated chase emails. Escalates to purchasing manager at 48 hours."
    },
    {
      "name": "MFG-02: Customer Order Status Communication",
      "nodes": [
        {
          "id": "node_95",
          "name": "📊 ERP Order Status Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "mfg-order-status",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_96",
          "name": "🤖 AI: Draft Customer Update",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a customer service coordinator at a manufacturing company. Draft a clear, professional order status update for the customer. For delays: be proactive, apologetic, explain the reason briefly, and give a revised timeline. For good news (confirmed, shipped): be positive and informative. Respond in JSON: {subject, body, isDelay}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Customer: ${$json.body.customerName}\\nOrder #: ${$json.body.orderNumber}\\nPrevious Status: ${$json.body.previousStatus}\\nNew Status: ${$json.body.newStatus}\\nProduct: ${$json.body.productDescription}\\nOriginal Delivery: ${$json.body.originalDelivery}\\nRevised Delivery: ${$json.body.revisedDelivery || $json.body.originalDelivery}\\nDelay Reason: ${$json.body.delayReason || 'N/A'}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_97",
          "name": "📧 Send Status Update to Customer",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            560,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.customerEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Draft Customer Update'].json.content[0].text).subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Draft Customer Update'].json.content[0].text).body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_98",
          "name": "🔔 Log in Customer Service Channel",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            560,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_CUSTOMER_SERVICE_CHANNEL }}",
            "text": "=📊 *Order Update Sent — {{ $json.body.orderNumber }}*\\n*Customer:* {{ $json.body.customerName }}\\n*Status:* {{ $json.body.previousStatus }} → {{ $json.body.newStatus }}{{ JSON.parse($node['🤖 AI: Draft Customer Update'].json.content[0].text).isDelay ? ' ⚠️ DELAY' : ' ✓' }}",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_95",
          "sourceOutput": 0,
          "target": "node_96",
          "targetInput": 0
        },
        {
          "source": "node_96",
          "sourceOutput": 0,
          "target": "node_97",
          "targetInput": 0
        },
        {
          "source": "node_96",
          "sourceOutput": 0,
          "target": "node_98",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "mfg_02_customer_order_status_communication",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Manufacturing",
        "Customer Service"
      ],
      "notes": "Monitors ERP for order status changes. Automatically sends personalised status updates to customers when orders are confirmed, enter production, ship, or are delayed. Delay notifications include revised timeline."
    },
    {
      "name": "MFG-03: Quality Non-Conformance (NCR) Intake & Routing",
      "nodes": [
        {
          "id": "node_99",
          "name": "⚠️ NCR Submitted Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "mfg-ncr-submit",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_100",
          "name": "🤖 AI: Classify NCR Severity",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a quality management specialist. Analyse this non-conformance report and: 1) Classify severity (CRITICAL/MAJOR/MINOR), 2) Identify the affected process area, 3) Suggest the most appropriate quality engineer to assign, 4) Draft a brief acknowledgement to the reporter, 5) Suggest immediate containment actions. Respond in JSON: {severity, processArea, assignTo, acknowledgementBody, containmentActions, slaHours}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Reporter: ${$json.body.reporterName}\\nDate: ${new Date().toLocaleDateString()}\\nProduct/Part: ${$json.body.partNumber}\\nDescription: ${$json.body.description}\\nLocation Found: ${$json.body.locationFound}\\nQuantity Affected: ${$json.body.quantityAffected}\\nCustomer Impact: ${$json.body.customerImpact || 'Unknown'}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_101",
          "name": "📧 Acknowledge Reporter",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            560,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.reporterEmail }}",
            "subject": "=NCR Acknowledged: {{ $json.body.partNumber }} — {{ JSON.parse($node['🤖 AI: Classify NCR Severity'].json.content[0].text).severity }} Severity",
            "message": "=Dear {{ $json.body.reporterName }},\n\nThank you for reporting this non-conformance. Your report has been received and classified as {{ JSON.parse($node['🤖 AI: Classify NCR Severity'].json.content[0].text).severity }} severity.\n\n{{ JSON.parse($node['🤖 AI: Classify NCR Severity'].json.content[0].text).acknowledgementBody }}\n\nYour NCR reference number is: {{ $json.body.ncrNumber || new Date().getTime() }}\n\nThe assigned quality engineer will contact you within {{ JSON.parse($node['🤖 AI: Classify NCR Severity'].json.content[0].text).slaHours }} hours.\n\nQuality Management Team",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_102",
          "name": "🚨 Route to Quality Engineer",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            560,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_QUALITY_CHANNEL }}",
            "text": "=⚠️ *NCR Filed — {{ JSON.parse($node['🤖 AI: Classify NCR Severity'].json.content[0].text).severity }}*\\n*Part/Product:* {{ $json.body.partNumber }}\\n*Description:* {{ $json.body.description.substring(0,200) }}\\n*Quantity Affected:* {{ $json.body.quantityAffected }}\\n*Assign To:* {{ JSON.parse($node['🤖 AI: Classify NCR Severity'].json.content[0].text).assignTo }}\\n*SLA:* {{ JSON.parse($node['🤖 AI: Classify NCR Severity'].json.content[0].text).slaHours }} hours\\n*Containment:* {{ JSON.parse($node['🤖 AI: Classify NCR Severity'].json.content[0].text).containmentActions }}",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        },
        {
          "id": "node_103",
          "name": "📋 Create NCR Record in Quality System",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            320
          ],
          "parameters": {
            "method": "POST",
            "url": "={{ $env.QUALITY_SYSTEM_URL }}/api/ncrs",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "severity",
                    "value": "={{ JSON.parse($node['🤖 AI: Classify NCR Severity'].json.content[0].text).severity }}"
                  },
                  {
                    "name": "assignedTo",
                    "value": "={{ JSON.parse($node['🤖 AI: Classify NCR Severity'].json.content[0].text).assignTo }}"
                  },
                  {
                    "name": "partNumber",
                    "value": "={{ $json.body.partNumber }}"
                  },
                  {
                    "name": "description",
                    "value": "={{ $json.body.description }}"
                  },
                  {
                    "name": "status",
                    "value": "open"
                  }
                ]
              }
            },
            "options": {}
          }
        }
      ],
      "connections": [
        {
          "source": "node_99",
          "sourceOutput": 0,
          "target": "node_100",
          "targetInput": 0
        },
        {
          "source": "node_100",
          "sourceOutput": 0,
          "target": "node_101",
          "targetInput": 0
        },
        {
          "source": "node_100",
          "sourceOutput": 0,
          "target": "node_102",
          "targetInput": 0
        },
        {
          "source": "node_100",
          "sourceOutput": 0,
          "target": "node_103",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "mfg_03_quality_non_conformance_ncr_intake_routing",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Manufacturing",
        "Quality"
      ],
      "notes": "Triggers on NCR form submission or quality system event. AI classifies severity, routes to correct quality engineer, sends acknowledgement to reporter, sets follow-up reminders."
    },
    {
      "name": "MFG-04: New Vendor / Supplier Onboarding Assistant",
      "nodes": [
        {
          "id": "node_104",
          "name": "🏭 New Vendor Approved Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "mfg-vendor-approved",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_105",
          "name": "📧 Send Onboarding Document Request",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            280,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.vendorEmail }}",
            "subject": "=New Vendor Onboarding — Documents Required: {{ $json.body.companyName }}",
            "message": "=Dear {{ $json.body.contactName }},\n\nCongratulations — {{ $json.body.companyName }} has been approved as a supplier to {{ $env.COMPANY_NAME }}.\n\nTo complete your onboarding, please provide the following documents via our supplier portal: {{ $env.SUPPLIER_PORTAL_URL }}/{{ $json.body.vendorId }}\n\nREQUIRED DOCUMENTS:\n□ W-9 Form (current year)\n□ Certificate of Liability Insurance (minimum $1M general liability)\n□ Workers' Compensation Certificate\n□ Quality Management Certificate (ISO 9001 or equivalent, if applicable)\n□ Banking / ACH Payment Details\n□ Signed Supplier Code of Conduct\n□ Lead time and minimum order confirmation\n\nPlease upload all documents within 10 business days to avoid delays to your first purchase order.\n\nIf you have any questions, contact our Procurement team at {{ $env.PROCUREMENT_EMAIL }}.\n\nWelcome aboard,\n{{ $env.COMPANY_NAME }} Procurement Team",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_106",
          "name": "🔔 Notify Procurement Team",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            280,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_PROCUREMENT_CHANNEL }}",
            "text": "=🏭 *New Vendor Onboarding Started*\\n*Company:* {{ $json.body.companyName }}\\n*Contact:* {{ $json.body.contactName }} ({{ $json.body.vendorEmail }})\\n*Category:* {{ $json.body.vendorCategory }}\\n_Document request sent. Reminder queued at 5 days if incomplete._",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        },
        {
          "id": "node_107",
          "name": "⏳ Wait 5 Days Then Check",
          "type": "n8n-nodes-base.wait",
          "typeVersion": 1.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "resume": "timeInterval",
            "time": 5,
            "unit": "days"
          }
        }
      ],
      "connections": [
        {
          "source": "node_104",
          "sourceOutput": 0,
          "target": "node_105",
          "targetInput": 0
        },
        {
          "source": "node_104",
          "sourceOutput": 0,
          "target": "node_106",
          "targetInput": 0
        },
        {
          "source": "node_105",
          "sourceOutput": 0,
          "target": "node_107",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "mfg_04_new_vendor_supplier_onboarding_assistant",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Manufacturing",
        "Procurement"
      ],
      "notes": "Triggers when a new vendor is approved. Sends document request list (W-9, insurance certificates, quality certs, banking details). Tracks submissions. Sends reminders. Alerts procurement when complete."
    },
    {
      "name": "MFG-05: Shift Handover & Production Digest",
      "nodes": [
        {
          "id": "node_108",
          "name": "⏰ Shift End Triggers (6am/2pm/10pm)",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "55 5,13,21 * * *"
                }
              ]
            }
          }
        },
        {
          "id": "node_109",
          "name": "📊 Pull Shift Metrics from ERP",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.ERP_BASE_URL }}/api/production/shift-summary?date={{ new Date().toISOString().split('T')[0] }}&shift={{ new Date().getHours() < 14 ? 'day' : new Date().getHours() < 22 ? 'afternoon' : 'night' }}",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_110",
          "name": "🤖 AI: Generate Shift Handover Report",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a production supervisor creating a shift handover report. Write a clear, structured summary that the incoming shift supervisor can read in 2 minutes. Highlight: 1) Output vs target (be specific about shortfalls), 2) Any equipment issues or downtime, 3) Quality issues or NCRs raised, 4) Open items requiring next-shift action, 5) Safety incidents or near-misses. Use bullet points. Be factual, not narrative. Respond in JSON: {shiftSummary, openItems, safetyItems, handoverNotes, outputVsTarget}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Shift: ${$json.shift}\\nDate: ${$json.date}\\nLine: ${$json.productionLine}\\nTarget Units: ${$json.targetUnits}\\nActual Units: ${$json.actualUnits}\\nDowntime Minutes: ${$json.downtimeMinutes}\\nDowntime Reasons: ${JSON.stringify($json.downtimeReasons)}\\nNCRs Raised: ${$json.ncrsRaised}\\nScrap Rate: ${$json.scrapRate}%\\nOpen Work Orders: ${JSON.stringify($json.openWorkOrders?.slice(0,5))}\\nStaffing: ${$json.staffingNotes}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_111",
          "name": "📧 Send Handover Report to Supervisors",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $env.SUPERVISOR_EMAIL_LIST }}",
            "subject": "=Shift Handover: {{ $json.shift }} shift — {{ $json.date }} | {{ JSON.parse($node['🤖 AI: Generate Shift Handover Report'].json.content[0].text).outputVsTarget }}",
            "message": "={{ (() => {\n  const ai = JSON.parse($node['🤖 AI: Generate Shift Handover Report'].json.content[0].text);\n  return `SHIFT HANDOVER REPORT\\n${$json.shift?.toUpperCase()} SHIFT — ${$json.date}\\n\n${ai.shiftSummary}\\n\\nOPEN ITEMS FOR NEXT SHIFT\\n${ai.openItems}\\n\\nSAFETY\\n${ai.safetyItems || 'No incidents this shift'}\\n\\nHANDOVER NOTES\\n${ai.handoverNotes}`;\n})() }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_108",
          "sourceOutput": 0,
          "target": "node_109",
          "targetInput": 0
        },
        {
          "source": "node_109",
          "sourceOutput": 0,
          "target": "node_110",
          "targetInput": 0
        },
        {
          "source": "node_110",
          "sourceOutput": 0,
          "target": "node_111",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "mfg_05_shift_handover_production_digest",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Manufacturing",
        "Production"
      ],
      "notes": "Triggers at end of each shift (6am, 2pm, 10pm). Pulls production metrics from ERP. AI generates formatted shift summary including output vs target, downtime, quality issues, and open items for next shift."
    },
    {
      "name": "MFG-06: Compliance Document Expiry Alert System",
      "nodes": [
        {
          "id": "node_112",
          "name": "⏰ Daily Compliance Check 6am",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 6 * * *"
                }
              ]
            }
          }
        },
        {
          "id": "node_113",
          "name": "📋 Fetch Expiring Documents",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.ERP_BASE_URL }}/api/compliance/documents?expiring_within_days=90&status=active",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_114",
          "name": "🤖 AI: Draft Renewal Request",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a compliance coordinator. Draft a professional renewal request for an expiring compliance document. Explain what is expiring, when, and exactly what is needed. Include the consequences of non-renewal (audit risk, supply chain disruption). Be clear but not alarmist. Respond in JSON: {subject, body, urgencyLevel}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Supplier/Owner: ${$json.ownerName}\\nDocument Type: ${$json.documentType}\\nDocument #: ${$json.documentNumber}\\nExpiry Date: ${$json.expiryDate}\\nDays Until Expiry: ${$json.daysUntilExpiry}\\nConsequence of Lapse: ${$json.consequence || 'Audit non-compliance'}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_115",
          "name": "📧 Send Renewal Request",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.ownerEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Draft Renewal Request'].json.content[0].text).subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Draft Renewal Request'].json.content[0].text).body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_112",
          "sourceOutput": 0,
          "target": "node_113",
          "targetInput": 0
        },
        {
          "source": "node_113",
          "sourceOutput": 0,
          "target": "node_114",
          "targetInput": 0
        },
        {
          "source": "node_114",
          "sourceOutput": 0,
          "target": "node_115",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "mfg_06_compliance_document_expiry_alert_system",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Manufacturing",
        "Compliance"
      ],
      "notes": "Runs daily. Checks all supplier and internal compliance documents for upcoming expiry at 90/30/7 days. Sends renewal requests. Escalates to compliance manager if not renewed. Prevents audit surprises."
    },
    {
      "name": "FO-01: Universal Inbox Triage & Routing",
      "nodes": [
        {
          "id": "node_116",
          "name": "📥 Gmail Shared Inbox Monitor",
          "type": "n8n-nodes-base.gmailTrigger",
          "typeVersion": 1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "pollTimes": {
              "item": [
                {
                  "mode": "everyMinute"
                }
              ]
            },
            "filters": {
              "readStatus": "unread"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_shared_cred",
              "name": "Gmail Shared Inbox"
            }
          }
        },
        {
          "id": "node_117",
          "name": "🤖 AI: Triage & Route Email",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are an expert email triage specialist. Classify and route this incoming email. Categories: LEAD_INQUIRY, CUSTOMER_SUPPORT, BILLING_QUESTION, APPOINTMENT_REQUEST, PARTNERSHIP, VENDOR, JOB_APPLICATION, SPAM, URGENT_ISSUE, GENERAL. For routine queries (business hours, address, simple FAQs), draft a complete response. Respond in JSON: {category, priority, routeTo, canAutoRespond, responseSubject, responseBody, internalNote, estimatedHandleTime}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`From: ${$json.From}\\nSubject: ${$json.Subject}\\nBody: ${$json.snippet}\\nTime: ${$json.internalDate}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_118",
          "name": "Format Routing Decision",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            560,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "j1",
                  "name": "triage",
                  "type": "string",
                  "value": "={{ JSON.parse($node['🤖 AI: Triage & Route Email'].json.content[0].text) }}"
                },
                {
                  "id": "j2",
                  "name": "shouldAutoRespond",
                  "type": "boolean",
                  "value": "={{ JSON.parse($node['🤖 AI: Triage & Route Email'].json.content[0].text).canAutoRespond === true }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_119",
          "name": "📧 Auto-Respond (Routine Queries)",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.From }}",
            "subject": "=Re: {{ $json.Subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Triage & Route Email'].json.content[0].text).responseBody }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_120",
          "name": "🔔 Route to Team Member",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            840,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_ROUTING_CHANNEL }}",
            "text": "=📧 *New Email — {{ JSON.parse($node['🤖 AI: Triage & Route Email'].json.content[0].text).category }}*\\n*Priority:* {{ JSON.parse($node['🤖 AI: Triage & Route Email'].json.content[0].text).priority }}\\n*From:* {{ $json.From }}\\n*Subject:* {{ $json.Subject }}\\n*Route To:* @{{ JSON.parse($node['🤖 AI: Triage & Route Email'].json.content[0].text).routeTo }}\\n*Handle Time:* {{ JSON.parse($node['🤖 AI: Triage & Route Email'].json.content[0].text).estimatedHandleTime }} min\\n*Note:* {{ JSON.parse($node['🤖 AI: Triage & Route Email'].json.content[0].text).internalNote }}",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_116",
          "sourceOutput": 0,
          "target": "node_117",
          "targetInput": 0
        },
        {
          "source": "node_117",
          "sourceOutput": 0,
          "target": "node_118",
          "targetInput": 0
        },
        {
          "source": "node_118",
          "sourceOutput": 0,
          "target": "node_119",
          "targetInput": 0
        },
        {
          "source": "node_118",
          "sourceOutput": 0,
          "target": "node_120",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "fo_01_universal_inbox_triage_routing",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Front Office",
        "Inbox Management"
      ],
      "notes": "Monitors shared inbox (info@, sales@, support@). AI classifies by intent, assigns priority, routes to correct person, and auto-responds to routine queries within minutes."
    },
    {
      "name": "FO-02: Lead Capture & First-Response (< 2 Minutes)",
      "nodes": [
        {
          "id": "node_121",
          "name": "📥 Lead Capture Webhook (All Sources)",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "fo-lead-capture",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_122",
          "name": "🤖 AI: Score Lead & Draft Response",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a sales development specialist. Evaluate this incoming lead and: 1) Score fit 1-10 based on available signals, 2) Identify the most likely need/pain point, 3) Draft a personalised, warm first-response email that references their specific situation and offers a clear next step. The response should feel handwritten, not templated. Respond in JSON: {leadScore, fitRating, likelyNeed, responseSubject, responseBody, followUpNote, urgency}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Name: ${$json.body.name}\\nEmail: ${$json.body.email}\\nCompany: ${$json.body.company || 'unknown'}\\nPhone: ${$json.body.phone || 'not provided'}\\nMessage: ${$json.body.message}\\nSource: ${$json.body.source}\\nPage/Ad: ${$json.body.landingPage || 'website'}\\nTime: ${new Date().toLocaleString()}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_123",
          "name": "📧 Send First Response (< 2 min)",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            560,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.email }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Score Lead & Draft Response'].json.content[0].text).responseSubject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Score Lead & Draft Response'].json.content[0].text).responseBody }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_124",
          "name": "📋 Create CRM Lead Record",
          "type": "n8n-nodes-base.hubspot",
          "typeVersion": 2,
          "position": [
            560,
            160
          ],
          "parameters": {
            "operation": "create",
            "resource": "contact",
            "additionalFields": {
              "email": "={{ $json.body.email }}",
              "firstName": "={{ $json.body.name.split(' ')[0] }}",
              "lastName": "={{ $json.body.name.split(' ').slice(1).join(' ') }}",
              "company": "={{ $json.body.company }}",
              "phone": "={{ $json.body.phone }}",
              "lead_status": "New",
              "hs_lead_status": "NEW"
            }
          },
          "credentials": {
            "hubspotAppToken": {
              "id": "hubspot_cred",
              "name": "HubSpot"
            }
          }
        },
        {
          "id": "node_125",
          "name": "🔔 Notify Sales Team",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            560,
            320
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_SALES_CHANNEL }}",
            "text": "=🆕 *New Lead — Score: {{ JSON.parse($node['🤖 AI: Score Lead & Draft Response'].json.content[0].text).leadScore }}/10*\\n*Name:* {{ $json.body.name }} | {{ $json.body.company }}\\n*Source:* {{ $json.body.source }}\\n*Need:* {{ JSON.parse($node['🤖 AI: Score Lead & Draft Response'].json.content[0].text).likelyNeed }}\\n*Note:* {{ JSON.parse($node['🤖 AI: Score Lead & Draft Response'].json.content[0].text).followUpNote }}\\n_First response sent ✓_",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_121",
          "sourceOutput": 0,
          "target": "node_122",
          "targetInput": 0
        },
        {
          "source": "node_122",
          "sourceOutput": 0,
          "target": "node_123",
          "targetInput": 0
        },
        {
          "source": "node_122",
          "sourceOutput": 0,
          "target": "node_124",
          "targetInput": 0
        },
        {
          "source": "node_122",
          "sourceOutput": 0,
          "target": "node_125",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "fo_02_lead_capture_first_response_2_minutes_",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Front Office",
        "Lead Management"
      ],
      "notes": "Captures leads from web forms, social media DMs, and ad platforms. AI scores lead fit, sends personalised acknowledgement within 2 minutes, creates CRM record, and assigns follow-up task."
    },
    {
      "name": "FO-03: Meeting Preparation Assistant",
      "nodes": [
        {
          "id": "node_126",
          "name": "⏰ Daily Brief Generation 6pm",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 18 * * 1-5"
                }
              ]
            }
          }
        },
        {
          "id": "node_127",
          "name": "📅 Fetch Tomorrow's Meetings",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "=https://www.googleapis.com/calendar/v3/calendars/primary/events?timeMin={{ new Date().toISOString() }}&timeMax={{ new Date(Date.now()+86400000).toISOString() }}&singleEvents=true",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_128",
          "name": "🤖 AI: Generate Meeting Brief",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are an executive assistant preparing a pre-meeting brief. Create a concise, actionable meeting preparation document. Include: 1) Who you're meeting with and their context, 2) Last interaction summary, 3) Open items or commitments from previous meetings, 4) Suggested talking points and questions, 5) Any relevant news or context. Keep it scannable — the reader has 3 minutes max. Respond in JSON: {attendeeName, attendeeContext, lastInteraction, openItems, suggestedTalkingPoints, backgroundNotes}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Meeting Title: ${$json.summary}\\nAttendees: ${$json.attendees?.map(a=>a.email).join(', ')}\\nTime: ${$json.start?.dateTime}\\nLocation: ${$json.location || 'Video call'}\\nDescription: ${$json.description || 'No description'}\\nOrganiser: ${$json.organizer?.email}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_129",
          "name": "📧 Deliver Meeting Brief",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $env.USER_EMAIL }}",
            "subject": "=📋 Meeting Brief: {{ $json.summary }} — {{ new Date($json.start?.dateTime).toLocaleString() }}",
            "message": "={{ (() => {\n  const ai = JSON.parse($node['🤖 AI: Generate Meeting Brief'].json.content[0].text);\n  return `MEETING BRIEF\\n${$json.summary}\\n${new Date($json.start?.dateTime).toLocaleString()}\\n\\nWHO\\n${ai.attendeeName}\\n${ai.attendeeContext}\\n\\nLAST INTERACTION\\n${ai.lastInteraction}\\n\\nOPEN ITEMS\\n${ai.openItems}\\n\\nSUGGESTED TALKING POINTS\\n${ai.suggestedTalkingPoints}\\n\\nBACKGROUND\\n${ai.backgroundNotes}`;\n})() }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_126",
          "sourceOutput": 0,
          "target": "node_127",
          "targetInput": 0
        },
        {
          "source": "node_127",
          "sourceOutput": 0,
          "target": "node_128",
          "targetInput": 0
        },
        {
          "source": "node_128",
          "sourceOutput": 0,
          "target": "node_129",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "fo_03_meeting_preparation_assistant",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Front Office",
        "Productivity"
      ],
      "notes": "Checks calendar for meetings happening in the next 24 hours. Pulls CRM history, recent email threads, and open items. AI compiles a concise meeting brief. Delivers to attendee the evening before."
    },
    {
      "name": "FO-04: Quote & Proposal Follow-Up Sequence",
      "nodes": [
        {
          "id": "node_130",
          "name": "⏰ Daily Quote Check 9am",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 9 * * 1-5"
                }
              ]
            }
          }
        },
        {
          "id": "node_131",
          "name": "💼 Fetch Open Quotes Without Response",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.CRM_BASE_URL }}/api/deals?stage=quote_sent&last_activity_before={{ new Date(Date.now()-259200000).toISOString() }}",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_132",
          "name": "🤖 AI: Draft Follow-Up Email",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a sales professional following up on a proposal. Draft a follow-up email that adds genuine value — don't just ask if they received it. At 3 days: express continued interest and offer to answer questions. At 7 days: share a relevant case study or specific benefit relevant to their situation. At 14 days: create gentle urgency, offer a call to discuss. Never be pushy. Always personalise to their industry/situation. Respond in JSON: {subject, body, suggestCall}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Prospect Name: ${$json.contactName}\\nCompany: ${$json.companyName}\\nProposal Value: $${$json.amount}\\nProposal Subject: ${$json.dealName}\\nDays Since Sent: ${Math.floor((new Date()-new Date($json.sentAt))/86400000)}\\nIndustry: ${$json.industry}\\nPain Points Discussed: ${$json.notes}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_133",
          "name": "📧 Send Follow-Up Email",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.contactEmail }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Draft Follow-Up Email'].json.content[0].text).subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Draft Follow-Up Email'].json.content[0].text).body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_134",
          "name": "🚨 Escalate to Sales Manager (14d)",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            840,
            160
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_SALES_CHANNEL }}",
            "text": "=💼 *Quote Follow-Up Alert — 14 Days*\\n*Prospect:* {{ $json.contactName }} @ {{ $json.companyName }}\\n*Deal:* {{ $json.dealName }} — ${{ $json.amount }}\\n_Final follow-up sent. Manager review recommended._",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_130",
          "sourceOutput": 0,
          "target": "node_131",
          "targetInput": 0
        },
        {
          "source": "node_131",
          "sourceOutput": 0,
          "target": "node_132",
          "targetInput": 0
        },
        {
          "source": "node_132",
          "sourceOutput": 0,
          "target": "node_133",
          "targetInput": 0
        },
        {
          "source": "node_132",
          "sourceOutput": 0,
          "target": "node_134",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "fo_04_quote_proposal_follow_up_sequence",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Front Office",
        "Sales"
      ],
      "notes": "Monitors CRM for sent quotes with no response. Triggers intelligent follow-up sequences at 3/7/14 days. Each follow-up adds value (case study, answer to likely objection). Escalates to sales manager at 14 days."
    },
    {
      "name": "FO-05: Employee Onboarding Journey (30 Days)",
      "nodes": [
        {
          "id": "node_135",
          "name": "👤 New Employee HR Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "fo-new-employee",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_136",
          "name": "🤖 AI: Generate Onboarding Plan",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are an HR onboarding specialist. Create a personalised 30-day onboarding email series for a new employee. Tailor it to their role and department. Include: Day 1 welcome and orientation overview, Day 3 systems and tools setup checklist, Day 7 first week reflection prompt, Day 14 role expectations check-in, Day 30 first month review and goals-setting. Each email should feel personal and supportive. Respond in JSON: {day1Subject, day1Body, day3Subject, day3Body, day7Subject, day7Body, day14Subject, day14Body, day30Subject, day30Body, managerTaskList, itTaskList}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Employee Name: ${$json.body.name}\\nRole: ${$json.body.role}\\nDepartment: ${$json.body.department}\\nManager: ${$json.body.managerName}\\nStart Date: ${$json.body.startDate}\\nOffice/Remote: ${$json.body.workType || 'office'}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_137",
          "name": "📧 Day 1: Welcome Email",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            560,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.email }}",
            "subject": "={{ JSON.parse($node['🤖 AI: Generate Onboarding Plan'].json.content[0].text).day1Subject }}",
            "message": "={{ JSON.parse($node['🤖 AI: Generate Onboarding Plan'].json.content[0].text).day1Body }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_138",
          "name": "📧 Manager Task Notification",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            560,
            160
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.body.managerEmail }}",
            "subject": "=New Team Member Starting: {{ $json.body.name }} — Your Onboarding Checklist",
            "message": "=Hi {{ $json.body.managerName }},\n\n{{ $json.body.name }} starts on {{ $json.body.startDate }} as {{ $json.body.role }}.\n\nYour onboarding checklist:\n\n{{ JSON.parse($node['🤖 AI: Generate Onboarding Plan'].json.content[0].text).managerTaskList }}\n\nThe automated onboarding email sequence is running. You'll receive reminders at Day 7, 14, and 30 to check in personally.",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        },
        {
          "id": "node_139",
          "name": "🔔 IT Setup Notification",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            560,
            320
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_IT_CHANNEL }}",
            "text": "=🖥️ *New Employee Starting — IT Setup Required*\\n*Name:* {{ $json.body.name }}\\n*Role:* {{ $json.body.role }}\\n*Start:* {{ $json.body.startDate }}\\n\\n*IT Checklist:*\\n{{ JSON.parse($node['🤖 AI: Generate Onboarding Plan'].json.content[0].text).itTaskList }}",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_135",
          "sourceOutput": 0,
          "target": "node_136",
          "targetInput": 0
        },
        {
          "source": "node_136",
          "sourceOutput": 0,
          "target": "node_137",
          "targetInput": 0
        },
        {
          "source": "node_136",
          "sourceOutput": 0,
          "target": "node_138",
          "targetInput": 0
        },
        {
          "source": "node_136",
          "sourceOutput": 0,
          "target": "node_139",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "fo_05_employee_onboarding_journey_30_days_",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Front Office",
        "HR"
      ],
      "notes": "Triggers when a new employee is added to HR system. Delivers a personalised 30-day guided onboarding sequence. Assigns tasks to manager and IT. Sends check-in prompts at day 7, 14, and 30."
    },
    {
      "name": "FO-06: Internal AI Knowledge Base Assistant",
      "nodes": [
        {
          "id": "node_140",
          "name": "💬 Slack Bot Mention Trigger",
          "type": "n8n-nodes-base.slackTrigger",
          "typeVersion": 1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "trigger": "app_mention",
            "returnOnlyFirst": false
          },
          "credentials": {
            "slackApi": {
              "id": "slack_bot_cred",
              "name": "Slack Bot"
            }
          }
        },
        {
          "id": "node_141",
          "name": "📚 Fetch Relevant KB Documents",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.KB_SEARCH_URL }}?query={{ encodeURIComponent($json.event.text) }}&top=5",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_142",
          "name": "🤖 AI: Answer from Knowledge Base",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are an internal company assistant. Answer this employee question using ONLY the provided company documents. Be helpful and specific. If the answer is not in the documents, say clearly that you don't have that information and suggest who to ask. Never make up policy information. Respond in JSON: {answer, confidence, sourceDocuments, needsEscalation, escalateTo}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Employee Question: ${$node['💬 Slack Bot Mention Trigger'].json.event.text}\\nEmployee: ${$node['💬 Slack Bot Mention Trigger'].json.event.user}\\nCompany Knowledge Base:\\n${$json.documents?.map(d=>d.content).join('\\n---\\n')}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_143",
          "name": "💬 Reply in Slack Thread",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $json.event.channel }}",
            "text": "={{ JSON.parse($node['🤖 AI: Answer from Knowledge Base'].json.content[0].text).answer }}{{ JSON.parse($node['🤖 AI: Answer from Knowledge Base'].json.content[0].text).needsEscalation ? '\\n\\n_I don\\'t have a confident answer for this — I\\'ve flagged it for ' + JSON.parse($node['🤖 AI: Answer from Knowledge Base'].json.content[0].text).escalateTo + ' to follow up._' : '' }}",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_140",
          "sourceOutput": 0,
          "target": "node_141",
          "targetInput": 0
        },
        {
          "source": "node_141",
          "sourceOutput": 0,
          "target": "node_142",
          "targetInput": 0
        },
        {
          "source": "node_142",
          "sourceOutput": 0,
          "target": "node_143",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "fo_06_internal_ai_knowledge_base_assistant",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Front Office",
        "Knowledge Management"
      ],
      "notes": "Monitors Slack for questions directed at the knowledge base bot. AI answers from the company's own policy documents and FAQs. Escalates unanswered questions to HR/manager. Logs all queries for KB improvement."
    },
    {
      "name": "FO-07: Weekly Business Performance Digest",
      "nodes": [
        {
          "id": "node_144",
          "name": "⏰ Monday 7am Digest",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 7 * * 1"
                }
              ]
            }
          }
        },
        {
          "id": "node_145",
          "name": "💰 Fetch Financial Metrics (QuickBooks)",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.QB_BASE_URL }}/v3/company/{{ $env.QB_REALM_ID }}/reports/ProfitAndLoss?start_date={{ new Date(Date.now()-604800000).toISOString().split('T')[0] }}&end_date={{ new Date().toISOString().split('T')[0] }}",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_146",
          "name": "📈 Fetch CRM Pipeline Data",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            160
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.CRM_BASE_URL }}/api/deals?status=open&updated_after={{ new Date(Date.now()-604800000).toISOString() }}",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_147",
          "name": "🤖 AI: Generate Weekly Digest",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a business intelligence analyst. Create a concise, insightful weekly business digest for the owner/leadership team. Include: revenue vs prior week, key pipeline movements, cash position/AR summary, wins and concerns, and 1-2 recommendations. Use numbers. Be specific. Flag anything that needs attention. Keep it to one readable page. Respond in JSON: {weekSummary, revenueHighlight, pipelineHighlight, arHighlight, wins, concerns, recommendations, weekRating}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Financial Data: ${JSON.stringify($node['💰 Fetch Financial Metrics (QuickBooks)'].json).substring(0,2000)}\\nCRM Pipeline: ${JSON.stringify($node['📈 Fetch CRM Pipeline Data'].json).substring(0,2000)}\\nWeek of: ${new Date().toLocaleDateString()}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_148",
          "name": "📧 Deliver Weekly Digest",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $env.OWNER_EMAIL }}",
            "subject": "=📊 Weekly Business Digest — Week of {{ new Date().toLocaleDateString() }} | {{ JSON.parse($node['🤖 AI: Generate Weekly Digest'].json.content[0].text).weekRating }}",
            "message": "={{ (() => {\n  const ai = JSON.parse($node['🤖 AI: Generate Weekly Digest'].json.content[0].text);\n  return `WEEKLY BUSINESS DIGEST\\nWeek of ${new Date().toLocaleDateString()}\\n\\nSUMMARY\\n${ai.weekSummary}\\n\\nREVENUE\\n${ai.revenueHighlight}\\n\\nPIPELINE\\n${ai.pipelineHighlight}\\n\\nCASH & AR\\n${ai.arHighlight}\\n\\nWINS THIS WEEK\\n${ai.wins}\\n\\nCONCERNS\\n${ai.concerns}\\n\\nRECOMMENDATIONS\\n${ai.recommendations}`;\n})() }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_144",
          "sourceOutput": 0,
          "target": "node_145",
          "targetInput": 0
        },
        {
          "source": "node_144",
          "sourceOutput": 0,
          "target": "node_146",
          "targetInput": 0
        },
        {
          "source": "node_145",
          "sourceOutput": 0,
          "target": "node_147",
          "targetInput": 0
        },
        {
          "source": "node_146",
          "sourceOutput": 0,
          "target": "node_147",
          "targetInput": 0
        },
        {
          "source": "node_147",
          "sourceOutput": 0,
          "target": "node_148",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "fo_07_weekly_business_performance_digest",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Front Office",
        "Reporting"
      ],
      "notes": "Runs every Monday at 7am. Pulls key metrics from CRM, accounting, and project tools. AI generates a formatted weekly digest with revenue, pipeline, AR, completed projects, and flagged exceptions."
    },
    {
      "name": "UNI-01: Google Review & Reputation Responder",
      "nodes": [
        {
          "id": "node_149",
          "name": "⏰ Check Reviews Every 2 Hours",
          "type": "n8n-nodes-base.scheduleTrigger",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "cronExpression",
                  "expression": "0 */2 * * *"
                }
              ]
            }
          }
        },
        {
          "id": "node_150",
          "name": "⭐ Fetch New Google Reviews",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "=https://mybusiness.googleapis.com/v4/accounts/{{ $env.GOOGLE_ACCOUNT_ID }}/locations/{{ $env.GOOGLE_LOCATION_ID }}/reviews",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_151",
          "name": "🤖 AI: Draft Review Response",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are managing online reputation for a business. Draft a professional, genuine response to this review. For positive reviews: thank them specifically, reference something unique they mentioned. For negative reviews: acknowledge their experience, apologise sincerely, offer to make it right offline (provide contact). Never be defensive. Never offer discounts publicly. Keep responses under 150 words. Respond in JSON: {responseText, sentiment, starRating, requiresFollowUp, internalAction}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Reviewer: ${$json.reviewer?.displayName}\\nRating: ${$json.starRating}/5\\nReview: ${$json.comment}\\nDate: ${$json.createTime}\\nBusiness Name: ${$env.BUSINESS_NAME}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_152",
          "name": "🔔 Send Draft for Approval",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_MANAGEMENT_CHANNEL }}",
            "text": "=⭐ *New Review — {{ JSON.parse($node['🤖 AI: Draft Review Response'].json.content[0].text).starRating }}/5*\\n*From:* {{ $json.reviewer?.displayName }}\\n*Review:* {{ $json.comment?.substring(0,300) }}\\n\\n*Draft Response:*\\n{{ JSON.parse($node['🤖 AI: Draft Review Response'].json.content[0].text).responseText }}\\n\\n{{ JSON.parse($node['🤖 AI: Draft Review Response'].json.content[0].text).requiresFollowUp ? '⚠️ *Follow-up needed: ' + JSON.parse($node['🤖 AI: Draft Review Response'].json.content[0].text).internalAction + '*' : '' }}",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_149",
          "sourceOutput": 0,
          "target": "node_150",
          "targetInput": 0
        },
        {
          "source": "node_150",
          "sourceOutput": 0,
          "target": "node_151",
          "targetInput": 0
        },
        {
          "source": "node_151",
          "sourceOutput": 0,
          "target": "node_152",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "uni_01_google_review_reputation_responder",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Universal",
        "Reputation Management"
      ],
      "notes": "Monitors Google Business Profile for new reviews. AI drafts professional responses in the client's brand voice. Queues for approval in Slack. Monthly sentiment summary delivered to management."
    },
    {
      "name": "UNI-02: Social Media Content Pipeline",
      "nodes": [
        {
          "id": "node_153",
          "name": "📝 Content Brief Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "social-content-brief",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_154",
          "name": "🤖 AI: Generate Weekly Content",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a social media content creator. From this weekly content brief, create a full week of social posts for LinkedIn, Facebook, and Instagram. Each platform should have its own optimised version: LinkedIn = professional and insightful (3-4 sentences + hashtags), Facebook = conversational and community-focused (2-3 sentences + CTA), Instagram = visual description + punchy caption + hashtags. Create Monday, Wednesday, and Friday posts. Respond in JSON: {monday:{linkedin,facebook,instagram}, wednesday:{linkedin,facebook,instagram}, friday:{linkedin,facebook,instagram}}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Business: ${$json.body.businessName}\\nIndustry: ${$json.body.industry}\\nWeekly Brief: ${$json.body.brief}\\nKey Messages: ${$json.body.keyMessages}\\nTone: ${$json.body.tone || 'professional and approachable'}\\nAny promotions this week: ${$json.body.promotions || 'none'}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_155",
          "name": "Format Posts for Scheduler",
          "type": "n8n-nodes-base.set",
          "typeVersion": 3.4,
          "position": [
            560,
            0
          ],
          "parameters": {
            "mode": "manual",
            "duplicateItem": false,
            "assignments": {
              "assignments": [
                {
                  "id": "k1",
                  "name": "contentPlan",
                  "type": "string",
                  "value": "={{ JSON.parse($node['🤖 AI: Generate Weekly Content'].json.content[0].text) }}"
                }
              ]
            }
          }
        },
        {
          "id": "node_156",
          "name": "🔔 Send Content Plan for Approval",
          "type": "n8n-nodes-base.slack",
          "typeVersion": 2.1,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "post",
            "channel": "={{ $env.SLACK_MARKETING_CHANNEL }}",
            "text": "=📱 *Weekly Social Content Plan Ready for Review*\\n\\n*MONDAY*\\n_LinkedIn:_ {{ JSON.parse($node['🤖 AI: Generate Weekly Content'].json.content[0].text).monday.linkedin.substring(0,200) }}...\\n\\n*WEDNESDAY*\\n_LinkedIn:_ {{ JSON.parse($node['🤖 AI: Generate Weekly Content'].json.content[0].text).wednesday.linkedin.substring(0,200) }}...\\n\\n*FRIDAY*\\n_LinkedIn:_ {{ JSON.parse($node['🤖 AI: Generate Weekly Content'].json.content[0].text).friday.linkedin.substring(0,200) }}...\\n\\n_Reply ✅ to approve all or ✏️ to request edits_",
            "otherOptions": {}
          },
          "credentials": {
            "slackApi": {
              "id": "slack_cred",
              "name": "Slack Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_153",
          "sourceOutput": 0,
          "target": "node_154",
          "targetInput": 0
        },
        {
          "source": "node_154",
          "sourceOutput": 0,
          "target": "node_155",
          "targetInput": 0
        },
        {
          "source": "node_155",
          "sourceOutput": 0,
          "target": "node_156",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "uni_02_social_media_content_pipeline",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Universal",
        "Marketing"
      ],
      "notes": "Triggered by weekly content brief or scheduled Monday. AI generates a week of social posts across LinkedIn, Facebook, and Instagram from a single brief. Queues for approval and schedules."
    },
    {
      "name": "UNI-03: AI Sales Proposal Generator",
      "nodes": [
        {
          "id": "node_157",
          "name": "💼 CRM Deal Stage Webhook",
          "type": "n8n-nodes-base.webhook",
          "typeVersion": 1.1,
          "position": [
            0,
            0
          ],
          "parameters": {
            "path": "crm-deal-proposal-stage",
            "httpMethod": "POST",
            "responseMode": "onReceived",
            "options": {}
          }
        },
        {
          "id": "node_158",
          "name": "📋 Fetch Deal & Contact Details",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            280,
            0
          ],
          "parameters": {
            "method": "GET",
            "url": "={{ $env.CRM_BASE_URL }}/api/deals/{{ $json.body.dealId }}?include=contact,company,notes,activities",
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": []
              }
            },
            "options": {}
          }
        },
        {
          "id": "node_159",
          "name": "🤖 AI: Generate Proposal Draft",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 4.1,
          "position": [
            560,
            0
          ],
          "parameters": {
            "method": "POST",
            "url": "https://api.anthropic.com/v1/messages",
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-api-key",
                  "value": "={{ $env.ANTHROPIC_API_KEY }}"
                },
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/json"
                }
              ]
            },
            "sendBody": true,
            "contentType": "json",
            "body": {
              "bodyParameters": {
                "parameters": [
                  {
                    "name": "model",
                    "value": "claude-sonnet-4-20250514"
                  },
                  {
                    "name": "max_tokens",
                    "value": "1000"
                  },
                  {
                    "name": "system",
                    "value": "You are a senior sales professional. Create a compelling, personalised proposal draft for this prospect. Structure: 1) Executive summary (their problem statement), 2) Our understanding of their situation (using their own words from notes), 3) Proposed solution (specific to their needs), 4) Why us (2-3 specific differentiators), 5) Investment overview (placeholder), 6) Next steps. Be specific, not generic. Reference their industry. Respond in JSON: {title, executiveSummary, situationAnalysis, proposedSolution, whyUs, investmentOverview, nextSteps}"
                  },
                  {
                    "name": "messages",
                    "value": "=[{\"role\":\"user\",\"content\":`Company: ${$json.company?.name}\\nContact: ${$json.contact?.firstname} ${$json.contact?.lastname}\\nIndustry: ${$json.company?.industry}\\nDeal Name: ${$json.dealname}\\nDeal Value: $${$json.amount}\\nNotes: ${$json.notes?.map(n=>n.body).join('\\n')}\\nPain Points: ${$json.properties?.pain_points}\\nCompetitors Mentioned: ${$json.properties?.competitors}`}]"
                  }
                ]
              }
            }
          }
        },
        {
          "id": "node_160",
          "name": "📧 Deliver Proposal Draft to Salesperson",
          "type": "n8n-nodes-base.gmail",
          "typeVersion": 2,
          "position": [
            840,
            0
          ],
          "parameters": {
            "operation": "send",
            "sendTo": "={{ $json.contact?.email_of_owner || $env.SALES_EMAIL }}",
            "subject": "=Proposal Draft Ready: {{ $json.company?.name }} — {{ $json.dealname }}",
            "message": "={{ (() => {\n  const ai = JSON.parse($node['🤖 AI: Generate Proposal Draft'].json.content[0].text);\n  return `PROPOSAL DRAFT — FOR YOUR REVIEW AND PERSONALISATION\\n${ai.title}\\n\\nEXECUTIVE SUMMARY\\n${ai.executiveSummary}\\n\\nTHEIR SITUATION\\n${ai.situationAnalysis}\\n\\nPROPOSED SOLUTION\\n${ai.proposedSolution}\\n\\nWHY SECURAFY\\n${ai.whyUs}\\n\\nINVESTMENT\\n${ai.investmentOverview}\\n\\nNEXT STEPS\\n${ai.nextSteps}\\n\\n---\\n[Please review, personalise, and format before sending to prospect]`;\n})() }}",
            "options": {
              "replyTo": "={{ $env.REPLY_TO_EMAIL }}"
            }
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "gmail_cred",
              "name": "Gmail Account"
            }
          }
        }
      ],
      "connections": [
        {
          "source": "node_157",
          "sourceOutput": 0,
          "target": "node_158",
          "targetInput": 0
        },
        {
          "source": "node_158",
          "sourceOutput": 0,
          "target": "node_159",
          "targetInput": 0
        },
        {
          "source": "node_159",
          "sourceOutput": 0,
          "target": "node_160",
          "targetInput": 0
        }
      ],
      "active": false,
      "settings": {
        "executionOrder": "v1"
      },
      "meta": {
        "templateId": "uni_03_ai_sales_proposal_generator",
        "instanceId": "securafy_ai_services"
      },
      "tags": [
        "Securafy",
        "AI Services",
        "Universal",
        "Sales"
      ],
      "notes": "Triggered when a deal moves to proposal stage in CRM. AI generates a customised proposal draft using the prospect's details, pain points from notes, and relevant case studies. Delivered to salesperson for final polish."
    }
  ],
  "exportedAt": "2026-05-01T19:27:41.071Z",
  "version": "1.0.0",
  "author": "Securafy AI Services"
}