Speed to lead via email A developer built an automated email response system using n8n, Gmail, and OpenAI's language model to speed up lead response times. The workflow triggers on new emails, uses an AI agent to analyze content, retrieves relevant documents from Google Docs, and sends a reply. The system aims to reduce the time between receiving an inquiry and sending a response. | { | | | "name": "Speed to lead via Gmail", | | | "nodes": | | | { | | | "parameters": { | | | "pollTimes": { | | | "item": | | | { | | | "mode": "everyMinute" | | | } | | | | | | }, | | | "filters": {} | | | }, | | | "type": "n8n-nodes-base.gmailTrigger", | | | "typeVersion": 1.3, | | | "position": | | | -576, | | | -176 | | | , | | | "id": "00000000-0000-4000-8000-000000000001", | | | "name": "Gmail Trigger", | | | "credentials": { | | | "gmailOAuth2": { | | | "id": "I6maisIBTmcRqsa2", | | | "name": "Credential 2" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "options": {} | | | }, | | | "type": "@n8n/n8n-nodes-langchain.agent", | | | "typeVersion": 3, | | | "position": | | | -400, | | | -176 | | | , | | | "id": "00000000-0000-4000-8000-000000000002", | | | "name": "AI Agent" | | | }, | | | { | | | "parameters": { | | | "model": { | | | " rl": true, | | | "mode": "list", | | | "value": "ism-0.3-sibt" | | | }, | | | "builtInTools": {}, | | | "options": {} | | | }, | | | "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", | | | "typeVersion": 1.3, | | | "position": | | | -416, | | | 96 | | | , | | | "id": "00000000-0000-4000-8000-000000000003", | | | "name": "OpenAI Chat Model", | | | "credentials": { | | | "openAiApi": { | | | "id": "zgkMBu6y37xIBaha", | | | "name": "Credential 4" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "options": {} | | | }, | | | "type": "@n8n/n8n-nodes-langchain.agent", | | | "typeVersion": 3, | | | "position": | | | 144, | | | -192 | | | , | | | "id": "00000000-0000-4000-8000-000000000004", | | | "name": "AI Agent1" | | | }, | | | { | | | "parameters": { | | | "operation": "get", | | | "documentURL": "https://example1.com", | | | "simple": false | | | }, | | | "type": "n8n-nodes-base.googleDocsTool", | | | "typeVersion": 2, | | | "position": | | | 448, | | | 48 | | | , | | | "id": "00000000-0000-4000-8000-000000000005", | | | "name": "Get a document in Google Docs", | | | "credentials": { | | | "googleDocsOAuth2Api": { | | | "id": "QHaaEBq7E7RN3t3h", | | | "name": "Credential 6" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "operation": "get", | | | "documentURL": "https://example2.com", | | | "simple": false | | | }, | | | "type": "n8n-nodes-base.googleDocsTool", | | | "typeVersion": 2, | | | "position": | | | 288, | | | 48 | | | , | | | "id": "00000000-0000-4000-8000-000000000006", | | | "name": "Get a document in Google Docs1", | | | "credentials": { | | | "googleDocsOAuth2Api": { | | | "id": "QHaaEBq7E7RN3t3h", | | | "name": "Credential 6" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "operation": "reply", | | | "messageId": "123", | | | "emailType": "text", | | | "message": "hello", | | | "options": { | | | "appendAttribution": false | | | } | | | }, | | | "type": "n8n-nodes-base.gmail", | | | "typeVersion": 2.1, | | | "position": | | | 640, | | | -192 | | | , | | | "id": "00000000-0000-4000-8000-000000000007", | | | "name": "Reply to a message", | | | "webhookId": "00000000-0000-4000-8000-000000000008", | | | "credentials": { | | | "gmailOAuth2": { | | | "id": "I6maisIBTmcRqsa2", | | | "name": "Credential 2" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "conditions": { | | | "options": { | | | "caseSensitive": true, | | | "leftValue": "", | | | "typeValidation": "strict", | | | "version": 2 | | | }, | | | "conditions": | | | { | | | "id": "00000000-0000-4000-8000-000000000009", | | | "leftValue": "", | | | "rightValue": "", | | | "operator": { | | | "type": "string", | | | "operation": "equals", | | | "name": "filter.operator.equals" | | | } | | | } | | | , | | | "combinator": "and" | | | }, | | | "options": {} | | | }, | | | "type": "n8n-nodes-base.if", | | | "typeVersion": 2.2, | | | "position": | | | -112, | | | -176 | | | , | | | "id": "00000000-0000-4000-8000-00000000000a", | | | "name": "If" | | | }, | | | { | | | "parameters": { | | | "pollTimes": { | | | "item": | | | { | | | "mode": "everyMinute" | | | } | | | | | | }, | | | "filters": {} | | | }, | | | "type": "n8n-nodes-base.gmailTrigger", | | | "typeVersion": 1.3, | | | "position": | | | -544, | | | 480 | | | , | | | "id": "00000000-0000-4000-8000-00000000000b", | | | "name": "Gmail Trigger1", | | | "credentials": { | | | "gmailOAuth2": { | | | "id": "I6maisIBTmcRqsa2", | | | "name": "Credential 2" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "operation": "append", | | | "documentId": { | | | " rl": true, | | | "value": "6ctDXv-ydPvbmefhKWAKM6DgJE2h4H7ZaxoyYZExcugY", | | | "mode": "list", | | | "cachedResultName": "Resource 1", | | | "cachedResultUrl": "https://example3.com" | | | }, | | | "sheetName": { | | | " rl": true, | | | "value": "zgk=4", | | | "mode": "list", | | | "cachedResultName": "Resource 2", | | | "cachedResultUrl": "https://example4.com" | | | }, | | | "columns": { | | | "mappingMode": "defineBelow", | | | "value": {}, | | | "matchingColumns": , | | | "schema": | | | { | | | "id": "Name", | | | "displayName": "Name", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Email", | | | "displayName": "Email", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true, | | | "removed": false | | | }, | | | { | | | "id": "Requested service", | | | "displayName": "Requested service", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Screening questions", | | | "displayName": "Screening questions", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Screening answers", | | | "displayName": "Screening answers", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Urgency classification", | | | "displayName": "Urgency classification", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Appointment date", | | | "displayName": "Appointment date", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Appointment status", | | | "displayName": "Appointment status", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Summary", | | | "displayName": "Summary", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | } | | | , | | | "attemptToConvertTypes": false, | | | "convertFieldsToString": false | | | }, | | | "options": {} | | | }, | | | "type": "n8n-nodes-base.googleSheets", | | | "typeVersion": 4.7, | | | "position": | | | 656, | | | 0 | | | , | | | "id": "00000000-0000-4000-8000-00000000000c", | | | "name": "Append row in sheet", | | | "credentials": { | | | "googleSheetsOAuth2Api": { | | | "id": "IcH4RIhPDvHIc18q", | | | "name": "Credential 8" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "documentId": { | | | " rl": true, | | | "value": "6ctDXv-ydPvbmefhKWAKM6DgJE2h4H7ZaxoyYZExcugY", | | | "mode": "list", | | | "cachedResultName": "Resource 1", | | | "cachedResultUrl": "https://example3.com" | | | }, | | | "sheetName": { | | | " rl": true, | | | "value": "zgk=4", | | | "mode": "list", | | | "cachedResultName": "Resource 2", | | | "cachedResultUrl": "https://example4.com" | | | }, | | | "options": {} | | | }, | | | "type": "n8n-nodes-base.googleSheets", | | | "typeVersion": 4.7, | | | "position": | | | -336, | | | 480 | | | , | | | "id": "00000000-0000-4000-8000-00000000000d", | | | "name": "Get row s in sheet", | | | "credentials": { | | | "googleSheetsOAuth2Api": { | | | "id": "IcH4RIhPDvHIc18q", | | | "name": "Credential 8" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "conditions": { | | | "options": { | | | "caseSensitive": true, | | | "leftValue": "", | | | "typeValidation": "strict", | | | "version": 2 | | | }, | | | "conditions": | | | { | | | "id": "00000000-0000-4000-8000-00000000000e", | | | "leftValue": "", | | | "rightValue": "", | | | "operator": { | | | "type": "string", | | | "operation": "equals", | | | "name": "filter.operator.equals" | | | } | | | } | | | , | | | "combinator": "and" | | | }, | | | "options": {} | | | }, | | | "type": "n8n-nodes-base.if", | | | "typeVersion": 2.2, | | | "position": | | | -128, | | | 480 | | | , | | | "id": "00000000-0000-4000-8000-00000000000f", | | | "name": "If1" | | | }, | | | { | | | "parameters": { | | | "options": {} | | | }, | | | "type": "@n8n/n8n-nodes-langchain.agent", | | | "typeVersion": 3, | | | "position": | | | 96, | | | 464 | | | , | | | "id": "00000000-0000-4000-8000-000000000010", | | | "name": "AI Agent2" | | | }, | | | { | | | "parameters": { | | | "model": { | | | " rl": true, | | | "mode": "list", | | | "value": "ism-0.3-sibt" | | | }, | | | "builtInTools": {}, | | | "options": {} | | | }, | | | "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", | | | "typeVersion": 1.3, | | | "position": | | | 32, | | | 672 | | | , | | | "id": "00000000-0000-4000-8000-000000000011", | | | "name": "OpenAI Chat Model1", | | | "credentials": { | | | "openAiApi": { | | | "id": "zgkMBu6y37xIBaha", | | | "name": "Credential 4" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "operation": "get", | | | "documentURL": "https://example2.com", | | | "simple": false | | | }, | | | "type": "n8n-nodes-base.googleDocsTool", | | | "typeVersion": 2, | | | "position": | | | 400, | | | 704 | | | , | | | "id": "00000000-0000-4000-8000-000000000012", | | | "name": "Get a document in Google Docs2", | | | "credentials": { | | | "googleDocsOAuth2Api": { | | | "id": "QHaaEBq7E7RN3t3h", | | | "name": "Credential 6" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "operation": "getAll", | | | "calendar": { | | | " rl": true, | | | "value": "iaodyqlzyv01@bowel.shz", | | | "mode": "list", | | | "cachedResultName": "Resource 3" | | | }, | | | "timeMax": "={{ $now.plus { week: 2 } }}", | | | "options": {} | | | }, | | | "type": "n8n-nodes-base.googleCalendarTool", | | | "typeVersion": 1.3, | | | "position": | | | 192, | | | 688 | | | , | | | "id": "00000000-0000-4000-8000-000000000013", | | | "name": "Get many events in Google Calendar", | | | "credentials": { | | | "googleCalendarOAuth2Api": { | | | "id": "Z8atP5zW2Z6BeBgg", | | | "name": "Credential 10" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "calendar": { | | | " rl": true, | | | "value": "iaodyqlzyv01@bowel.shz", | | | "mode": "list", | | | "cachedResultName": "Resource 3" | | | }, | | | "additionalFields": {} | | | }, | | | "type": "n8n-nodes-base.googleCalendar", | | | "typeVersion": 1.3, | | | "position": | | | 640, | | | 304 | | | , | | | "id": "00000000-0000-4000-8000-000000000014", | | | "name": "Create an event", | | | "credentials": { | | | "googleCalendarOAuth2Api": { | | | "id": "Z8atP5zW2Z6BeBgg", | | | "name": "Credential 10" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "operation": "reply", | | | "messageId": "123", | | | "emailType": "text", | | | "message": "hello", | | | "options": { | | | "appendAttribution": false | | | } | | | }, | | | "type": "n8n-nodes-base.gmail", | | | "typeVersion": 2.1, | | | "position": | | | 640, | | | 464 | | | , | | | "id": "00000000-0000-4000-8000-000000000015", | | | "name": "Reply to a message1", | | | "webhookId": "00000000-0000-4000-8000-000000000016", | | | "credentials": { | | | "gmailOAuth2": { | | | "id": "I6maisIBTmcRqsa2", | | | "name": "Credential 2" | | | } | | | } | | | }, | | | { | | | "parameters": { | | | "operation": "update", | | | "documentId": { | | | " rl": true, | | | "value": "6ctDXv-ydPvbmefhKWAKM6DgJE2h4H7ZaxoyYZExcugY", | | | "mode": "list", | | | "cachedResultName": "Resource 1", | | | "cachedResultUrl": "https://example3.com" | | | }, | | | "sheetName": { | | | " rl": true, | | | "value": "zgk=4", | | | "mode": "list", | | | "cachedResultName": "Resource 2", | | | "cachedResultUrl": "https://example4.com" | | | }, | | | "columns": { | | | "mappingMode": "defineBelow", | | | "value": {}, | | | "matchingColumns": , | | | "schema": | | | { | | | "id": "Name", | | | "displayName": "Name", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Email", | | | "displayName": "Email", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Requested service", | | | "displayName": "Requested service", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Screening questions", | | | "displayName": "Screening questions", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Screening answers", | | | "displayName": "Screening answers", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Urgency classification", | | | "displayName": "Urgency classification", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Appointment date", | | | "displayName": "Appointment date", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Appointment status", | | | "displayName": "Appointment status", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "Summary", | | | "displayName": "Summary", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "string", | | | "canBeUsedToMatch": true | | | }, | | | { | | | "id": "row number", | | | "displayName": "row number", | | | "required": false, | | | "defaultMatch": false, | | | "display": true, | | | "type": "number", | | | "canBeUsedToMatch": true, | | | "readOnly": true, | | | "removed": true | | | } | | | , | | | "attemptToConvertTypes": false, | | | "convertFieldsToString": false | | | }, | | | "options": {} | | | }, | | | "type": "n8n-nodes-base.googleSheets", | | | "typeVersion": 4.7, | | | "position": | | | 640, | | | 640 | | | , | | | "id": "00000000-0000-4000-8000-000000000017", | | | "name": "Update row in sheet", | | | "credentials": { | | | "googleSheetsOAuth2Api": { | | | "id": "IcH4RIhPDvHIc18q", | | | "name": "Credential 8" | | | } | | | } | | | } | | | , | | | "pinData": {}, | | | "connections": { | | | "Gmail Trigger": { | | | "main": | | | | | | { | | | "node": "AI Agent", | | | "type": "main", | | | "index": 0 | | | } | | | | | | | | | }, | | | "OpenAI Chat Model": { | | | "ai languageModel": | | | | | | { | | | "node": "AI Agent", | | | "type": "ai languageModel", | | | "index": 0 | | | }, | | | { | | | "node": "AI Agent1", | | | "type": "ai languageModel", | | | "index": 0 | | | } | | | | | | | | | }, | | | "AI Agent": { | | | "main": | | | | | | { | | | "node": "If", | | | "type": "main", | | | "index": 0 | | | } | | | | | | | | | }, | | | "Get a document in Google Docs": { | | | "ai tool": | | | | | | { | | | "node": "AI Agent1", | | | "type": "ai tool", | | | "index": 0 | | | } | | | | | | | | | }, | | | "Get a document in Google Docs1": { | | | "ai tool": | | | | | | { | | | "node": "AI Agent1", | | | "type": "ai tool", | | | "index": 0 | | | } | | | | | | | | | }, | | | "AI Agent1": { | | | "main": | | | | | | { | | | "node": "Reply to a message", | | | "type": "main", | | | "index": 0 | | | }, | | | { | | | "node": "Append row in sheet", | | | "type": "main", | | | "index": 0 | | | } | | | | | | | | | }, | | | "Reply to a message": { | | | "main": | | | | | | | | | }, | | | "If": { | | | "main": | | | | | | { | | | "node": "AI Agent1", | | | "type": "main", | | | "index": 0 | | | } | | | | | | | | | }, | | | "Gmail Trigger1": { | | | "main": | | | | | | { | | | "node": "Get row s in sheet", | | | "type": "main", | | | "index": 0 | | | } | | | | | | | | | }, | | | "Get row s in sheet": { | | | "main": | | | | | | { | | | "node": "If1", | | | "type": "main", | | | "index": 0 | | | } | | | | | | | | | }, | | | "If1": { | | | "main": | | | | | | { | | | "node": "AI Agent2", | | | "type": "main", | | | "index": 0 | | | } | | | | | | | | | }, | | | "OpenAI Chat Model1": { | | | "ai languageModel": | | | | | | { | | | "node": "AI Agent2", | | | "type": "ai languageModel", | | | "index": 0 | | | } | | | | | | | | | }, | | | "Get a document in Google Docs2": { | | | "ai tool": | | | | | | { | | | "node": "AI Agent2", | | | "type": "ai tool", | | | "index": 0 | | | } | | | | | | | | | }, | | | "Get many events in Google Calendar": { | | | "ai tool": | | | | | | { | | | "node": "AI Agent2", | | | "type": "ai tool", | | | "index": 0 | | | } | | | | | | | | | }, | | | "AI Agent2": { | | | "main": | | | | | | { | | | "node": "Create an event", | | | "type": "main", | | | "index": 0 | | | }, | | | { | | | "node": "Reply to a message1", | | | "type": "main", | | | "index": 0 | | | }, | | | { | | | "node": "Update row in sheet", | | | "type": "main", | | | "index": 0 | | | } | | | | | | | | | } | | | }, | | | "active": false, | | | "settings": { | | | "executionOrder": "v1" | | | }, | | | "versionId": "00000000-0000-4000-8000-000000000018", | | | "meta": { | | | "templateCredsSetupCompleted": true, | | | "instanceId": "4fc5719bc60806f0dfde66e924470404ffddf1c7eb9003e245b82be1de253217" | | | }, | | | "id": "3UWCPRPxo0JMV0V7", | | | "tags": | | | } |