Überwachte Klassifizierung von E-Mails mit GPT-4o und gotoHuman und Senden von Antworten

Experte

Dies ist ein Ticket Management, Multimodal AI-Bereich Automatisierungsworkflow mit 24 Nodes. Hauptsächlich werden Set, Gmail, Switch, GmailTrigger, Agent und andere Nodes verwendet. Überwachung der E-Mail-Klassifizierung und das Senden von Antworten mit GPT-4o und gotoHuman

Voraussetzungen
  • Google-Konto + Gmail API-Anmeldedaten
  • OpenAI API Key
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "meta": {
    "instanceId": "5ec543f78db8e552b46818580d4137dda2f58675a1a45426c44ae175fc35ac62"
  },
  "nodes": [
    {
      "id": "2b131412-e9f1-4a8b-a268-0c9b21443aa7",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -752,
        256
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {},
      "typeVersion": 1.2
    },
    {
      "id": "db840ba6-5bf2-4355-af2c-35d6a9b2059a",
      "name": "OpenAI Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        368,
        96
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {},
      "typeVersion": 1.2
    },
    {
      "id": "54e8ca88-61d2-4ecf-97be-5bde43f92adf",
      "name": "Neue E-Mail",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -880,
        16
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {},
      "typeVersion": 1.2
    },
    {
      "id": "138f84f1-1e44-4a2f-b2cf-574f196fabb1",
      "name": "AI-Klassifikator",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -672,
        16
      ],
      "parameters": {
        "text": "=From: {{ $json.from.text }}\nTo: {{ $json.to.text }}\nSubject: {{ $json.subject }}\nBody:\n{{ $json.text }}",
        "options": {
          "systemMessage": "You are a helpful email assistant analyzing the email passed by the user.\nPlease determine whether we need to reply and if you would flag it as important. Also classify the email into one of the following categories:\n- Customer Support\n- Partnership Inquiry\n- Sales opportunity\n- Transactional notification\n- Promotion\n- Spam\n- Personal"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "f96111be-c199-4e19-84d7-15062c5bbcae",
      "name": "AI-E-Mail-Verfasser",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        416,
        -80
      ],
      "parameters": {
        "text": "=From: {{ $('New Email').item.json.from.text }}\nTo: {{ $('New Email').item.json.to.text }}\nSubject: {{ $('New Email').item.json.subject }}\nBody:\n{{ $('New Email').item.json.text }}",
        "options": {
          "systemMessage": "={{ $json.prompt }}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "4aa78fde-0378-43ac-8de4-5eb16d4654db",
      "name": "Keine Antwort",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1632,
        -176
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "fabc6e2c-338c-4fd5-892e-a9d41eb2fbf7",
      "name": "Prompt setzen",
      "type": "n8n-nodes-base.set",
      "position": [
        208,
        -80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d1b93765-fd43-4c01-aff9-f96170b77cd9",
              "name": "prompt",
              "type": "string",
              "value": "You are a helpful email assistant. Please draft a reply to the email passed by the user. Match the writing style of the received email. If you cannot answer questions or draft a complete reply, incl. placeholders. A user will review your draft after this and can fill in more info. Incl. the body of the email only, we are responding within the thread."
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "052cbe31-443a-4b3a-8429-fb775703eee0",
      "name": "Prompt (bearbeitet) setzen",
      "type": "n8n-nodes-base.set",
      "position": [
        1632,
        512
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f10b4f0b-3756-48e9-a7f6-51299ad48427",
              "name": "prompt",
              "type": "string",
              "value": "={{ $json.messages[0].content || $('Set Prompt').item.json.prompt }}"
            },
            {
              "id": "9a7c60fe-a782-4660-97fe-a7fc851cbb45",
              "name": "reviewToUpdate",
              "type": "string",
              "value": "={{ $json.reviewId }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "333ddcdf-c633-4824-9096-d1d47a564eb9",
      "name": "Strukturierte Ausgabe",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        576,
        96
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"textEmailDraft\": \"Hello Jack...\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "6b82f29b-240a-42ba-a326-cfe92660e621",
      "name": "Strukturierte Ausgabe1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -480,
        256
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"classifiedAs\": \"support\",\n    \"needsReply\": true,\n    \"important\": false\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "3d2ca961-b126-4b45-a87c-675128886bbb",
      "name": "Benötigt menschliche Aufmerksamkeit?",
      "type": "n8n-nodes-base.switch",
      "position": [
        -320,
        0
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Needs reply",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b5af0410-a10b-4b7c-a4e9-33f351a9c988",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.output.needsReply }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Needs no reply but important",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ace11ff1-0722-475a-ba61-706bc21f9e8f",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ !$json.output.needsReply && $json.output.important }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Don't bother",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d36d5ec4-90a8-4a70-bedd-4a3534dc0308",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ !$json.output.needsReply && !$json.output.important }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "b8d8ef38-2c99-418b-94bd-9fcd825a3a3a",
      "name": "Nicht wichtig",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -80,
        192
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8afb91b3-70ca-4d20-8dc0-d8e82d47b16b",
      "name": "gotoHuman: Manuelle Prüfung",
      "type": "@gotohuman/n8n-nodes-gotohuman.gotoHuman",
      "position": [
        1056,
        0
      ],
      "webhookId": "f445153e-594c-4e61-9f32-b6b4e87c1411",
      "parameters": {
        "fields": {
          "value": {
            "email": "={{ $('New Email').item.json.textAsHtml }}",
            "sender": "={{ $('New Email').item.json.from.text }}",
            "emailDraft": "={{ $json.output?.textEmailDraft ? {ai: {prompt: $('Set Prompt').item.json.prompt}, content: $json.output?.textEmailDraft} : \"No reply needed - FYI only\" }}",
            "classification": "={{ $('AI Classifier').item.json.output.classifiedAs }}"
          },
          "schema": [
            {
              "id": "sender",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "sender (textShort)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email (emailHtml)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "classification",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "classification (textShort)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "emailDraft",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "emailDraft (text)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "additionalFields": {
          "updateForReviewId": "={{ $('Set (edited) prompt').isExecuted ? $('Set (edited) prompt').item.json.reviewToUpdate : null }}"
        },
        "reviewTemplateID": {
          "__rl": true,
          "mode": "list"
        }
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "d7496fcc-e8d5-45fd-94af-0190be114308",
      "name": "Menschliche Antwort",
      "type": "n8n-nodes-base.switch",
      "position": [
        1360,
        -16
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Rejected",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c25eb32d-e664-420c-8574-946f9e1c10cf",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.response }}",
                    "rightValue": "rejected"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Approved",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a55f8641-84eb-4043-a573-9958b9606571",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.response }}",
                    "rightValue": "approved"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Retry",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "feaea8d7-d127-4a03-a87d-2269551ab775",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.type }}",
                    "rightValue": "chat"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "c1b741a5-4bb5-4570-acae-c4d6d0aef7f4",
      "name": "Auf Thread antworten",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2016,
        0
      ],
      "webhookId": "f5644cf1-21dd-446e-91b1-06a6958cdc27",
      "parameters": {
        "message": "={{ $json.responseValues.emailDraft.value }}",
        "options": {
          "appendAttribution": false
        },
        "emailType": "text",
        "messageId": "={{ $('New Email').item.json.id }}",
        "operation": "reply"
      },
      "credentials": {},
      "typeVersion": 2.1
    },
    {
      "id": "2d0ee5a2-b7f6-4e83-9640-4005526c451b",
      "name": "Haftnotiz",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        -80
      ],
      "parameters": {
        "color": 7,
        "height": 272,
        "content": "![Source example](https://cdn.prod.website-files.com/6605a2979ff17b2cd1939cd4/6877ff9cd93f480ff6eb4def_677c04b5cd6a77eb434526bf9c0eaaca_gotoHuman%20full%20logo.svg)"
      },
      "typeVersion": 1
    },
    {
      "id": "b24bd496-feed-4825-8de2-0c04252ffa9e",
      "name": "Haftnotiz1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -224
      ],
      "parameters": {
        "color": 7,
        "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."
      },
      "typeVersion": 1
    },
    {
      "id": "cb439e6b-dbe7-4e8a-9830-ea95293319c1",
      "name": "Haftnotiz2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -208
      ],
      "parameters": {
        "color": 7,
        "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."
      },
      "typeVersion": 1
    },
    {
      "id": "83096ad5-1749-4863-85c7-05148bc8c583",
      "name": "Haftnotiz3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        -208
      ],
      "parameters": {
        "color": 7,
        "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 writer node)."
      },
      "typeVersion": 1
    },
    {
      "id": "aeeda5cc-c5ff-4bfe-ac35-7730efca93bb",
      "name": "Haftnotiz4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        448
      ],
      "parameters": {
        "color": 7,
        "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."
      },
      "typeVersion": 1
    },
    {
      "id": "c20abf9e-385a-4263-9205-8739a95093be",
      "name": "Haftnotiz5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1808,
        -224
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 432,
        "content": "## Send approved Reply\nSend the approved response as a reply to the email thread"
      },
      "typeVersion": 1
    },
    {
      "id": "e5994c92-1179-421d-957a-ecc413e41e8d",
      "name": "Haftnotiz6",
      "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)"
      },
      "typeVersion": 1
    },
    {
      "id": "890831e1-89c0-4978-9b1f-6bdd00fceea4",
      "name": "Haftnotiz7",
      "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)"
      },
      "typeVersion": 1
    },
    {
      "id": "3ecfaedc-0b01-47f4-b6d1-bbde0426cc23",
      "name": "Haftnotiz8",
      "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 approval in gotoHuman.\n\n### ⚠️ How to set up\n[ ] In n8n, install the gotoHuman node **before** importing this template or some settings will be missing (Just add the node to a blank canvas before importing)\n\n[ ] Create gotoHuman account, copy API key\n\n[ ] In gotoHuman, import a review template from ID: `v81wzxwYoFYvWpmuIBgX`\n![x](https://cdn.prod.website-files.com/6605a2979ff17b2cd1939cd4/689484a8c752885e94ef212e_import-menu.JPG)\n[ ] In the gotoHuman node, set up the credentials using your API key and select the review template \"Email Smart Reply\" from the list (This is the one you just imported)\n[ ] Connect Gmail and OpenAI account\n\n### Requirements\n- gotoHuman account for human supervision\n- OpenAI account for classification and email draft\n- Gmail for emails"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "54e8ca88-61d2-4ecf-97be-5bde43f92adf": {
      "main": [
        [
          {
            "node": "138f84f1-1e44-4a2f-b2cf-574f196fabb1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fabc6e2c-338c-4fd5-892e-a9d41eb2fbf7": {
      "main": [
        [
          {
            "node": "f96111be-c199-4e19-84d7-15062c5bbcae",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "138f84f1-1e44-4a2f-b2cf-574f196fabb1": {
      "main": [
        [
          {
            "node": "3d2ca961-b126-4b45-a87c-675128886bbb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d7496fcc-e8d5-45fd-94af-0190be114308": {
      "main": [
        [
          {
            "node": "4aa78fde-0378-43ac-8de4-5eb16d4654db",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "c1b741a5-4bb5-4570-acae-c4d6d0aef7f4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "052cbe31-443a-4b3a-8429-fb775703eee0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f96111be-c199-4e19-84d7-15062c5bbcae": {
      "main": [
        [
          {
            "node": "8afb91b3-70ca-4d20-8dc0-d8e82d47b16b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2b131412-e9f1-4a8b-a268-0c9b21443aa7": {
      "ai_languageModel": [
        [
          {
            "node": "138f84f1-1e44-4a2f-b2cf-574f196fabb1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "333ddcdf-c633-4824-9096-d1d47a564eb9": {
      "ai_outputParser": [
        [
          {
            "node": "f96111be-c199-4e19-84d7-15062c5bbcae",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "db840ba6-5bf2-4355-af2c-35d6a9b2059a": {
      "ai_languageModel": [
        [
          {
            "node": "f96111be-c199-4e19-84d7-15062c5bbcae",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "6b82f29b-240a-42ba-a326-cfe92660e621": {
      "ai_outputParser": [
        [
          {
            "node": "138f84f1-1e44-4a2f-b2cf-574f196fabb1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "052cbe31-443a-4b3a-8429-fb775703eee0": {
      "main": [
        [
          {
            "node": "f96111be-c199-4e19-84d7-15062c5bbcae",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3d2ca961-b126-4b45-a87c-675128886bbb": {
      "main": [
        [
          {
            "node": "fabc6e2c-338c-4fd5-892e-a9d41eb2fbf7",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "8afb91b3-70ca-4d20-8dc0-d8e82d47b16b",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "b8d8ef38-2c99-418b-94bd-9fcd825a3a3a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8afb91b3-70ca-4d20-8dc0-d8e82d47b16b": {
      "main": [
        [
          {
            "node": "d7496fcc-e8d5-45fd-94af-0190be114308",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Häufig gestellte Fragen

Wie verwende ich diesen Workflow?

Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.

Für welche Szenarien ist dieser Workflow geeignet?

Experte - Ticketverwaltung, Multimodales KI

Ist es kostenpflichtig?

Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.

Workflow-Informationen
Schwierigkeitsgrad
Experte
Anzahl der Nodes24
Kategorie2
Node-Typen10
Schwierigkeitsbeschreibung

Für fortgeschrittene Benutzer, komplexe Workflows mit 16+ Nodes

Autor
gotoHuman

gotoHuman

@gotohuman

Approve critical actions in gotoHuman’s customizable review interface and edit AI outputs manually or by looping back to your workflow. Ensure AI-generated content is on-brand, messages to customers are accurate, and high-stakes decisions are made by humans.

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34