{
  "name": "AI Sales Agent Workflow",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "intent",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -544,
        176
      ],
      "id": "1eefb3e5-b383-44fc-8bb3-1a61a679d75e",
      "name": "Intent Webhook"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -240,
        288
      ],
      "id": "b3c3b4ac-3b1a-4d65-9f31-aeb13dd610a8",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.parse(($json.text || \"{}\").replace(/```json/g, \"\").replace(/```/g, \"\").trim()) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        32,
        176
      ],
      "id": "aa59eac3-470d-4254-ba24-d7b0a83ff532",
      "name": "Respond to Intent Webhook"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are a strict intent classifier. Your ONLY job is to categorize the user's message as \"SALES\" or \"SUPPORT\".\n\n### RULES ###\n1. \"SALES\" is ONLY for: buying, pricing, packages, \"book a demo\", upgrading, paying, or booking.\n2. \"SUPPORT\" is for: errors, bugs, \"how to\", login issues, resetting passwords, technical help, or broken features.\n3. If you are unsure, default to \"SUPPORT\".\n\n### EXAMPLES ###\nUser: \"How much is the pro plan?\"\nResult: SALES\n\nUser: \"I cannot log in to my account.\"\nResult: SUPPORT\n\nUser: \"Where is the settings menu?\"\nResult: SUPPORT\n\nUser: \"I want to talk to sales.\"\nResult: SALES\n\nUser: \"What packages do you offer?\"\nResult: SALES\n\nUser: \"I'm getting an error message.\"\nResult: SUPPORT\n\n### OUTPUT REQUIREMENT ###\nReturn ONLY raw JSON with no markdown formatting.\n{\n  \"reply\": \"A short, helpful answer to the user.\",\n  \"intent\": \"SALES\",\n  \"confidence\": 0.98\n}\n\nUser Input: \n{{ $json.body.message }}",
        "messages": {
          "messageValues": []
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        -320,
        64
      ],
      "id": "fd6135b3-2b11-46cf-ae6c-b813fd6cad92",
      "name": "Intent Classification LLM"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "send-appointment",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -544,
        496
      ],
      "id": "86b14875-27d1-4164-9d57-6ecc6d3292f7",
      "name": "Booking Webhook"
    },
    {
      "parameters": {
        "sendTo": "abdullahfaisalbinmadhi@gmail.com",
        "subject": "Appointment Confirmed",
        "message": "=Hello,\n\nYour appointment has been confirmed!\n\n\ud83d\udcc5 Date & Time: {{ $json.body.formattedDateTime || 'To be scheduled' }}\n\ud83d\udc64 Customer: {{ $json.body.leadName || 'Customer' }}\n\nHere is your meeting link: https://meet.example.com/sales-demo-{{ $json.body.leadId || 'meeting' }}\n\nWe look forward to speaking with you!\n\nBest regards,\nSales Team",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        -96,
        496
      ],
      "id": "2d78235e-b947-4e9d-a03d-2af6ca5860fc",
      "name": "Send Confirmation Email",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "{\n  \"status\": \"success\",\n  \"message\": \"Appointment confirmed. Confirmation email has been sent.\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        -320,
        496
      ],
      "id": "944d8f7c-013f-4df3-89e6-815fba6828db",
      "name": "Respond to Booking Webhook"
    },
    {
      "parameters": {
        "content": "## AI Sales Agent Workflow\n\n### Section 3: Intent Classification API\n\n**Webhook:** POST /webhook/intent\n\n**Payload:** { \"message\": \"user input\" }\n\n**Response:**\n{\n  \"reply\": \"AI response text\",\n  \"intent\": \"SALES\" or \"SUPPORT\",\n  \"confidence\": 0.98\n}\n\n**Rules:**\n- SALES: pricing, packages, buying, booking\n- SUPPORT: errors, login issues, technical help",
        "height": 340,
        "width": 320,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -120
      ],
      "typeVersion": 1,
      "id": "note-intent",
      "name": "Intent API Note"
    },
    {
      "parameters": {
        "content": "## Section 5: Email Booking Flow\n\n**Webhook:** POST /webhook/send-appointment\n\n**Payload (from frontend):**\n{\n  \"appointmentDateTime\": \"ISO string\",\n  \"formattedDateTime\": \"Dec 15, 2025 at 2:30 PM\",\n  \"leadName\": \"Customer A\",\n  \"leadId\": \"1\"\n}\n\n**Email Content:**\n- Subject: Appointment Confirmed\n- Body: Meeting link + appointment details\n\n**Response:** { \"status\": \"success\" }",
        "height": 380,
        "width": 320,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        680
      ],
      "typeVersion": 1,
      "id": "note-booking",
      "name": "Booking Flow Note"
    }
  ],
  "connections": {
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Intent Classification LLM",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Intent Webhook": {
      "main": [
        [
          {
            "node": "Intent Classification LLM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Intent Classification LLM": {
      "main": [
        [
          {
            "node": "Respond to Intent Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Booking Webhook": {
      "main": [
        [
          {
            "node": "Respond to Booking Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Respond to Booking Webhook": {
      "main": [
        [
          {
            "node": "Send Confirmation Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ai-sales-agent-v1",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "hcasM7USuPMYGCaU",
  "tags": []
}