Skip to content

Instantly share code, notes, and snippets.

@e3e6
Created April 21, 2026 11:58
Show Gist options
  • Select an option

  • Save e3e6/836a7904083b73b35f7444b005907cd9 to your computer and use it in GitHub Desktop.

Select an option

Save e3e6/836a7904083b73b35f7444b005907cd9 to your computer and use it in GitHub Desktop.
workflow_help
{
"nodes": [
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const subject = $json.subject || \"\";\nconst from = $json.from || \"\";\nconst text = ($json.body || \"\").slice(0, 500);\n\n$json.llm_input = `\nSubject: ${subject}\n\nFrom: ${from}\n\nText: ${text}\n`;\n\nreturn $input.item;"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1216,
-64
],
"id": "d1878425-0f54-4f6b-9c2c-52ae366f3b16",
"name": "LLM Classificator prep"
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.llm_input }}",
"options": {
"systemMessage": "Classify this email into exactly one category:\n\n[order, shipping, invoice, auth, personal, marketing, spam, other]\n\nRules:\n- order: purchase confirmations\n- shipping: delivery/tracking updates\n- invoice: bills, receipts\n- auth: OTP, verification codes\n- marketing: promotions, newsletters\n- personal: human-written emails\n\nReturn ONLY the category."
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
1392,
-64
],
"id": "3ae7fcda-117a-44ce-80d0-7948fb8b3ce0",
"name": "AI Agent1",
"alwaysOutputData": true
},
{
"parameters": {
"modelName": "models/gemini-2.5-flash-lite",
"options": {
"maxOutputTokens": 10
}
},
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"typeVersion": 1,
"position": [
1392,
112
],
"id": "a00f6711-d8d6-4a98-9066-9bef6ae95f41",
"name": "Google Gemini Chat Model",
"credentials": {
"googlePalmApi": {
"id": "S0ePuEI4dAlHzvQb",
"name": "Google Gemini(PaLM) Api account"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "a1ac1525-47e5-46e2-9aff-ad5551c7f946",
"leftValue": "={{ $json.skip_llm }}",
"rightValue": false,
"operator": {
"type": "boolean",
"operation": "exists",
"singleValue": true
}
},
{
"id": "27a4bf22-88a9-4da4-b941-c5e5273e695c",
"leftValue": "={{ $json.skip_llm }}",
"rightValue": false,
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
1024,
-272
],
"id": "d85d2df9-9c29-4d79-865a-c1145af1f1ed",
"name": "skip_llm"
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "\n$json.skip_llm = false;\nif (/unsubscribe|newsletter|promo/i.test($json.subject)) {\n $json.category = \"marketing\";\n $json.skip_llm = true;\n}\n\nreturn $input.item;"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
784,
-272
],
"id": "8de41d77-8941-4b8e-b328-48cc0b788ee8",
"name": "Skip LLM"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "f5b6ee1e-d2b5-43cd-92cd-2f3fdecad6cd",
"name": "category",
"value": "={{ $json.output }}",
"type": "string"
},
{
"id": "f3946576-6096-44aa-b945-5acaf787b3af",
"name": "body",
"value": "={{ $('skip_llm').item.json.body }}",
"type": "string"
},
{
"id": "3eb0d414-7110-4c0f-ae82-c797e1ab9618",
"name": "subject",
"value": "={{ $('skip_llm').item.json.subject }}",
"type": "string"
},
{
"id": "777ad728-a9f2-4aaa-8c2f-ccec2c569d82",
"name": "skip_llm",
"value": "={{ $('skip_llm').item.json.skip_llm }}",
"type": "boolean"
}
]
},
"includeOtherFields": true,
"include": "selected",
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
1792,
-64
],
"id": "913e7dbc-3c71-455d-a66c-62b5111adedc",
"name": "LLM Output Normalize"
},
{
"parameters": {},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.2,
"position": [
1968,
-240
],
"id": "8d3a1982-54c0-4db6-8904-beb62461ea64",
"name": "Merge"
},
{
"parameters": {
"content": "- body\n- subject\n- body_trimmed\n- body_cleaned\n- skip_llm\n- category",
"width": 150
},
"type": "n8n-nodes-base.stickyNote",
"position": [
880,
-176
],
"typeVersion": 1,
"id": "3d321af1-a70e-4c48-ae07-19c2155f7991",
"name": "Sticky Note1"
},
{
"parameters": {
"content": "- output",
"height": 96,
"width": 150
},
"type": "n8n-nodes-base.stickyNote",
"position": [
1632,
32
],
"typeVersion": 1,
"id": "13e7e04c-118c-418d-b119-38221e008e9e",
"name": "Sticky Note5"
}
],
"connections": {
"LLM Classificator prep": {
"main": [
[
{
"node": "AI Agent1",
"type": "main",
"index": 0
}
]
]
},
"AI Agent1": {
"main": [
[
{
"node": "LLM Output Normalize",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent1",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"skip_llm": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
],
[
{
"node": "LLM Classificator prep",
"type": "main",
"index": 0
}
]
]
},
"Skip LLM": {
"main": [
[
{
"node": "skip_llm",
"type": "main",
"index": 0
}
]
]
},
"LLM Output Normalize": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Merge": {
"main": [
[]
]
}
},
"pinData": {
"AI Agent1": [
{
"output": "marketing"
},
{
"output": "shipping"
}
]
},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "7f338e9db951775a07337f33543dfd713ead030abca21a5cfe7d741070d62635"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment