Skip to content

Instantly share code, notes, and snippets.

@luisgradossalinas
Last active December 23, 2025 20:42
Show Gist options
  • Select an option

  • Save luisgradossalinas/a865facdb8f0918cb1cd6bb170a95ae0 to your computer and use it in GitHub Desktop.

Select an option

Save luisgradossalinas/a865facdb8f0918cb1cd6bb170a95ae0 to your computer and use it in GitHub Desktop.
{
"name": "Monitoring of bank transactions",
"nodes": [
{
"parameters": {
"modelId": {
"__rl": true,
"value": "gpt-5-mini",
"mode": "list",
"cachedResultName": "GPT-5-MINI"
},
"messages": {
"values": [
{
"content": "=Eres un asistente experto en extraer información en formato JSON de correos electrónicos bancarios.",
"role": "system"
},
{
"content": "=Extrae los siguientes datos en formato JSON campos a obtener: id_operacion, fecha_hora (en formato 2024-24-12 09:09:09), monto, tipo_moneda (solo debe ir Soles si es s/ o Dólares si es $), tarjeta (Si termina en 3333 debes poner Juan Pérez y si termina en 5555 debes poner Adicional), empresa, operacion_realizada y category (Transporte 🚆, Alimentos 🍔, Compras 🛍️, Tecnología 💻, Servicios 🛎️, Alojamiento 🏨, Turismo 🗺️, Educación 📚, Salud 🩺, Finanzas 💳. Solo elige una categoría con su emoticón). Contenido del correo : \n{{ $('Get messages').item.json.text }}"
}
]
},
"jsonOutput": true,
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.8,
"position": [
-640,
-64
],
"id": "dce9b645-827f-4ec3-99e5-077f6b96e9d6",
"name": "Generate output json",
"credentials": {
"openAiApi": {
"id": "RVNvx8wVppulw0S2",
"name": "OpenAI - n8n"
}
}
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 2
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.3,
"position": [
-1088,
-64
],
"id": "45dc2086-59d3-4f24-9338-97c0f7f98d82",
"name": "Schedule Trigger"
},
{
"parameters": {
"sendTo": "tucorreo@gmail.com",
"subject": "[Operación igual o mayor a 500]",
"message": "=Revisar operación del BCP {{ $json['ID Operación'] }} de {{ $json.Monto }} (moneda {{ $json.Moneda }}), tipo de operación : {{ $json['Operación realizada'] }}. Fecha : {{ $json['Fecha y hora'] }}, empresa ({{ $json.Empresa }}) tarjeta ({{ $('Generate output json').item.json.message.content.tarjeta }})",
"options": {
"appendAttribution": false,
"senderName": "Alert pay"
}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
400,
-160
],
"id": "9dd00f17-c266-4b61-abe1-cab8f130f4ca",
"name": "Send a message",
"webhookId": "972c8766-982a-45d9-b01e-d637519a0bbd",
"credentials": {
"gmailOAuth2": {
"id": "bDpYXp9wpYt8b7dm",
"name": "Gmail account - tucorreo@gmail.com"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "a0585364-4d6d-4184-8eb7-ef0545ae1e7a",
"name": "id_operacion",
"value": "={{ $json.message.content.id_operacion }}",
"type": "string"
},
{
"id": "96416229-50bc-4f5f-91ea-90dbf714912b",
"name": "fecha_hora",
"value": "={{ $json.message.content.fecha_hora }}",
"type": "string"
},
{
"id": "df47c2d1-010a-41ff-9ff2-6d00b5a9f382",
"name": "monto",
"value": "={{ $json.message.content.monto }}",
"type": "number"
},
{
"id": "16d9894c-590a-43c0-ab57-f4dc10b91da7",
"name": "tipo_moneda",
"value": "={{ $json.message.content.tipo_moneda }}",
"type": "string"
},
{
"id": "c3ec823c-a0a6-43da-a1a4-beb7a718c3c9",
"name": "tarjeta",
"value": "={{ $json.message.content.tarjeta }}",
"type": "string"
},
{
"id": "0ee37f08-e671-4fae-b160-3398dafab90c",
"name": "empresa",
"value": "={{ $json.message.content.empresa }}",
"type": "string"
},
{
"id": "af3cca2f-03dd-4dde-b75c-bdb96dc4e85c",
"name": "operacion_realizada",
"value": "={{ $json.message.content.operacion_realizada }}",
"type": "string"
},
{
"id": "e2f14fd7-8d1b-446b-8ed4-84f518dae708",
"name": "category",
"value": "={{ $json.message.content.category }}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-288,
-64
],
"id": "817fd9a0-3c61-4e0b-85d2-f5de534ec85c",
"name": "Edit Fields"
},
{
"parameters": {
"operation": "getAll",
"limit": 5,
"simple": false,
"filters": {
"q": "from:notificaciones@notificacionesbcp.com.pe AND is:unread"
},
"options": {}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
-864,
-64
],
"id": "24a896f2-aec3-4331-82be-e1eecf5ab8fc",
"name": "Get messages",
"webhookId": "14ee1a9d-af57-4b03-aa48-ce7356016dea",
"credentials": {
"gmailOAuth2": {
"id": "bDpYXp9wpYt8b7dm",
"name": "Gmail account"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "278f70df-7f55-49a3-b2e5-a87bddb37c72",
"leftValue": "={{ $json.Monto }}",
"rightValue": 500,
"operator": {
"type": "number",
"operation": "gte"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
192,
-144
],
"id": "727b0a1b-e081-4dd0-922c-616bf4338578",
"name": "If >= 500"
},
{
"parameters": {
"operation": "markAsRead",
"messageId": "={{ $('Get messages').item.json.id }}"
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
192,
0
],
"id": "ab14fcfa-64f3-4263-bb4c-956b6750a000",
"name": "Mark message as read",
"webhookId": "6bea638a-9936-4c8e-905f-56789d4a45ca",
"credentials": {
"gmailOAuth2": {
"id": "bDpYXp9wpYt8b7dm",
"name": "Gmail account - tucorreo@gmail.com"
}
}
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"value": "1JgETOp81UhjBajc-JrWxeh9C_ksL6ZdmmkvQ4atUPqM",
"mode": "list",
"cachedResultName": "PagosTCMake",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JgETOp81UhjBajc-JrWxeh9C_ksL6ZdmmkvQ4atUDqM/edit?usp=drivesdk"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Hoja 1",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JgETOp81UhjBajc-JrWxeh9C_ksL6ZdmmkvQ4atUDqM/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"ID Operación": "={{ $json.id_operacion }}",
"Fecha y hora": "={{ $json.fecha_hora }}",
"Monto": "={{ $json.monto }}",
"Moneda": "={{ $json.tipo_moneda }}",
"Tarjeta": "={{ $json.tarjeta }}",
"Empresa": "={{ $json.empresa }}",
"Categoría": "={{ $json.category }}",
"Operación realizada": "={{ $json.operacion_realizada }}",
"Fecha ingesta": "={{ $now.setZone('UTC-5').toFormat('dd-MM-yyyy HH:mm:ss') }}"
},
"matchingColumns": [],
"schema": [
{
"id": "ID Operación",
"displayName": "ID Operación",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Fecha y hora",
"displayName": "Fecha y hora",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Monto",
"displayName": "Monto",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Moneda",
"displayName": "Moneda",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Tarjeta",
"displayName": "Tarjeta",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Empresa",
"displayName": "Empresa",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Operación realizada",
"displayName": "Operación realizada",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Fecha ingesta",
"displayName": "Fecha ingesta",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Categoría",
"displayName": "Categoría",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
-64,
-64
],
"id": "a4d11b89-df91-4714-b8df-3d9cc2e8ee63",
"name": "Add transaction",
"credentials": {
"googleSheetsOAuth2Api": {
"id": "4rIOp5fkT4DoJbTC",
"name": "GoogleSheets"
}
}
},
{
"parameters": {
"content": "## Recupera mensajes de GMAIL (Filtro específico)",
"height": 304,
"width": 464
},
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-1152,
-160
],
"id": "fe368909-af0f-4e91-a99e-c8bb25c146df",
"name": "Sticky Note"
},
{
"parameters": {
"content": "## Lee mensaje y genera JSON (id operación, monto, moneda, etc)",
"height": 304,
"width": 512,
"color": 5
},
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-656,
-160
],
"id": "0185721f-c848-42a8-a35d-8bd3149a103c",
"name": "Sticky Note1"
},
{
"parameters": {
"content": "## Añade fila en Google Sheet",
"height": 304,
"width": 224,
"color": 4
},
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-128,
-160
],
"id": "8e34259f-fbcb-434a-9b4d-b5c8c7657989",
"name": "Sticky Note2"
},
{
"parameters": {
"content": "## Envía mensaje si el monto es mayor o igual a 500.\nSe marca como leído el mensaje de correo para no procesarlo nuevamente.",
"height": 416,
"width": 480,
"color": 3
},
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
112,
-272
],
"id": "66a337b6-e807-4e4d-a22c-1c53bb4197d9",
"name": "Sticky Note3"
},
{
"parameters": {
"content": "## 👋 ¡Gracias por revisar este flujo!\n### 🔗 Contacto\n- 💼 **LinkedIn:** https://www.linkedin.com/in/luisgrados\n- 💻 **GitHub:** https://github.com/luisgradossalinas\n---\n### ⭐ ¿Te sirvió este flujo?\nSi te ayudó o te dio ideas:\n- Compártelo con tu equipo o la comunidad\n- Duplicalo y adáptalo a tus propios casos\n- Déjame feedback o mejoras 🙌\n\n¡La automatización crece cuando se comparte!",
"height": 304,
"width": 464,
"color": 2
},
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-1152,
160
],
"id": "60b3fcf0-f5ac-4238-850c-c1151ea38f96",
"name": "Sticky Note4"
}
],
"pinData": {},
"connections": {
"Schedule Trigger": {
"main": [
[
{
"node": "Get messages",
"type": "main",
"index": 0
}
]
]
},
"Generate output json": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Add transaction",
"type": "main",
"index": 0
}
]
]
},
"Get messages": {
"main": [
[
{
"node": "Generate output json",
"type": "main",
"index": 0
}
]
]
},
"If >= 500": {
"main": [
[
{
"node": "Send a message",
"type": "main",
"index": 0
}
]
]
},
"Send a message": {
"main": [
[]
]
},
"Mark message as read": {
"main": [
[]
]
},
"Add transaction": {
"main": [
[
{
"node": "If >= 500",
"type": "main",
"index": 0
},
{
"node": "Mark message as read",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"versionId": "e5576c01-fb5a-4123-8706-73ce7eff9743",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "fa104beae187f6025d070818c1e1654b5d4dd3a936e247a980ab1fc495bb7af8"
},
"id": "icetcjQ1xLekRirz",
"tags": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment