{
  "name": "Classify emails and send replies with GPT-4o and gotoHuman for supervision",
  "nodes": [
    {
      "id": "2b131412-e9f1-4a8b-a268-0c9b21443aa7",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -752,
        256
      ]
    },
    {
      "id": "db840ba6-5bf2-4355-af2c-35d6a9b2059a",
      "name": "OpenAI Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        368,
        96
      ]
    },
    {
      "id": "54e8ca88-61d2-4ecf-97be-5bde43f92adf",
      "name": "New Email",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -880,
        16
      ]
    },
    {
      "id": "138f84f1-1e44-4a2f-b2cf-574f196fabb1",
      "name": "AI Classifier",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -672,
        16
      ]
    },
    {
      "id": "f96111be-c199-4e19-84d7-15062c5bbcae",
      "name": "AI Email Writer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        416,
        -80
      ]
    },
    {
      "id": "4aa78fde-0378-43ac-8de4-5eb16d4654db",
      "name": "No reply",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1632,
        -176
      ]
    },
    {
      "id": "fabc6e2c-338c-4fd5-892e-a9d41eb2fbf7",
      "name": "Set Prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        208,
        -80
      ]
    },
    {
      "id": "052cbe31-443a-4b3a-8429-fb775703eee0",
      "name": "Set (edited) prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        1632,
        512
      ]
    },
    {
      "id": "333ddcdf-c633-4824-9096-d1d47a564eb9",
      "name": "Structured Output",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        576,
        96
      ]
    },
    {
      "id": "6b82f29b-240a-42ba-a326-cfe92660e621",
      "name": "Structured Output1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -480,
        256
      ]
    },
    {
      "id": "3d2ca961-b126-4b45-a87c-675128886bbb",
      "name": "Needs Human Attention?",
      "type": "n8n-nodes-base.switch",
      "position": [
        -320,
        0
      ]
    },
    {
      "id": "b8d8ef38-2c99-418b-94bd-9fcd825a3a3a",
      "name": "Not important",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -80,
        192
      ]
    },
    {
      "id": "8afb91b3-70ca-4d20-8dc0-d8e82d47b16b",
      "name": "gotoHuman: Human review",
      "type": "@gotohuman/n8n-nodes-gotohuman.gotoHuman",
      "position": [
        1056,
        0
      ]
    },
    {
      "id": "d7496fcc-e8d5-45fd-94af-0190be114308",
      "name": "Human response",
      "type": "n8n-nodes-base.switch",
      "position": [
        1360,
        -16
      ]
    },
    {
      "id": "c1b741a5-4bb5-4570-acae-c4d6d0aef7f4",
      "name": "Reply to thread",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2016,
        0
      ]
    },
    {
      "id": "2d0ee5a2-b7f6-4e83-9640-4005526c451b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        -80
      ],
      "parameters": {
        "width": null,
        "height": 272,
        "content": "![Source example](https://cdn.prod.website-files.com/6605a2979ff17b2cd1939cd4/6877ff9cd93f480ff6eb4def_677c04b5cd6a77eb434526bf9c0eaaca_gotoHuman%20full%20logo.svg)"
      }
    },
    {
      "id": "b24bd496-feed-4825-8de2-0c04252ffa9e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -224
      ],
      "parameters": {
        "width": 848,
        "height": 640,
        "content": "## Classify Email\nWe ask AI to classify the received email into one of the categories defined in the prompt. It also determines whether a reply is needed and it is deemed important."
      }
    },
    {
      "id": "cb439e6b-dbe7-4e8a-9830-ea95293319c1",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -208
      ],
      "parameters": {
        "width": 720,
        "height": 624,
        "content": "## Draft Email Response\nIf it was determined that a reply is required, we ask AI to draft a response. It might incl. placeholders for a human to replace during review."
      }
    },
    {
      "id": "83096ad5-1749-4863-85c7-05148bc8c583",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        -208
      ],
      "parameters": {
        "width": 656,
        "height": 624,
        "content": "## Human Review\nAsk a human to review the received email and approve any AI-drafted response via gotoHuman.\nDrafts can be manually edited or retried in gotoHuman (Retries loop back to the AI email wri"
      }
    },
    {
      "id": "aeeda5cc-c5ff-4bfe-ac35-7730efca93bb",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        448
      ],
      "parameters": {
        "width": 896,
        "height": 336,
        "content": "## Human asked for Retry\nIn gotoHuman the reviewer clicked retry or edited the prompt to iterate on the LLM output."
      }
    },
    {
      "id": "c20abf9e-385a-4263-9205-8739a95093be",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1808,
        -224
      ],
      "parameters": {
        "width": 560,
        "height": 432,
        "content": "## Send approved Reply\nSend the approved response as a reply to the email thread"
      }
    },
    {
      "id": "e5994c92-1179-421d-957a-ecc413e41e8d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        -1056
      ],
      "parameters": {
        "width": 784,
        "height": 816,
        "content": "gotoHuman - Reviewing\n![Pic](https://cdn.prod.website-files.com/6605a2979ff17b2cd1939cd4/689b5e250227be98ca4d11e2_gth-review.JPG)"
      }
    },
    {
      "id": "890831e1-89c0-4978-9b1f-6bdd00fceea4",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        800
      ],
      "parameters": {
        "width": 1072,
        "height": 352,
        "content": "gotoHuman - Retrying with AI\n![Pic](https://cdn.prod.website-files.com/6605a2979ff17b2cd1939cd4/689b5eb249cfe598f6ef0305_gth-chat.JPG)"
      }
    },
    {
      "id": "3ecfaedc-0b01-47f4-b6d1-bbde0426cc23",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -976
      ],
      "parameters": {
        "width": 688,
        "height": 720,
        "content": "## AI Email Assistant 🤖📧\n### Classifies, Drafts and Sends Human-Approved Reply\n\nThis shows an AI-based email assistant that reads each new incoming email, drafts a reply and sends it after human appro"
      }
    }
  ],
  "connections": {
    "New Email": {
      "main": [
        [
          {
            "node": "AI Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Prompt": {
      "main": [
        [
          {
            "node": "AI Email Writer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Classifier": {
      "main": [
        [
          {
            "node": "Needs Human Attention?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Human response": {
      "main": [
        [
          {
            "node": "No reply",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply to thread",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set (edited) prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Email Writer": {
      "main": [
        [
          {
            "node": "gotoHuman: Human review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output": {
      "ai_outputParser": [
        [
          {
            "node": "AI Email Writer",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Email Writer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output1": {
      "ai_outputParser": [
        [
          {
            "node": "AI Classifier",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Set (edited) prompt": {
      "main": [
        [
          {
            "node": "AI Email Writer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Needs Human Attention?": {
      "main": [
        [
          {
            "node": "Set Prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "gotoHuman: Human review",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Not important",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "gotoHuman: Human review": {
      "main": [
        [
          {
            "node": "Human response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}