{ "id": "Nvn78tMRNnKji7Fg", "meta": { "instanceId": "a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462", "templateCredsSetupCompleted": true }, "name": "Very simple Human in the loop system email with AI e IMAP", "tags": [], "nodes": [ { "id": "271bb16f-9b62-41d9-ab76-114cd7ba915a", "name": "Email Trigger (IMAP)", "type": "n8n-nodes-base.emailReadImap", "position": [ -1300, 1340 ], "parameters": { "options": {} }, "credentials": { "imap": { "id": "k31W9oGddl9pMDy4", "name": "IMAP info@n3witalia.com" } }, "typeVersion": 2 }, { "id": "42d150d8-d574-49f9-9c0e-71a2cdea3b79", "name": "Markdown", "type": "n8n-nodes-base.markdown", "position": [ -1040, 1340 ], "parameters": { "html": "={{ $json.textHtml }}", "options": {} }, "typeVersion": 1 }, { "id": "e9498a60-0078-4581-b269-7ff552f4047a", "name": "Send Email", "type": "n8n-nodes-base.emailSend", "position": [ 920, 1320 ], "webhookId": "a79ae1b4-648c-4cb4-b6cd-04ea3c1d9314", "parameters": { "html": "={{ $('Set Email text').item.json.email }}", "options": {}, "subject": "=Re: {{ $('Email Trigger (IMAP)').item.json.subject }}", "toEmail": "={{ $('Email Trigger (IMAP)').item.json.from }}", "fromEmail": "={{ $('Email Trigger (IMAP)').item.json.to }}" }, "credentials": { "smtp": { "id": "hRjP3XbDiIQqvi7x", "name": "SMTP info@n3witalia.com" } }, "typeVersion": 2.1 }, { "id": "ab9f6ac3-2095-44df-aeba-2eab96ecf425", "name": "Email Summarization Chain", "type": "@n8n/n8n-nodes-langchain.chainSummarization", "position": [ -780, 1340 ], "parameters": { "options": { "binaryDataKey": "={{ $json.data }}", "summarizationMethodAndPrompts": { "values": { "prompt": "=Write a concise summary of the following in max 100 words:\n\n\"{{ $json.data }}\"\n\nDo not enter the total number of words used.", "combineMapPrompt": "=Write a concise summary of the following in max 100 words:\n\n\"{{ $json.data }}\"\n\nDo not enter the total number of words used." } } }, "operationMode": "nodeInputBinary" }, "typeVersion": 2 }, { "id": "86b7c3d0-e1f2-4e2f-b293-8042700d6816", "name": "Write email", "type": "@n8n/n8n-nodes-langchain.agent", "position": [ -340, 1340 ], "parameters": { "text": "=Write the text to reply to the following email:\n\n{{ $json.response.text }}", "options": { "systemMessage": "You are an expert at answering emails. You need to answer them professionally based on the information you have. This is a business email. Be concise and never exceed 100 words. Only the body of the email, not create the subject" }, "promptType": "define", "hasOutputParser": true }, "typeVersion": 1.7 }, { "id": "5d5a397f-f9c3-4691-afd0-9a6102679eac", "name": "OpenAI", "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "position": [ -400, 1560 ], "parameters": { "model": { "__rl": true, "mode": "list", "value": "gpt-4o-mini", "cachedResultName": "gpt-4o-mini" }, "options": {} }, "credentials": { "openAiApi": { "id": "CDX6QM4gLYanh0P4", "name": "OpenAi account" } }, "typeVersion": 1.2 }, { "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" }, "typeVersion": 1 }, { "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" }, "typeVersion": 1 }, { "id": "e2bdbd64-3c37-4867-ae2c-0f6937d82b81", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "position": [ -1100, 1260 ], "parameters": { "height": 240, "content": "Convert email to Markdown format for better understanding of LLM models" }, "typeVersion": 1 }, { "id": "8ae5d216-5897-4c33-800a-27ff939b174a", "name": "Sticky Note7", "type": "n8n-nodes-base.stickyNote", "position": [ 620, 1300 ], "parameters": { "height": 180, "content": "If the feedback is OK send email" }, "typeVersion": 1 }, { "id": "4cfce63c-5931-45c5-99ca-eb85dca962b5", "name": "Approve Email", "type": "n8n-nodes-base.emailSend", "position": [ 380, 1340 ], "webhookId": "4f9f06e7-9b2b-4896-9b51-245972341d12", "parameters": { "message": "=