{
  "name": "AI-driven lead management and inquiry automation with ERPNext & n8n",
  "nodes": [
    {
      "id": "23291d25-3e1a-4b0d-9b1d-d066e8c04a1f",
      "name": "Customer Lead AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -640,
        460
      ]
    },
    {
      "id": "1831dc36-910b-4a72-a90e-b411f105a8c3",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -800,
        800
      ]
    },
    {
      "id": "79713c56-2f7c-4872-90e4-331715f54048",
      "name": "Abbriviations",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -640,
        800
      ]
    },
    {
      "id": "73b1e3c9-4703-4f87-8399-e7a9bf368d4c",
      "name": "Lead Body",
      "type": "n8n-nodes-base.set",
      "position": [
        -1640,
        640
      ]
    },
    {
      "id": "5f25d846-c639-49e5-bea2-160000bfb104",
      "name": "Source Website and Status Open",
      "type": "n8n-nodes-base.if",
      "position": [
        -1920,
        640
      ]
    },
    {
      "id": "12ba65c9-0890-4862-9704-98492eb8f637",
      "name": "Microsoft Outlook",
      "type": "n8n-nodes-base.microsoftOutlook",
      "position": [
        1180,
        580
      ]
    },
    {
      "id": "b1410997-3705-4234-918e-a14e4ccc6b70",
      "name": "Email Body Text Generated by AI",
      "type": "n8n-nodes-base.set",
      "position": [
        700,
        580
      ]
    },
    {
      "id": "b10684b9-9f72-42b3-a9f9-c54e711ceb59",
      "name": "Fields for Outlook",
      "type": "n8n-nodes-base.code",
      "position": [
        360,
        600
      ]
    },
    {
      "id": "e2c10569-fde2-425c-8b20-fdb32a6e2bd5",
      "name": "Email Body for Outlook",
      "type": "n8n-nodes-base.code",
      "position": [
        860,
        580
      ]
    },
    {
      "id": "3297550b-ed78-4528-ad65-facdc879590a",
      "name": "Inquiry has Notes",
      "type": "n8n-nodes-base.if",
      "position": [
        -1080,
        640
      ]
    },
    {
      "id": "e2544a27-8b6d-4bb0-84f1-00c3a5e66978",
      "name": "Inquiry is Valid?",
      "type": "n8n-nodes-base.if",
      "position": [
        40,
        620
      ]
    },
    {
      "id": "39cc73e7-ceb3-4e8e-a5bc-55648595f784",
      "name": "Company Profile",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        -540,
        800
      ]
    },
    {
      "id": "8ee24c59-1acb-4d76-a136-74e69d694a49",
      "name": "Company Policies",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        -420,
        780
      ]
    },
    {
      "id": "a5db3aa7-8a77-4553-9c13-a96c51f32745",
      "name": "Company Contact Database",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -300,
        780
      ]
    },
    {
      "id": "f3e73266-faa4-4e6d-8c60-92669d64233b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2000,
        257.53836663807056
      ],
      "parameters": {
        "width": 297.84037615575886,
        "height": 643.0692298205195,
        "content": "### Filter the Lead\nI have done only for theose which are open and where the source is Website. You can remove this if you want to have all leads."
      }
    },
    {
      "id": "0056e35c-4901-406d-9a95-f6da26808841",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        280
      ],
      "parameters": {
        "width": 302.58963031819115,
        "height": 660,
        "content": "### Output from AI Agent\nIf the INquiry is invalid, not related to the products and services offered, it will invalidate that you can optionnally link the invalid output to email or anything. Options "
      }
    },
    {
      "id": "5e0e9561-0fb8-4225-aa59-58e25abc8ca1",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        280.0000000000002
      ],
      "parameters": {
        "width": 764.2159851725196,
        "height": 648.5051458745236,
        "content": "### Customer Experience Agent (AI)\nNow this Node is an AI Agent who is speicalized to understand the Lead Source and the Inquiry sent by Cusomter. The Agent will look at company information, which has"
      }
    },
    {
      "id": "5a3ca9c9-07c2-4c74-ba8c-6b14f487fc4d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2420,
        260
      ],
      "parameters": {
        "width": 398,
        "height": 642,
        "content": "### Once the Lead is generatd in ERP\n\nConsider creating creating an inquiry web form in ERPNext and let the Website Visitor fill that Inquiry form, as soon as the iqnuiry form is filled this workflow "
      }
    },
    {
      "id": "cf930f52-d06b-40c1-91f5-fa1c3dfee09a",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        618.1625654107004,
        260
      ],
      "parameters": {
        "width": 388.6432532629275,
        "height": 662,
        "content": "### Email Body\nGet only Email body from Previous Node and then Convert this to HTML Format so that it looks professional. \n"
      }
    },
    {
      "id": "a1023b2b-3e0d-486f-9050-8ff98ff060b5",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1440,
        260
      ],
      "parameters": {
        "width": 248.905549047384,
        "height": 654.6630436071407,
        "content": "### Get Details of Lead from ERPNext. For us most important is Notes"
      }
    },
    {
      "id": "732046b2-967a-4e0c-85e4-ae04e8c0f9cf",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1680,
        260
      ],
      "parameters": {
        "width": 222.5278407657604,
        "height": 651.0941643427163,
        "content": "### Get Lead ID\nThis will extract the Lead Name in ERPNext. Ensure to send doc.name from the webhook in ERPnext\n\nIt will then send this to next node to get full details of this lead."
      }
    },
    {
      "id": "b80448ee-5a15-4569-99e4-c3e616a5600d",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1035.2592266730085,
        260
      ],
      "parameters": {
        "width": 399.43186296400074,
        "height": 662,
        "content": "### Send Email\n\nNow drag and drop the fields from Previous Nodes. Email Addresses Subject and Body.\n\nRemember all fields are selected by AI Agent, whom to send email, what to send and so on. \n\nYou can"
      }
    },
    {
      "id": "3d190d34-f6e0-47bc-9216-d312d1d6ee38",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2920,
        260
      ],
      "parameters": {
        "width": 475.27306699862953,
        "height": 636.1483291619771,
        "content": "## Developed by Amjid Ali\n\nThank you for using this workflow template. It has taken me countless hours of hard work, research, and dedication to develop, and I sincerely hope it adds value to your wor"
      }
    },
    {
      "id": "cfd7effc-92aa-43c6-9fc5-054b53de74a2",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1160,
        280
      ],
      "parameters": {
        "width": 248.905549047384,
        "height": 654.6630436071407,
        "content": "### Inquiry with Notes\nIf inquiry is having notes then only it will forward to next node."
      }
    },
    {
      "id": "e5b0992c-e360-4323-82cb-c7ddec45deb5",
      "name": "Get Lead Data from ERPNext",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1360,
        640
      ]
    },
    {
      "id": "87508043-baf5-4fa6-aa38-0f06881dc267",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        280,
        280
      ],
      "parameters": {
        "width": 302.58963031819115,
        "height": 660,
        "content": "### Prepare for Email\nThis node will get approprate Fields for Email \nEmail Addresses:\nSubject : \nEmail Body : "
      }
    },
    {
      "id": "2b4c1e91-c64b-43cb-aba2-c6f8f5a17c79",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -2300,
        640
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Source Website and Status Open",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lead Body": {
      "main": [
        [
          {
            "node": "Get Lead Data from ERPNext",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Abbriviations": {
      "ai_tool": [
        [
          {
            "node": "Customer Lead AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Company Profile": {
      "ai_tool": [
        [
          {
            "node": "Customer Lead AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Company Policies": {
      "ai_tool": [
        [
          {
            "node": "Customer Lead AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Inquiry has Notes": {
      "main": [
        [
          {
            "node": "Customer Lead AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inquiry is Valid?": {
      "main": [
        [
          {
            "node": "Fields for Outlook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Customer Lead AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fields for Outlook": {
      "main": [
        [
          {
            "node": "Email Body Text Generated by AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Customer Lead AI Agent": {
      "main": [
        [
          {
            "node": "Inquiry is Valid?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Body for Outlook": {
      "main": [
        [
          {
            "node": "Microsoft Outlook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Company Contact Database": {
      "ai_tool": [
        [
          {
            "node": "Customer Lead AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get Lead Data from ERPNext": {
      "main": [
        [
          {
            "node": "Inquiry has Notes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Source Website and Status Open": {
      "main": [
        [
          {
            "node": "Lead Body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Body Text Generated by AI": {
      "main": [
        [
          {
            "node": "Email Body for Outlook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}