Created
August 1, 2025 18:29
-
-
Save sethdavis512/702da76e33d89b753513b170b9a3e547 to your computer and use it in GitHub Desktop.
Auto Draft Email - n8n Automation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nodes": [ | |
| { | |
| "parameters": { | |
| "conditions": { | |
| "options": { | |
| "caseSensitive": true, | |
| "leftValue": "", | |
| "typeValidation": "strict", | |
| "version": 1 | |
| }, | |
| "conditions": [ | |
| { | |
| "id": "53849246-ad32-4845-9976-9f9688f5a6f2", | |
| "operator": { | |
| "type": "boolean", | |
| "operation": "true", | |
| "singleValue": true | |
| }, | |
| "leftValue": "={{ $json.needsReply }}", | |
| "rightValue": "true" | |
| } | |
| ], | |
| "combinator": "and" | |
| }, | |
| "options": {} | |
| }, | |
| "id": "05595c01-e8d2-495b-8c7f-b0c8a1b41d32", | |
| "name": "If Needs Reply", | |
| "type": "n8n-nodes-base.if", | |
| "position": [ | |
| -100, | |
| 60 | |
| ], | |
| "typeVersion": 2 | |
| }, | |
| { | |
| "parameters": { | |
| "jsonSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"needsReply\": {\n \"type\": \"boolean\"\n }\n },\n \"required\": [\"needsReply\"]\n}\n" | |
| }, | |
| "id": "05f97ac0-96a1-41f1-9a25-db3ada18f3ca", | |
| "name": "JSON Parser", | |
| "type": "@n8n/n8n-nodes-langchain.outputParserStructured", | |
| "position": [ | |
| -240, | |
| 220 | |
| ], | |
| "typeVersion": 1 | |
| }, | |
| { | |
| "parameters": { | |
| "model": "gpt-4o", | |
| "options": { | |
| "responseFormat": "json_object", | |
| "temperature": 0 | |
| } | |
| }, | |
| "id": "c000c67d-c5b1-4a52-9ad8-a28139e4366c", | |
| "name": "OpenAI Chat", | |
| "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", | |
| "position": [ | |
| -440, | |
| 220 | |
| ], | |
| "typeVersion": 1, | |
| "credentials": { | |
| "openAiApi": { | |
| "id": "5Y5pUyyIKKyhlRLl", | |
| "name": "OpenAi account" | |
| } | |
| } | |
| }, | |
| { | |
| "parameters": { | |
| "content": "## When I receive an Email\n", | |
| "height": 394.42512272977456, | |
| "width": 304.10628068244364 | |
| }, | |
| "id": "a24e9c4e-9208-404c-a1c2-afb50174799f", | |
| "name": "Sticky Note", | |
| "type": "n8n-nodes-base.stickyNote", | |
| "position": [ | |
| -760, | |
| -60 | |
| ], | |
| "typeVersion": 1 | |
| }, | |
| { | |
| "parameters": { | |
| "content": "## ... that Needs a Reply\n", | |
| "height": 397, | |
| "width": 556 | |
| }, | |
| "id": "4a6cea04-3eff-4677-9094-777f60479399", | |
| "name": "Sticky Note1", | |
| "type": "n8n-nodes-base.stickyNote", | |
| "position": [ | |
| -460, | |
| -60 | |
| ], | |
| "typeVersion": 1 | |
| }, | |
| { | |
| "parameters": { | |
| "content": "## Generate a Reply", | |
| "height": 400.08454375343996, | |
| "width": 333.19082443588354 | |
| }, | |
| "id": "18fb3de3-a180-4353-8965-5efcaf2014a8", | |
| "name": "Sticky Note2", | |
| "type": "n8n-nodes-base.stickyNote", | |
| "position": [ | |
| 120, | |
| -60 | |
| ], | |
| "typeVersion": 1 | |
| }, | |
| { | |
| "parameters": { | |
| "content": "## ...as a Draft in the conversation", | |
| "height": 395, | |
| "width": 326 | |
| }, | |
| "id": "c2573b8f-07b9-4200-8c63-0f1f4d92145d", | |
| "name": "Sticky Note3", | |
| "type": "n8n-nodes-base.stickyNote", | |
| "position": [ | |
| 480, | |
| -60 | |
| ], | |
| "typeVersion": 1 | |
| }, | |
| { | |
| "parameters": { | |
| "model": "gpt-4-turbo", | |
| "options": {} | |
| }, | |
| "id": "229bc840-065b-4104-af5e-f8c00c8802b4", | |
| "name": "OpenAI Chat Model", | |
| "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", | |
| "position": [ | |
| 160, | |
| 200 | |
| ], | |
| "typeVersion": 1, | |
| "credentials": { | |
| "openAiApi": { | |
| "id": "5Y5pUyyIKKyhlRLl", | |
| "name": "OpenAi account" | |
| } | |
| } | |
| }, | |
| { | |
| "parameters": { | |
| "resource": "draft", | |
| "subject": "=Re: {{ $('Gmail Trigger1').item.json.headers.subject }}", | |
| "emailType": "html", | |
| "message": "={{ $json.text.replace(/\\n/g, \"<br />\\n\") }}", | |
| "options": { | |
| "threadId": "={{ $('Gmail Trigger1').item.json.threadId }}", | |
| "sendTo": "={{ $('Gmail Trigger1').item.json.headers.from }}" | |
| } | |
| }, | |
| "id": "ce4a21d7-304e-4c4c-9682-459c04e1f82a", | |
| "name": "Gmail - Create Draft", | |
| "type": "n8n-nodes-base.gmail", | |
| "position": [ | |
| 560, | |
| 60 | |
| ], | |
| "typeVersion": 2.1, | |
| "webhookId": "0252f702-db46-4954-b15f-634c92cacbe0", | |
| "credentials": { | |
| "gmailOAuth2": { | |
| "id": "rei7LBkBJGTGpyG7", | |
| "name": "Gmail account" | |
| } | |
| } | |
| }, | |
| { | |
| "parameters": { | |
| "prompt": "=Subject: {{ $json.subject }}\nMessage:\n{{ $json.textAsHtml }} ", | |
| "messages": { | |
| "messageValues": [ | |
| { | |
| "message": "Your task is to assess if the message requires a response. Return in JSON format true if it does, false otherwise.\nMarketing emails don't require a response." | |
| } | |
| ] | |
| } | |
| }, | |
| "id": "b8fc78b4-99e4-4f39-a5b8-4730fe58c929", | |
| "name": "Assess if message needs a reply", | |
| "type": "@n8n/n8n-nodes-langchain.chainLlm", | |
| "position": [ | |
| -440, | |
| 60 | |
| ], | |
| "typeVersion": 1.3 | |
| }, | |
| { | |
| "parameters": { | |
| "promptType": "define", | |
| "text": "=Subject: {{ $('Gmail Trigger1').item.json.subject }}\nMessage: {{ $('Gmail Trigger1').item.json.textAsHtml }}", | |
| "messages": { | |
| "messageValues": [ | |
| { | |
| "message": "You're a helpful personal assistant and your task is to draft replies on my behalf to my incoming emails. Whenever I provide some text from an email, return an appropriate draft reply for it and nothing else.\nEnsure that the reply is suitable for a professional email setting and addresses the topic in a clear, structured, and detailed manner.\nDo not make things up.\n\nDetailed instructions:\n- Be concise and maintain a business casual tone.\n- Start with \"Hello,\", and end with \"Best,\"\n- When replying to yes-no questions, draft 2 responses: one affirmative and one negative separated by \" - - - - - - - OR - - - - - - - \"\n- If you don't know an answer, you can leave placeholders like \"[YOUR_ANSWER_HERE]\".\n- Don't use any special formatting, only plain text.\n- Reply in the same language as the inbound email." | |
| } | |
| ] | |
| } | |
| }, | |
| "id": "7a1fd713-15c3-4080-a55c-ffb69ecd33eb", | |
| "name": "Generate email reply", | |
| "type": "@n8n/n8n-nodes-langchain.chainLlm", | |
| "position": [ | |
| 160, | |
| 20 | |
| ], | |
| "typeVersion": 1.4 | |
| }, | |
| { | |
| "parameters": { | |
| "pollTimes": { | |
| "item": [ | |
| { | |
| "mode": "everyX", | |
| "value": 5, | |
| "unit": "minutes" | |
| } | |
| ] | |
| }, | |
| "simple": false, | |
| "filters": { | |
| "q": "-from:me" | |
| }, | |
| "options": {} | |
| }, | |
| "id": "41064403-2d62-48f0-85f1-c0d0b0ca6a30", | |
| "name": "Gmail Trigger1", | |
| "type": "n8n-nodes-base.gmailTrigger", | |
| "position": [ | |
| -680, | |
| 60 | |
| ], | |
| "typeVersion": 1, | |
| "credentials": { | |
| "gmailOAuth2": { | |
| "id": "rei7LBkBJGTGpyG7", | |
| "name": "Gmail account" | |
| } | |
| } | |
| } | |
| ], | |
| "connections": { | |
| "If Needs Reply": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Generate email reply", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "JSON Parser": { | |
| "ai_outputParser": [ | |
| [ | |
| { | |
| "node": "Assess if message needs a reply", | |
| "type": "ai_outputParser", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "OpenAI Chat": { | |
| "ai_languageModel": [ | |
| [ | |
| { | |
| "node": "Assess if message needs a reply", | |
| "type": "ai_languageModel", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "OpenAI Chat Model": { | |
| "ai_languageModel": [ | |
| [ | |
| { | |
| "node": "Generate email reply", | |
| "type": "ai_languageModel", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "Assess if message needs a reply": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "If Needs Reply", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "Generate email reply": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Gmail - Create Draft", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "Gmail Trigger1": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Assess if message needs a reply", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| } | |
| }, | |
| "pinData": {}, | |
| "meta": { | |
| "templateCredsSetupCompleted": true, | |
| "instanceId": "e24f074b27fcbd436010b3e109ee0f344c8f96e92b0df96478e12e605d382fd9" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment