{
  "name": "A very simple \"Human in the Loop\" email response system using AI and IMAP",
  "nodes": [
    {
      "id": "271bb16f-9b62-41d9-ab76-114cd7ba915a",
      "name": "Email Trigger (IMAP)",
      "type": "n8n-nodes-base.emailReadImap",
      "position": [
        -1300,
        1340
      ]
    },
    {
      "id": "42d150d8-d574-49f9-9c0e-71a2cdea3b79",
      "name": "Markdown",
      "type": "n8n-nodes-base.markdown",
      "position": [
        -1040,
        1340
      ]
    },
    {
      "id": "e9498a60-0078-4581-b269-7ff552f4047a",
      "name": "Send Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        920,
        1320
      ]
    },
    {
      "id": "ab9f6ac3-2095-44df-aeba-2eab96ecf425",
      "name": "Email Summarization Chain",
      "type": "@n8n/n8n-nodes-langchain.chainSummarization",
      "position": [
        -780,
        1340
      ]
    },
    {
      "id": "86b7c3d0-e1f2-4e2f-b293-8042700d6816",
      "name": "Write email",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -340,
        1340
      ]
    },
    {
      "id": "5d5a397f-f9c3-4691-afd0-9a6102679eac",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -400,
        1560
      ]
    },
    {
      "id": "5b36a295-fda6-4174-9078-0a8ec57620d2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        1260
      ],
      "parameters": {
        "width": 320,
        "height": 240,
        "content": "Chain that summarizes the received email"
      }
    },
    {
      "id": "7110fe1f-0099-49aa-9095-96e733aa468f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -360,
        1260
      ],
      "parameters": {
        "width": 340,
        "height": 240,
        "content": "Agent that retrieves business information from a vector database and processes the response"
      }
    },
    {
      "id": "e2bdbd64-3c37-4867-ae2c-0f6937d82b81",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        1260
      ],
      "parameters": {
        "width": null,
        "height": 240,
        "content": "Convert email to Markdown format for better understanding of LLM models"
      }
    },
    {
      "id": "8ae5d216-5897-4c33-800a-27ff939b174a",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        1300
      ],
      "parameters": {
        "width": null,
        "height": 180,
        "content": "If the feedback is OK send email"
      }
    },
    {
      "id": "4cfce63c-5931-45c5-99ca-eb85dca962b5",
      "name": "Approve Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        380,
        1340
      ]
    },
    {
      "id": "d6c8acd2-ebc1-4aaa-bfcc-cdb18fcc8715",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -820,
        1560
      ]
    },
    {
      "id": "33bbedeb-129a-4e99-ab5a-9e0ec4456156",
      "name": "Set Email text",
      "type": "n8n-nodes-base.set",
      "position": [
        100,
        1340
      ]
    },
    {
      "id": "2293e0e6-4f2a-4622-a610-64b65f34e1e5",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        1300
      ],
      "parameters": {
        "width": null,
        "height": 180,
        "content": "Human in the loop"
      }
    },
    {
      "id": "510196ec-adaf-4e6c-aac0-8ca8b754438a",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        940
      ],
      "parameters": {
        "width": 540,
        "height": 260,
        "content": "# How it works\nThis workflow automates the handling of incoming emails, summarizes their content, generates appropriate responses and validate it through send IMAP email with \"Human in the loop\" syste"
      }
    },
    {
      "id": "c4c9157d-4d05-47a1-a5eb-63865e838d39",
      "name": "Approved?",
      "type": "n8n-nodes-base.if",
      "position": [
        680,
        1340
      ]
    }
  ],
  "connections": {
    "OpenAI": {
      "ai_languageModel": [
        [
          {
            "node": "Write email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Markdown": {
      "main": [
        [
          {
            "node": "Email Summarization Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approved?": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Write email": {
      "main": [
        [
          {
            "node": "Set Email text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approve Email": {
      "main": [
        [
          {
            "node": "Approved?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Email text": {
      "main": [
        [
          {
            "node": "Approve Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Email Summarization Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Email Trigger (IMAP)": {
      "main": [
        [
          {
            "node": "Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Summarization Chain": {
      "main": [
        [
          {
            "node": "Write email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}