{
  "name": "Insurance Support WhatsApp Agent",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.chatInput }}",
        "options": {
          "systemMessage": "=You are an AI Customer Support Assistant for an insurance company.\n\nGreeting\n\nOn the first message only, greet the user:\nHello 👋, welcome to our Customer Support Assistant! I’m here 24/7 to help you with policy inquiries, claims status, or any frequently asked questions you may have.\n\nTools You Have Access To\n\nCustomer Policies\n\nUse this tool when the user asks about their policy details, policy status, premium, due dates, renewal, or coverage.\n\nSpecial case:\n\nIf the user asks “What is my policy number?” → ask for Email and Date of Birth (DOB) in yyyy-mm-dd format, then fetch the PolicyNumber.\n\nExample formula:\n\nAND({Email}='user@email.com',{DateofBirth}='1990-05-20')\n\n\nFor all other policy-related queries → ask for PolicyNumber + DOB (yyyy-mm-dd).\n\nExample formula:\n\nAND({PolicyNumber}='POL67890',{DateofBirth}='2002-05-16')\n\n\nClaims\n\nUse this tool when the user asks about a claim status, claim amount, claim ResponseTime or claim remarks.\n\nAlways first ask for PolicyNumber and ClaimID.\n\nExample formula:\n\nAND({ClaimID}='CLM003',{PolicyNumber}='POL11111')\n\n\nFAQ\n\nUse this tool for general questions (e.g., grace period, required documents, coverage process).\n\nThe field KnowledgeBase contains entries in the format:\nQ: … A: …\n\nIf user’s query matches, return the answer directly in plain text.\n\nFormula Generate\n\nAlways generate valid Airtable filterByFormula expressions.\n\nDates must always be formatted as yyyy-mm-dd.\n\nRules for Responses\n\nFirst, analyze the user’s intent and decide whether to use Customer Policies, Claims, or FAQ.\n\nIf customer-specific info is needed → ask for required details:\n\nEmail + DOB if user asks for their policy number.\n\nPolicyNumber + DOB for other policy questions.\n\nPolicyNumber + ClaimID for claim-related questions.\n\nAlways return answers in simple, conversational paragraphs (not bullet points).\n\nResponses must be clear, concise, and friendly.\n\nIf no relevant answer is found, generate a helpful related question and one-line answer. Example:\n“I couldn’t find details for that. Would you like me to check if your policy is currently active or lapsed?”"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        424,
        -32
      ],
      "id": "34e29b67-ba0a-450f-8d8d-aa5200b335e1",
      "name": "AI Agent"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        352,
        192
      ],
      "id": "c2021ae0-17c1-4dc3-8309-e39e2d20d782",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "operation": "search",
        "base": {
          "__rl": true,
          "value": "appz7D9gZgKKZl66g",
          "mode": "list",
          "cachedResultName": "Customer Support(Insurance)"
        },
        "table": {
          "__rl": true,
          "value": "tblCH4OzpQ12EHxoQ",
          "mode": "list",
          "cachedResultName": "Customer Policies"
        },
        "filterByFormula": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Filter_By_Formula', `only find a provided a PolicyNumber and Date of Birth related details not another id details.\n`, 'string') }}",
        "returnAll": false,
        "limit": 50,
        "options": {}
      },
      "type": "n8n-nodes-base.airtableTool",
      "typeVersion": 2.1,
      "position": [
        496,
        192
      ],
      "id": "9095c42e-2b3d-4748-a6f5-d8c67bd02c1a",
      "name": "Customer Policies",
      "credentials": {
        "airtableTokenApi": {
          "id": "0lstEdikXtvhmDPJ",
          "name": "Airtable account"
        }
      }
    },
    {
      "parameters": {
        "operation": "search",
        "base": {
          "__rl": true,
          "value": "appz7D9gZgKKZl66g",
          "mode": "list",
          "cachedResultName": "Customer Support(Insurance)"
        },
        "table": {
          "__rl": true,
          "value": "tblGCGx9b7WU6Cf1A",
          "mode": "list",
          "cachedResultName": "Claims"
        },
        "filterByFormula": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Filter_By_Formula', `only find a provided a ClaimID related details not another id details.`, 'string') }}",
        "returnAll": false,
        "options": {}
      },
      "type": "n8n-nodes-base.airtableTool",
      "typeVersion": 2.1,
      "position": [
        624,
        192
      ],
      "id": "e41797ef-0f61-44da-aa0f-c9ba1fd8a18a",
      "name": "Claims",
      "credentials": {
        "airtableTokenApi": {
          "id": "0lstEdikXtvhmDPJ",
          "name": "Airtable account"
        }
      }
    },
    {
      "parameters": {
        "operation": "search",
        "base": {
          "__rl": true,
          "value": "appz7D9gZgKKZl66g",
          "mode": "list",
          "cachedResultName": "Customer Support(Insurance)"
        },
        "table": {
          "__rl": true,
          "value": "tbltGKrlgHymCojrI",
          "mode": "list",
          "cachedResultName": "FAQ"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.airtableTool",
      "typeVersion": 2.1,
      "position": [
        752,
        192
      ],
      "id": "ba99462b-7727-4a21-9f72-96271c431509",
      "name": "FAQ",
      "credentials": {
        "airtableTokenApi": {
          "id": "0lstEdikXtvhmDPJ",
          "name": "Airtable account"
        }
      }
    },
    {
      "parameters": {
        "content": "## Data Setup\nCreate an Airtable base with these tables/fields, then select it in the Airtable nodes:\n- **Customer Support(Insurance) → Customer Policies**: _(columns as used in the nodes)_\n- **Customer Support(Insurance) → Claims**: _(columns as used in the nodes)_\n- **Customer Support(Insurance) → FAQ**: _(columns as used in the nodes)_",
        "height": 80,
        "width": 448
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        128
      ],
      "typeVersion": 1,
      "id": "1a23294c-9dd1-485d-a380-7a14be442ed2",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "updates": [
          "com.twilio.messaging.inbound-message.received"
        ]
      },
      "type": "n8n-nodes-base.twilioTrigger",
      "typeVersion": 1,
      "position": [
        208,
        -32
      ],
      "id": "977427b6-47e7-49ae-805e-5048d27be1b1",
      "name": "Twilio Trigger",
      "webhookId": "2ad614f0-db8b-4ded-b6a2-1a0f908f2d65",
      "credentials": {
        "twilioApi": {
          "id": "xmQ7NblKKLEiOZwC",
          "name": "Twilio account"
        }
      }
    },
    {
      "parameters": {
        "from": "={{ $('Twilio Trigger').item.json.To }}",
        "to": "={{ $('Twilio Trigger').item.json.From }}",
        "message": "={{ $json.output }}",
        "options": {}
      },
      "type": "n8n-nodes-base.twilio",
      "typeVersion": 1,
      "position": [
        768,
        -32
      ],
      "id": "c71aa37d-f3cb-48cb-958e-e06b53804a7c",
      "name": "Send an SMS/MMS/WhatsApp message",
      "credentials": {
        "twilioApi": {
          "id": "xmQ7NblKKLEiOZwC",
          "name": "Twilio account"
        }
      }
    },
    {
      "parameters": {
        "model": "openai/gpt-oss-120b",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        208,
        192
      ],
      "id": "c750747c-8004-4414-a1d0-35546ee057a6",
      "name": "OpenRouter Chat Model",
      "credentials": {
        "openRouterApi": {
          "id": "XDH1ME5qL4duPuQc",
          "name": "OpenRouter account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Customer Policies": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Claims": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "FAQ": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send an SMS/MMS/WhatsApp message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Twilio Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1be2c07c-141e-4537-ad1e-9d36ef07a038",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "f1c26778ec36097a9722a22c47c5e9c01f00b8862dadd0121ec118026a370fa6"
  },
  "id": "BRcAQDYWdvNXT7qQ",
  "tags": []
}