{
  "name": "AI Inbound Lead Email Responder",
  "nodes": [
    {
      "parameters": {
        "postProcessAction": "nothing",
        "options": {}
      },
      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 2,
      "position": [
        200,
        0
      ],
      "id": "4bdc8c62-835c-41b0-b75d-f5daca29a847",
      "name": "Email Trigger (IMAP)"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "GPT-4O"
        },
        "messages": {
          "values": [
            {
              "content": "You're currently monitoring a sales email inbox for my high-ticket coaching offer. For every inquiry you receive, digest it and respond appropriately with a customized message that's tuned to the particular prospect. Make sure to use spartan, no-frills language."
            },
            {
              "content": "Name: Michael SmithType: High-TicketMonthly Commitment: $8,000About: Hi I really want to get started on your high tickey monthly e-commerce offer - let me know how to start!"
            },
            {
              "content": "Hey Michael,\n\n[Your Name] here. Thanks for reaching out & I appreciate your interest in my high ticket e-commerce offer. Happy to help you get started!\n\nI just let someone on my team know about this & they'll give you a call in a couple of minutes to dive into detail. Looking forward to working with you.\n\nCheers,\n[Your Name]",
              "role": "assistant"
            },
            {
              "content": "={{ $('Email Trigger (IMAP)').item.json.textPlain }}"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1040,
        0
      ],
      "id": "b1dde0a2-a18c-4b9c-a57b-b838cdd31c60",
      "name": "Write Customized Reply"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "GPT-4O"
        },
        "messages": {
          "values": [
            {
              "content": "=Identify if the following message is a lead that's interested in our services.\n\nOutput as JSON {\"lead\": \"<true/false>\"}\n\n {{ $json.textPlain }}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        440,
        0
      ],
      "id": "d0b5336f-31cc-4e3f-98a4-108cfce49edb",
      "name": "Is Lead?"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "4da59f1a-dd10-450e-a113-d193b63fcdac",
              "leftValue": "={{ $json.message.content.lead.toBoolean() }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        800,
        0
      ],
      "id": "af663989-a888-4af2-a67d-65c0fe6aa378",
      "name": "Filter"
    },
    {
      "parameters": {
        "operation": "getAll",
        "filters": {
          "q": "=from:\"{{ $('Email Trigger (IMAP)').item.json.from }}\" subject:\"{{ $('Email Trigger (IMAP)').item.json.subject }}\" "
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1400,
        0
      ],
      "id": "cf280db9-ae1c-49d1-b56a-6bca8c63572c",
      "name": "Get Message",
      "webhookId": "49c65756-7d95-4006-8098-7b42832657ec"
    },
    {
      "parameters": {
        "operation": "reply",
        "messageId": "={{ $json.id }}",
        "emailType": "text",
        "message": "={{ $('Write Customized Reply').item.json.message.content }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1600,
        0
      ],
      "id": "d5e1c3a0-574d-41a3-9f18-963195e36e63",
      "name": "Reply to Message",
      "webhookId": "7395318d-5346-4e1e-9650-e734aa3d5458"
    }
  ],
  "connections": {
    "Email Trigger (IMAP)": {
      "main": [
        [
          {
            "node": "Is Lead?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Lead?": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Write Customized Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Customized Reply": {
      "main": [
        [
          {
            "node": "Get Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Message": {
      "main": [
        [
          {
            "node": "Reply to Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false
}
