{
  "name": "LeadBot autopilot — chat-to-lead for Salesforce",
  "nodes": [
    {
      "id": "0e189df7-1be1-4ec7-aca1-0810787c426d",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -940,
        -140
      ]
    },
    {
      "id": "ca3d5237-58be-48ad-8f22-2c02ce62b882",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -240,
        -120
      ]
    },
    {
      "id": "7c22366f-4295-4aee-a91e-89dd17a604a6",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1200,
        220
      ]
    },
    {
      "id": "02f3e832-199a-496e-8379-7ab7689c5855",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -880,
        220
      ]
    },
    {
      "id": "72ca5cb3-f1e1-4edd-b9fa-7ebfcba0b4ec",
      "name": "check_duplicate_lead",
      "type": "n8n-nodes-base.salesforceTool",
      "position": [
        -340,
        220
      ]
    },
    {
      "id": "1ea47fba-b284-4bc9-bc02-6d77d2ffd893",
      "name": "Think",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        -600,
        220
      ]
    },
    {
      "id": "9d139e15-a0c6-4be7-a14f-b4249eb1bbaf",
      "name": "update_lead",
      "type": "n8n-nodes-base.salesforceTool",
      "position": [
        -80,
        240
      ]
    },
    {
      "id": "d378581f-7736-4f2d-beb7-1b5e7cd5d483",
      "name": "create_lead",
      "type": "n8n-nodes-base.salesforceTool",
      "position": [
        180,
        240
      ]
    },
    {
      "id": "12f7e77e-f03f-4163-96be-fa1fd3fcf538",
      "name": "send_notification_client",
      "type": "n8n-nodes-base.emailSendTool",
      "position": [
        720,
        220
      ]
    },
    {
      "id": "be44e29f-7a46-4eae-8d8c-33d8ec58f998",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2000,
        120
      ],
      "parameters": {
        "width": 600,
        "height": 520,
        "content": "## Workflow Overview\nThis workflow creates a Chat-to-Lead chatbot using AI to collect user data conversationally. It integrates with Salesforce for duplicate checks and lead CRUD, notifies teams via S"
      }
    },
    {
      "id": "a0bc70e3-d94f-4a7e-8c69-3922a478be2b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        340
      ],
      "parameters": {
        "width": 260,
        "height": 320,
        "content": "## Memory Management\nSalesforce tool to query leads by email (using \"getAll\" with Email condition). Returns if a duplicate exists, with lead_id and details. Invoked after email collection.\nCredentials"
      }
    },
    {
      "id": "f22cc811-5994-471b-8a2e-6af73c2a2f95",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        340
      ],
      "parameters": {
        "width": 260,
        "height": 320,
        "content": "## Internal Reasoning\nLangChain Think tool for AI to reason step-by-step internally (e.g., splitting names or handling ambiguities).\n\nNo params; returns thoughts for the agent.\nUsed for complex decisi"
      }
    },
    {
      "id": "468f2843-0870-4b40-a607-09041e537db7",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1300,
        340
      ],
      "parameters": {
        "width": 300,
        "height": 220,
        "content": "## Language Model\nProvides the LLM backend (GPT-4.1) for the AI Agent. Handles natural language processing, reasoning, and tool decisions.\nCredentials: OpenAI API key.\nOptions are minimal here; advanc"
      }
    },
    {
      "id": "753b25f0-e81f-42fb-89de-3108b43b9b02",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1420,
        -220
      ],
      "parameters": {
        "width": 440,
        "height": 260,
        "content": "## Chat Trigger Step\nThis node starts the workflow on incoming chat messages (e.g., via webhook). It sets an initial greeting:\n\n\"Hi! I'm LeadBot. I'll help you submit your interest. Let's start with y"
      }
    },
    {
      "id": "5741242e-6315-4dc7-a965-c57893f9b379",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        380
      ],
      "parameters": {
        "width": null,
        "height": 280,
        "content": "## Internal Notification\nSends Slack message to a specific user/channel (here, user U08QYRBEE3V). Text dynamically from AI (e.g., \"New/updated interest: [Name] - [Email] - [Interest]\").\n\nActs as send_"
      }
    },
    {
      "id": "dbe62204-1d71-4f27-8b4d-c548b3ac47ff",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        380
      ],
      "parameters": {
        "width": null,
        "height": 280,
        "content": "## Client Notification \nEmails the user a personalized message based on interest.\nParams: fromEmail (fixed), toEmail, subject, HTML body – all dynamic from AI.\nUses SMTP credentials. Invoked after lea"
      }
    },
    {
      "id": "236a61ef-0c2b-42fb-967f-ee1f6df2ca20",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        380
      ],
      "parameters": {
        "width": null,
        "height": 280,
        "content": "## Update Lead\nSalesforce tool to update an existing lead.\nParams: leadId, firstname, lastname, email, mobile, custom field (ProductInterest__c).\nInvoked if duplicate found. Credentials: Salesforce OA"
      }
    },
    {
      "id": "31de4234-4233-45d7-89ba-53d43db7542d",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        380
      ],
      "parameters": {
        "width": null,
        "height": 280,
        "content": "## Duplicate Check\nSalesforce tool to query leads by email (using \"getAll\" with Email condition). Returns if a duplicate exists, with lead_id and details. Invoked after email collection.\nCredentials: "
      }
    },
    {
      "id": "d0ceab0d-a4bf-4020-b55b-57433716fdb3",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        380
      ],
      "parameters": {
        "width": null,
        "height": 280,
        "content": "## Create Lead\nSalesforce tool to create a new lead.\nParams: company (default), lastname, additional fields like email, firstname, mobile, ProductInterest__c.\nInvoked if no duplicate. Credentials: Sal"
      }
    },
    {
      "id": "cb4396b7-f375-485f-bdf4-bcc8b1b31bb4",
      "name": "send_notification_internal",
      "type": "n8n-nodes-base.slackTool",
      "position": [
        440,
        220
      ]
    },
    {
      "id": "d0752cee-6fc3-4cc6-9ec6-087105fb6952",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -400
      ],
      "parameters": {
        "width": 440,
        "height": 260,
        "content": "## Core AI Agent\nThe heart of the bot: Uses OpenAI (via connected model) to manage conversation based on the system prompt. Handles step-by-step data collection, validations, and tool calls (e.g., dup"
      }
    }
  ],
  "connections": {
    "Think": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        []
      ]
    },
    "create_lead": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "update_lead": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "check_duplicate_lead": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "send_notification_client": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "send_notification_internal": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}