{ "name": "My workflow 12", "nodes": [ { "parameters": { "pollTimes": { "item": [ { "mode": "everyMinute" } ] }, "filters": {} }, "type": "n8n-nodes-base.gmailTrigger", "typeVersion": 1.3, "position": [ -128, 288 ], "id": "11c51fca-c2ae-4c9e-b0e6-a9675b89523d", "name": "Gmail Trigger", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "inputText": "=Subject : {{ $json.Subject }}\nemail body : {{ $json.snippet }}", "categories": { "categories": [ { "category": "Receipt", "description": "Any email containing a receipt" }, { "category": "Promotion", "description": "Promotion & ad emails " }, { "category": "Business ", "description": "Any sale opportunity email" }, { "category": "Personal", "description": "Emails from friends or family" }, { "category": "Miscalleneous ", "description": "Anything other than the Category above" } ] }, "options": { "enableAutoFixing": true } }, "type": "@n8n/n8n-nodes-langchain.textClassifier", "typeVersion": 1.1, "position": [ 96, 288 ], "id": "3897241c-bcde-4ad0-9c3d-c125cd21fdbd", "name": "Text Classifier" }, { "parameters": { "model": { "__rl": true, "mode": "list", "value": "gpt-4.1-mini" }, "builtInTools": {}, "options": {} }, "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "typeVersion": 1.3, "position": [ 168, 608 ], "id": "24d789e4-21ff-4ea1-84bf-a1f8839910c9", "name": "OpenAI Chat Model", "credentials": { "openAiApi": { "id": "k9LlgnkWoOMbNkRw", "name": "OpenAi account 5" } } }, { "parameters": { "operation": "addLabels", "messageId": "={{ $json.id }}", "labelIds": [ "Label_7505686583535714281" ] }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 448, 672 ], "id": "53323184-e912-41ff-a65c-8351074a6e49", "name": "Miscellaneous", "webhookId": "a7b7280c-262f-47fe-9adf-b2b6c24b148f", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "operation": "addLabels", "messageId": "={{ $json.id }}", "labelIds": [ "Label_6120533101455061651" ] }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 448, 96 ], "id": "94785275-789a-49b8-a335-52fb40fde9be", "name": "Business", "webhookId": "a7b7280c-262f-47fe-9adf-b2b6c24b148f", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "operation": "addLabels", "messageId": "={{ $json.id }}", "labelIds": [ "Label_8974299204510970049" ] }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 448, -96 ], "id": "0d4d9de4-a1e1-4d19-abce-c824ec27c2ce", "name": "Receipt", "webhookId": "a7b7280c-262f-47fe-9adf-b2b6c24b148f", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "operation": "addLabels", "messageId": "={{ $json.id }}", "labelIds": [ "Label_5732974103807708409" ] }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 448, 480 ], "id": "d17f5de5-d711-4ecb-8df0-fdabacd980c1", "name": "Personal", "webhookId": "a7b7280c-262f-47fe-9adf-b2b6c24b148f", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "operation": "addLabels", "messageId": "={{ $json.id }}", "labelIds": [ "Label_5763728656937256152" ] }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 448, 288 ], "id": "8514aaae-b856-4292-ba3a-11590669fd6b", "name": "Promotion", "webhookId": "a7b7280c-262f-47fe-9adf-b2b6c24b148f", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "operation": "append", "documentId": { "__rl": true, "value": "1TMvwb8AFLEhvcaIoo0qdYyWhqY3QgVFwQPfIKMwfuG4", "mode": "list", "cachedResultName": "Receipts ", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TMvwb8AFLEhvcaIoo0qdYyWhqY3QgVFwQPfIKMwfuG4/edit?usp=drivesdk" }, "sheetName": { "__rl": true, "value": "gid=0", "mode": "list", "cachedResultName": "Invoices", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TMvwb8AFLEhvcaIoo0qdYyWhqY3QgVFwQPfIKMwfuG4/edit#gid=0" }, "columns": { "mappingMode": "defineBelow", "value": { "ID": "={{ $json.output.receipt.receipt_id }}", "Date": "={{ $json.output.receipt.date }}", "Time": "={{ $json.output.receipt.time }}", "Value": "={{ $json.output.receipt.items[0].description }}", "Price HT": "={{ $json.output.receipt.payment_details.paid_amount }}" }, "matchingColumns": [], "schema": [ { "id": "ID", "displayName": "ID", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "Date", "displayName": "Date", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "Time", "displayName": "Time", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "Value", "displayName": "Value", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "Price HT", "displayName": "Price HT", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true } ], "attemptToConvertTypes": false, "convertFieldsToString": false }, "options": {} }, "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.7, "position": [ 1248, -96 ], "id": "e41d8d59-25ff-44f5-a3c2-970976a77d99", "name": "Append row in sheet", "credentials": { "googleSheetsOAuth2Api": { "id": "T6R5MYFmKR8onpeW", "name": "Google Sheets account 3" } } }, { "parameters": { "model": { "__rl": true, "mode": "list", "value": "gpt-4.1-mini" }, "builtInTools": {}, "options": {} }, "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "typeVersion": 1.3, "position": [ 904, 128 ], "id": "95202db3-d144-41e4-97a5-012a99c0f5d9", "name": "OpenAI Chat Model1", "credentials": { "openAiApi": { "id": "k9LlgnkWoOMbNkRw", "name": "OpenAi account 5" } } }, { "parameters": { "jsonSchemaExample": "{\n\n \"receipt\": {\n\n \"receipt_id\": \"RCPT-2026-0001\",\n\n \"date\": \"2026-01-02\",\n\n \"time\": \"14:05:00\",\n\n \"currency\": \"USD\",\n\n \"payment_method\": \"Card\",\n\n \"status\": \"Paid\",\n\n \"seller\": {\n\n \"name\": \"Example Store\",\n\n \"address\": \"123 Main Street, Casablanca, Morocco\",\n\n \"phone\": \"+212 600 000 000\",\n\n \"email\": \"contact@examplestore.ma\",\n\n \"tax_id\": \"ICE123456789\"\n\n },\n\n \"customer\": {\n\n \"name\": \"John Doe\",\n\n \"phone\": \"+212 611 111 111\",\n\n \"email\": \"john.doe@email.com\"\n\n },\n\n \"items\": [\n\n {\n\n \"item_id\": \"SKU-001\",\n\n \"description\": \"Wireless Mouse\",\n\n \"quantity\": 1,\n\n \"unit_price\": 150.00,\n\n \"total_price\": 150.00\n\n },\n\n {\n\n \"item_id\": \"SKU-002\",\n\n \"description\": \"Keyboard\",\n\n \"quantity\": 1,\n\n \"unit_price\": 250.00,\n\n \"total_price\": 250.00\n\n }\n\n ],\n\n \"subtotal\": 400.00,\n\n \"tax\": {\n\n \"rate\": 0.20,\n\n \"amount\": 80.00\n\n },\n\n \"discount\": {\n\n \"description\": \"New Year Promo\",\n\n \"amount\": 20.00\n\n },\n\n \"total_amount\": 460.00,\n\n \"payment_details\": {\n\n \"transaction_id\": \"TXN-987654321\",\n\n \"paid_amount\": 460.00,\n\n \"change\": 0.00\n\n },\n\n \"notes\": \"Thank you for your purchase!\"\n\n }\n\n}" }, "type": "@n8n/n8n-nodes-langchain.outputParserStructured", "typeVersion": 1.3, "position": [ 1032, 128 ], "id": "fa6dfb60-a3c1-4a62-9d54-ccf46987c9b4", "name": "Structured Output Parser" }, { "parameters": { "sendTo": "zohair.wakif@gmail.com", "subject": "={{ $('Text Classifier').item.json.Subject }}", "emailType": "text", "message": "={{ $('Text Classifier').item.json.snippet }}", "options": { "appendAttribution": false } }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 672, 96 ], "id": "db524f66-ade7-41ed-84f8-72714f8d68fe", "name": "Personal Gmail", "webhookId": "8a8438ff-466a-4289-a58b-f4d557031584", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "operation": "delete", "messageId": "={{ $json.id }}" }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 672, 288 ], "id": "480cf160-e089-428d-8d1c-4716cfdc35a2", "name": "Delete a message", "webhookId": "c6c106d0-f646-4914-9db0-c533f69b9cf2", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "model": { "__rl": true, "mode": "list", "value": "gpt-4.1-mini" }, "builtInTools": {}, "options": {} }, "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "typeVersion": 1.3, "position": [ 968, 704 ], "id": "fb30be29-5a28-46b5-a3ec-43e4758a4d5f", "name": "OpenAI Chat Model2", "credentials": { "openAiApi": { "id": "k9LlgnkWoOMbNkRw", "name": "OpenAi account 5" } } }, { "parameters": { "operation": "reply", "messageId": "={{ $('Get message').item.json.id }}", "emailType": "text", "message": "={{ $json.output }}", "options": {} }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 1248, 480 ], "id": "ecffa2b9-29ba-424b-8354-1f6128afd7cd", "name": "Reply to a message", "webhookId": "d19b0dfb-16a9-4a08-a6bf-ead49b659887", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "operation": "get", "messageId": "={{ $json.id }}" }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 672, -96 ], "id": "8fd91644-edf2-4b1d-ac2b-6d09569a3d6d", "name": "Get Receipt Data", "webhookId": "667a981c-5ab2-437f-a071-29fc4c09e408", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "promptType": "define", "text": "={{ $json.snippet }}", "hasOutputParser": true, "options": {} }, "type": "@n8n/n8n-nodes-langchain.agent", "typeVersion": 3.1, "position": [ 896, -96 ], "id": "3bf1a957-569e-47c4-9f8c-a46ee0d9be44", "name": "Process Receipt" }, { "parameters": { "operation": "get", "messageId": "={{ $json.id }}" }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 672, 480 ], "id": "ac264967-aac7-4879-b903-3b03a489e364", "name": "Get message", "webhookId": "667a981c-5ab2-437f-a071-29fc4c09e408", "credentials": { "gmailOAuth2": { "id": "bOnpeJGN3cLhC0TN", "name": "Gmail account 7" } } }, { "parameters": { "promptType": "define", "text": "={{ $json.snippet }}", "options": { "systemMessage": "=You are a helpful assistant.\n\nPlease Answer my Friends & Family withi this message:\n\n\"Hey feel free to contact me on this email : zohair.wakif@gmail.com \" \n\nOnly Answer with this \"Hey feel free to contact me on this email : zohair.wakif@gmail.com \" Don't add anything else !!" } }, "type": "@n8n/n8n-nodes-langchain.agent", "typeVersion": 3.1, "position": [ 896, 480 ], "id": "7611006c-7338-4b02-a180-54d99893f786", "name": "Reply to Personal" } ], "pinData": {}, "connections": { "Gmail Trigger": { "main": [ [ { "node": "Text Classifier", "type": "main", "index": 0 } ] ] }, "OpenAI Chat Model": { "ai_languageModel": [ [ { "node": "Text Classifier", "type": "ai_languageModel", "index": 0 } ] ] }, "Text Classifier": { "main": [ [ { "node": "Receipt", "type": "main", "index": 0 } ], [ { "node": "Promotion", "type": "main", "index": 0 } ], [ { "node": "Business", "type": "main", "index": 0 } ], [ { "node": "Personal", "type": "main", "index": 0 } ], [ { "node": "Miscellaneous", "type": "main", "index": 0 } ] ] }, "Business": { "main": [ [ { "node": "Personal Gmail", "type": "main", "index": 0 } ] ] }, "Receipt": { "main": [ [ { "node": "Get Receipt Data", "type": "main", "index": 0 } ] ] }, "OpenAI Chat Model1": { "ai_languageModel": [ [ { "node": "Process Receipt", "type": "ai_languageModel", "index": 0 } ] ] }, "Structured Output Parser": { "ai_outputParser": [ [ { "node": "Process Receipt", "type": "ai_outputParser", "index": 0 } ] ] }, "Personal": { "main": [ [ { "node": "Get message", "type": "main", "index": 0 } ] ] }, "Promotion": { "main": [ [ { "node": "Delete a message", "type": "main", "index": 0 } ] ] }, "OpenAI Chat Model2": { "ai_languageModel": [ [ { "node": "Reply to Personal", "type": "ai_languageModel", "index": 0 } ] ] }, "Get Receipt Data": { "main": [ [ { "node": "Process Receipt", "type": "main", "index": 0 } ] ] }, "Process Receipt": { "main": [ [ { "node": "Append row in sheet", "type": "main", "index": 0 } ] ] }, "Get message": { "main": [ [ { "node": "Reply to Personal", "type": "main", "index": 0 } ] ] }, "Reply to Personal": { "main": [ [ { "node": "Reply to a message", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": { "executionOrder": "v1", "availableInMCP": false }, "versionId": "10d02326-4765-4737-925c-871a419af4c8", "meta": { "templateCredsSetupCompleted": true, "instanceId": "23830929e6c018b604abb710d12ca57ce411c63a552f9a21234ab1d153211b0b" }, "id": "OuET3J_ICyNujDJKGwYUo", "tags": [] }