{ "$json": { "updatedAt": "2026-06-08T20:20:56.084Z", "createdAt": "2026-05-28T13:53:39.482Z", "id": "eM8ZZafSC9M8GYd4", "name": "Procesador de facturas VERSION AUDIO", "description": null, "active": false, "isArchived": false, "nodes": [ { "parameters": { "inputDataFieldName": "=data", "name": "=IMG_{{ $('Generar timestamp').item.json.timestamp }}", "driveId": { "__rl": true, "mode": "list", "value": "My Drive" }, "folderId": { "__rl": true, "value": "={{ $('Es imagen?').item.json.invoice_photos_folder_id }}", "mode": "id" }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 2432, 1696 ], "id": "7ccd0408-1cc5-44d1-8466-56fb0b0f0b58", "name": "Upload file", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "httpMethod": "POST", "path": "factura", "options": {} }, "type": "n8n-nodes-base.webhook", "typeVersion": 2.1, "position": [ -3392, 80 ], "id": "d321a666-b8bf-4a20-85b5-bc8dfa8da9ca", "name": "Webhook", "webhookId": "faba6fac-3529-4b9f-a493-fba58427b06a" }, { "parameters": { "content": "## Trigger\n\nRecibe el mensaje enviado al bot", "height": 256, "width": 256 }, "type": "n8n-nodes-base.stickyNote", "position": [ -3456, -16 ], "typeVersion": 1, "id": "ee478bf2-ae8f-495f-8af3-a339692a5fd7", "name": "Sticky Note" }, { "parameters": { "content": "## Es imagen?\n\n- Si el mensaje es una imagen, el flujo sigue y analiza la imagen.\n\n\n- Si el mensaje es un texto, envía una alerta de que por favor envíe una imagen.", "height": 496, "width": 464, "color": 2 }, "type": "n8n-nodes-base.stickyNote", "position": [ 176, 1616 ], "typeVersion": 1, "id": "7891d420-b1e1-4dca-bd0c-af7499d51d28", "name": "Sticky Note1" }, { "parameters": { "rules": { "values": [ { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "leftValue": "={{ $json.output.es_factura_valida }}", "rightValue": true, "operator": { "type": "boolean", "operation": "equals" }, "id": "5465f057-06a0-4f9d-94a4-bfea02c57bbe" } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "ec09d024-f657-4e57-834f-7929ef6030f7", "leftValue": "={{ $json.output.es_factura_valida == false && $json.output.motivo == \"fuera_periodo\" }}", "rightValue": false, "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "39c05f42-36e4-4027-a758-fd7a20608637", "leftValue": "={{ $json.output.es_factura_valida }}", "rightValue": false, "operator": { "type": "boolean", "operation": "equals" } } ], "combinator": "and" } } ] }, "options": {} }, "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ 1296, 1792 ], "id": "6f236c15-ff30-4ecf-9a24-596b020a58c8", "name": "Factura es valida?" }, { "parameters": { "resource": "image", "operation": "analyze", "modelId": { "__rl": true, "value": "models/gemini-3.1-pro-preview", "mode": "list", "cachedResultName": "models/gemini-3.1-pro-preview" }, "text": "=Actúa como un auditor fiscal y extractor de datos especializado en facturación electrónica.\n\nTu tarea es analizar la imagen o documento proporcionado (factura escaneada o fotografía) y determinar si se trata de una FACTURA VÁLIDA emitida a nombre de GomezLee Marketing (GLM).\n\nDebes realizar los siguientes pasos de forma estricta:\n1. Verificación obligatoria\n - Detecta el NIF de GomezLee Marketing (GLM) que aparece en la factura.\n - Normaliza el NIF detectado: elimina guiones y espacios, convierte a mayúsculas.\n - Compara el NIF normalizado contra la lista de NIFs válidos del paso 2.\n - Si el NIF no aparece, no es legible, o no coincide con ningún NIF de la lista,\n marca la factura como: \"Factura no válida para este contribuyente\".\n\n2. Identificación del Número de Identificación Fiscal\n El NIF puede aparecer en el documento bajo los siguientes nombres:\n - RNC, NIT, Cédula Jurídica, RUC, RTN, RFC, TRN, BIR, Tax ID, EIN, NIN\n \n NIFs válidos de GomezLee Marketing (GLM) — normalizados sin guiones ni espacios:\n - Guatemala: 69624046\n - Costa Rica: 3101661108\n - Panamá: 15353441654347DV0\n - Colombia: 9010197681\n - República Dominicana: 101647442\n - Jamaica: 002974762\n - Trinidad: 1000369632\n - Latam: 155687606\n - Puerto Rico: 660784022\n - Honduras: 08019016840977\n - Nicaragua: J0310000356246\n - El Salvador: 06140206161017\n - Ecuador: 1793222609001\n - Mexico: GMA180919EA9\n - Vozez: 155717030\n\n Si el NIF detectado no coincide con ninguno de los anteriores, indica:\n \"Documento sin Número de Identificación Fiscal válido para GLM.\"\n\n3. Extracción estructurada de datos\n Extrae los siguientes campos (si existen, aunque el orden o nombre varíe):\n\n - fecha:\n Fecha de emisión de la factura\n\n - numero_factura:\n Numero de la factura o eNCF\n\n - proveedor:\n Nombre comercial del proveedor o estación\n\n - nif_glm:\n NIF de GomezLee Marketing (GLM) tal como aparece en el documento (sin normalizar)\n\n - gasto_categoria: \n Debes leer los productos en la factura y elegir una categoria de gastos en la lista \n\n - moneda:\n Debes elegir la moneda que se hizo el gasto en la factura\n\n - subtotal:\n Debes poner el total SIN IMPUESTO\n\n - impuesto1_tipo:\n Debes elegir el tipo de impuesto correcto que esta en la factura de la lista de tipos de facturas\n\n - impuesto1_porciento:\n Debes poner % del impuesto\n\n - impuesto1_monto:\n Debes poner el total del primer impuesto\n \n - impuesto2_tipo:\n Debes elegir el tipo de impuesto correcto que esta en la factura de la lista de tipos de facturas\n\n - impuesto2_monto:\n Debes poner el total del segundo impuesto\n\n - total:\n Monto total pagado\n Formato numérico sin texto adicional\n Ejemplo: 2000.00\n\n4. Normalización\n - Elimina símbolos de moneda (RD$, $, pesos, dólares, etc).\n - Convierte comas a formato numérico estándar.\n - Usa punto decimal.\n\n5. Lista de tipo monedas:\n - COP (Peso colombiano)\n - CRC (Colón costarricense)\n - DOP (Peso dominicano)\n - GTQ (Quetzal guatemalteco)\n - HNL (Lempira hondureño)\n - JMD (Dólar jamaiquino)\n - MXN (Peso mexicano)\n - NIO (Córdoba nicaragüense)\n - PAB (Balboa panameño)\n - PEN (Sol peruano)\n - TTD (Dólar de Trinidad y Tobago)\n - USD (Dólar estadounidense)\n\n6. Lista de categorias de gastos que tienes que poner en 'gasto_categoria':\n - Transporte aéreo\n - Transporte terrestre (taxi/Uber/bus)\n - Combustible\n - Peajes y parqueos\n - Hospedaje\n - Alimentación\n - Representación con cliente\n - Telefonía e internet\n - Materiales y suministros\n - Papelería\n - Mensajería / courier\n - Impresión\n - Capacitación\n - Suscripciones software\n - Eventos / activaciones\n - Otros\n\n7. Estos son los tipos de impuestos que tendras que poner en 'impuesto1_tipo' y 'impuesto2_tipo' si son visibles en la factura:\n - ITBIS\n - ITBIS reducido\n - IVA\n - IVA reducido\n - IVA frontera\n - ITBMS\n - ISV\n - IGV\n - IVU estatal\n - IVU municipal\n - VAT\n - GCT\n - GCT turismo\n - ICE\n - IEPS\n - ISC\n - ICA\n - Propina legal\n - Retención ISR\n - Retención fuente\n - Otro\n - Ninguno\n\n8. Si falta un valor en la factura, debes escribir un breve texto en \"motivo\" diciendo que falta en la factura y pon \"es_factura_valida\" como false.\n\n9. Si la fecha de la factura esta afuera de las fechas de periodo de inicio y de finalizacion debes insertar como valor en motivo \"fuera_periodo\", false en es_factura_valida y en fecha la fecha de la factura:\n - Periodo inicio: {{ $('Es imagen?').item.json.context.periodoInicio }}\n - Periodo finalizacion: {{ $('Es imagen?').item.json.context.periodoFinalizacion }}\n\n10. Resultado final\n Devuelve exclusivamente un JSON válido con esta estructura:\n {\n \"es_factura_valida\": true | false,\n \"motivo\": \" | null\",\n \"fecha\": \"string\",\n \"numero_factura\": \"string\", \n \"proveedor\": \"string | null\",\n \"nif_glm\": \"string | null\",\n \"gasto_categoria\": \"string | null\",\n \"moneda\": \"string | null\",\n \"subtotal\": \"string | null\", \n \"impuesto1_tipo\": \"string | null\",\n \"impuesto1_porciento\": \"string | null\",\n \"impuesto1_monto\": \"string | null\",\n \"impuesto2_tipo\": \"string | null\",\n \"impuesto2_monto\": \"string | null\",\n \"total\": \"string | null\"\n }\n\n11. Reglas importantes\n - No inventes datos.\n - Si un campo no se encuentra claramente, colócalo como null y escribe un breve texto en \"motivo\" diciendo que falta en la factura y pon \"es_factura_valida\" como false.\n - No incluyas texto fuera del JSON.\n - No hagas suposiciones si el texto no es legible.\n - No uses bloques de código Markdown. Responde únicamente con el objeto JSON, sin texto adicional antes ni después.\n\nAnaliza cuidadosamente el documento antes de responder.", "inputType": "binary", "binaryPropertyName": "=data", "options": {} }, "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.1, "position": [ 976, 1792 ], "id": "b2c9feb9-026e-4de9-b2e1-85b6f8290cfe", "name": "Analyze an image1", "retryOnFail": true, "waitBetweenTries": 5000, "credentials": { "googlePalmApi": { "id": "tFqBJras00HUi1hA", "name": "Eidan - Google Gemini(PaLM) Api account" } }, "onError": "continueErrorOutput" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "f2be1fb5-b047-4614-a1f2-9a4d65ef5cc7", "leftValue": "={{ $json.body.data.key.remoteJid }}", "rightValue": "=18097159076@s.whatsapp.net", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ -3088, 192 ], "id": "0fc94f6a-2ebd-4c1b-976c-7b17c2939aeb", "name": "Mi numero TESTING" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "d915e557-afce-4d93-9dfc-deaf5f1bbfda", "leftValue": "={{ $('Webhook').item.json.body.data.messageType }}", "rightValue": "=imageMessage", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 192, 1792 ], "id": "147eee37-1ad7-4b84-bd08-1654f49b9f23", "name": "Es imagen?" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/chat/getBase64FromMediaMessage/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "message.key.id", "value": "={{ $('Webhook').item.json.body.data.key.id }}" }, { "name": "convertToMp4", "value": "={{ Boolean(false) }}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 624, 1792 ], "id": "e6bb63d2-fa54-43ba-a27e-0954a92c21c7", "name": "Descargar imagen de whatsapp" }, { "parameters": { "assignments": { "assignments": [ { "id": "93dde7fd-187b-4baa-b769-15b52e58562c", "name": "output", "value": "={{ $json.content.parts[0].text }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 1136, 1792 ], "id": "4ac3b5e6-ef5c-4829-8103-f188e065a1fb", "name": "Edit Fields" }, { "parameters": { "operation": "toBinary", "sourceProperty": "base64", "options": { "mimeType": "={{ $json.mimetype }}" } }, "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ 816, 1792 ], "id": "21f8a9f4-c324-447a-be6a-25f9bd4df407", "name": "Convert to File" }, { "parameters": { "operation": "toBinary", "sourceProperty": "base64", "options": { "mimeType": "={{ $('Descargar imagen de whatsapp').item.json.mimetype }}" } }, "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ 2272, 1696 ], "id": "810c988e-1ffb-438d-8d9b-847f9be60573", "name": "Convert to File1" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=Por favor envia una imagen." }, { "name": "delay", "value": "={{4000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 352, 1936 ], "id": "3257977e-d001-4cde-8074-fe816716097f", "name": "Alerta no es imagen" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "={{ $('Awaiting').item.json.texto }}" }, { "name": "delay", "value": "={{4000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 2432, 2208 ], "id": "ba000b1f-fad7-4e73-bc04-25be882a9b68", "name": "Alerta factura no es valida" }, { "parameters": { "content": "1. Guarda imagen en Google Drive.\n\n\n2. Envía mensaje de confirmación.", "height": 256, "width": 320 }, "type": "n8n-nodes-base.stickyNote", "position": [ 2400, 1584 ], "typeVersion": 1, "id": "1a32fee7-9643-4fa8-9b06-1093bcc98317", "name": "Sticky Note5" }, { "parameters": { "content": "### Descargar otra vez la imagen", "height": 208, "width": 320 }, "type": "n8n-nodes-base.stickyNote", "position": [ 2064, 1632 ], "typeVersion": 1, "id": "54fa0afe-8f9d-4d73-8b9f-8b3cb4c9ed61", "name": "Sticky Note6" }, { "parameters": { "operation": "send", "additionalFields": {} }, "type": "n8n-nodes-base.whatsApp", "typeVersion": 1.1, "position": [ -1536, 896 ], "id": "9d41e847-de54-48ca-b07b-d60a5242c7ce", "name": "Send message", "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", "disabled": true }, { "parameters": { "operation": "sendAndWait", "responseType": "customForm", "formFields": { "values": [ {} ] }, "options": {} }, "type": "n8n-nodes-base.whatsApp", "typeVersion": 1.1, "position": [ -1536, 1056 ], "id": "b98b06af-dc86-423f-bd2e-8c489bf2c990", "name": "Send message and wait for response", "webhookId": "39baf60b-3f56-4349-90aa-1b7ffd15548d", "disabled": true }, { "parameters": { "resource": "media", "operation": "mediaUrlGet" }, "type": "n8n-nodes-base.whatsApp", "typeVersion": 1.1, "position": [ -1264, 1072 ], "id": "84a27682-ff38-4b46-abed-61f44c99b25a", "name": "Download media", "webhookId": "68cf4848-d0a9-4325-995e-4b067eee50ba", "disabled": true }, { "parameters": { "updates": [ "messages" ], "options": {} }, "type": "n8n-nodes-base.whatsAppTrigger", "typeVersion": 1, "position": [ -1536, 1232 ], "id": "04830804-459a-49fa-97ba-1c864641583c", "name": "WhatsApp Trigger", "webhookId": "11875011-47ee-4be7-81d2-f58384918645", "disabled": true }, { "parameters": {}, "type": "n8n-nodes-base.whatsApp", "typeVersion": 1.1, "position": [ -1264, 1232 ], "id": "c1082e16-ef63-4a41-b666-be4875c770ba", "name": "Send template", "webhookId": "73315d8d-e5bd-4b52-b2cd-6f983998a0e3", "disabled": true }, { "parameters": { "documentId": { "__rl": true, "value": "={{ $('Es imagen?').item.json.sheet_id }}", "mode": "id" }, "sheetName": { "__rl": true, "value": 823590345, "mode": "list", "cachedResultName": "Liquidación", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1vaUg4UkhecbyaKlXS3i5lMxR2WGFPuy2wdZ_grkOgKQ/edit#gid=823590345" }, "filtersUI": { "values": [] }, "combineFilters": "OR", "options": { "dataLocationOnSheet": { "values": { "rangeDefinition": "specifyRangeA1", "range": "C17:C47" } } } }, "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.7, "position": [ 1504, 1696 ], "id": "829c288f-8400-47f3-9a22-859d4a5523eb", "name": "Buscar NCF duplicado", "alwaysOutputData": true, "credentials": { "googleSheetsOAuth2Api": { "id": "8Pp0ek3NPsEkyXfY", "name": "Eidan - Google Sheets account" } } }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "dup-check-001", "leftValue": "={{ $json['Nº Factura / NCF / DTE'] }}", "rightValue": "={{ $('Factura es valida?').item.json.output.numero_factura }}", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 1712, 1696 ], "id": "ad928736-a65e-4d3d-a791-b3e061f19ee0", "name": "Es duplicado?" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=⚠️ Esta factura ya fue registrada anteriormente (NCF: {{ $('Edit Fields').item.json.output.numero_factura }}). No se procesará para evitar duplicados." }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1936, 1520 ], "id": "321c0e69-d2cb-49d0-a3bb-f2df98e5f9dd", "name": "Alerta factura duplicada" }, { "parameters": { "content": "## Verificación de duplicados\n\nHace un **Get Rows** filtrando por `eNCF`.\n\n- **Encontró fila** → NCF ya existe → alerta duplicado, detiene el flujo.\n- **No encontró fila** → NCF nuevo → continúa a Drive + Sheet.", "height": 336, "width": 432, "color": 2 }, "type": "n8n-nodes-base.stickyNote", "position": [ 1456, 1504 ], "typeVersion": 1, "id": "b1aea034-8775-44b1-b054-14606a6f9b5d", "name": "Sticky Note Duplicados" }, { "parameters": { "tableId": "user_states", "fieldsUi": { "fieldValues": [ { "fieldId": "phone", "fieldValue": "={{ $json.phone }}" }, { "fieldId": "name", "fieldValue": "={{ $('Numero esta registrado en GLM?').item.json.name }}" }, { "fieldId": "country", "fieldValue": "={{ $('Numero esta registrado en GLM?').item.json.country }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ -1536, 96 ], "id": "7108c70b-9237-414c-b40e-739188698d7d", "name": "Create a row", "alwaysOutputData": false, "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "jsCode": "const phone = $input.first().json.body.data.key.remoteJid;\n\nconst cleanPhone = phone.replace(\"@s.whatsapp.net\", \"\");\n\nreturn [{\n json: {\n cleanPhone: cleanPhone\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -3136, -16 ], "id": "20ccd833-a512-403b-abc5-f6173520f7cf", "name": "Limpiar numero de telefono" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=No encuentro tu número en el sistema. Por favor avisa a asrodriguez@gomezleemarketing.com para registrarlo." }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ -2464, 96 ], "id": "d190a852-6785-4e69-afcb-094f821bfb7e", "name": "Alerta numero no registrado" }, { "parameters": { "content": "## Validar numeros de telefonos de empleados de GLM\n\nSi el numero no está registrado el bot envía este mensaje, \"No encuentro tu número en el sistema. Por favor avisa a asrodriguez@gomezleemarketing.com para registrarlo.\"", "height": 384, "width": 1168, "color": 2 }, "type": "n8n-nodes-base.stickyNote", "position": [ -3168, -128 ], "typeVersion": 1, "id": "2afe000f-fe83-42d6-9ab8-e676cc47253c", "name": "Sticky Note7" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ $('Webhook').item.json.body.data.key.remoteJid }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=Usted no se encuentra activo actualmente en GLM." }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ -2208, 96 ], "id": "0bacaa6f-5d3d-4941-b7d5-6bc30851feaa", "name": "Alerta empleado no activo" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "ac86564e-1b34-49d4-be74-0685297a6f86", "leftValue": "={{ $json.report_id }}", "rightValue": "=", "operator": { "type": "string", "operation": "notEmpty", "singleValue": true } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 32, -816 ], "id": "cc1bf3fc-fbe6-4896-b569-254b9f9eb3a5", "name": "Empleado tiene reporte abierto?" }, { "parameters": { "rules": { "values": [ { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "leftValue": "={{ $json.state }}", "rightValue": "idle", "operator": { "type": "string", "operation": "equals" }, "id": "1943c7ac-0b68-4cdc-9b06-8d0863585a3d" } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "0c1b8e82-e5c9-4215-af60-d47b8651c086", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_tipoReporte", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "162a1533-0fc4-4369-b6bc-41df2d070183", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_answer", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "cce2e1f7-823c-4cb4-8495-bfd9fa276437", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_ruta", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "ac6bacab-fbf1-4e70-8819-7bbe407b1e39", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_anticipoRecibido", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "934cd438-36c1-4011-919b-ea2ba57447bc", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_periodoDesde", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "26f4a522-9d90-4afd-aa18-0d2999d1e74d", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_periodoHasta", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "a083e3ea-9e0f-434d-b491-54969d9f81d8", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_motivo", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "fdfea931-661e-42f0-961b-1bcc9c82755a", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_clienteProyecto", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "e757f670-4cb8-4c1c-b24a-3b053dfc0c68", "leftValue": "={{ $json.state }}", "rightValue": "report_open", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "6a950af5-c3bd-4c6c-bf2f-b1e1e591ae27", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_total", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "922ef0c6-8e77-49f1-aeae-76e7b92445e0", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_proveedor", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "55411414-2c8e-4660-8c51-ba40b9580072", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_nif_glm", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "701b999e-b6f1-4593-9825-37bd1794f186", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_fecha", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "034b15d5-6897-4097-bbae-14824d5d8bd4", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_fechaFuera", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "daa07de3-d0a0-4867-81df-89b79be5c070", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_nuevaFechaPeriodo", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "06290d92-0147-4932-86ba-f3034c27b490", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_close_confirm", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "8e8f7dc2-ecf0-46e9-8b85-8556db397c5d", "leftValue": "={{ $json.state }}", "rightValue": "awaiting_approval", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" } } ] }, "options": {} }, "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ -928, 32 ], "id": "c86e3729-6827-4580-bb09-93cfff9e1eb2", "name": "Switch" }, { "parameters": { "operation": "get", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "keyValue": "={{ $json.phone }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ -1632, -64 ], "id": "07c3dcfd-9d6c-483b-865d-918fc83237aa", "name": "Obtener status", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "operation": "appendOrUpdate", "documentId": { "__rl": true, "value": "1DzUjeikfp8eSdFqEW0LEZZBkn13jI8Uhy15DjGZ2tK4", "mode": "list", "cachedResultName": "Empleados GLM Prueba", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DzUjeikfp8eSdFqEW0LEZZBkn13jI8Uhy15DjGZ2tK4/edit?usp=drivesdk" }, "sheetName": { "__rl": true, "value": "gid=0", "mode": "list", "cachedResultName": "Hoja 1", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DzUjeikfp8eSdFqEW0LEZZBkn13jI8Uhy15DjGZ2tK4/edit#gid=0" }, "columns": { "mappingMode": "defineBelow", "value": { "id": "={{ $json.id }}", "name": "={{ $json.displayName }}", "mobilePhone": "={{ $json.mobilePhone }}", "workPhone": "={{ $json.workPhone }}", "status": "={{ $json.status }}", "cedula": "={{ $json.employeeNumber }}", "supervisor": "={{ $json.supervisor }}", "country": "={{ $json.location }}", "cargo": "={{ $json.jobTitle }}", "supervisorEmail": "={{ $json.supervisorEmail }}", "departamento": "={{ $json.department }}" }, "matchingColumns": [ "id" ], "schema": [ { "id": "id", "displayName": "id", "required": false, "defaultMatch": true, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "name", "displayName": "name", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "mobilePhone", "displayName": "mobilePhone", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "workPhone", "displayName": "workPhone", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "status", "displayName": "status", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "cedula", "displayName": "cedula", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "supervisor", "displayName": "supervisor", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "supervisorEmail", "displayName": "supervisorEmail", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "country", "displayName": "country", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "cargo", "displayName": "cargo", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "departamento", "displayName": "departamento", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false } ], "attemptToConvertTypes": false, "convertFieldsToString": false }, "options": {} }, "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.7, "position": [ -1888, 800 ], "id": "a9f4ea1a-1a98-4010-81a8-452333674893", "name": "Append or update row in sheet1", "credentials": { "googleSheetsOAuth2Api": { "id": "8Pp0ek3NPsEkyXfY", "name": "Eidan - Google Sheets account" } } }, { "parameters": { "rule": { "interval": [ { "triggerAtHour": 2 } ] } }, "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.3, "position": [ -2832, 800 ], "id": "27769474-80ef-4d16-8ec4-ee2d0a9103fa", "name": "Schedule Trigger1" }, { "parameters": { "operation": "getAll", "returnAll": true }, "type": "n8n-nodes-base.bambooHr", "typeVersion": 1, "position": [ -2640, 800 ], "id": "11612dd1-1d3a-4051-9189-fc40522542c4", "name": "BambooHR4", "credentials": { "bambooHrApi": { "id": "VwYITXROyinOC4je", "name": "Eidan - BambooHR account" } } }, { "parameters": { "jsCode": "return $input.all().map(item => {\n let mobilePhone = item.json.mobilePhone;\n let workPhone = item.json.workPhone;\n\n if (mobilePhone) {\n mobilePhone = mobilePhone.replace(/\\D/g, \"\");\n mobilePhone = mobilePhone.slice(-10);\n }\n\n if (workPhone) {\n workPhone = workPhone.replace(/\\D/g, \"\");\n workPhone = workPhone.slice(-10);\n }\n\n return {\n json: {\n ...item.json,\n mobilePhone: mobilePhone,\n workPhone: workPhone\n }\n };\n});" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -2256, 800 ], "id": "2ead17e8-2738-4462-a98f-615a4d1aaa03", "name": "Eliminar extension del numero3" }, { "parameters": { "amount": 10 }, "type": "n8n-nodes-base.wait", "typeVersion": 1.1, "position": [ -2080, 960 ], "id": "718de384-3665-42e3-9998-3b9102b4f5a2", "name": "Wait1", "webhookId": "4f4fdc9f-93d8-43f3-942c-8e2afdda26f2" }, { "parameters": { "batchSize": 100, "options": {} }, "type": "n8n-nodes-base.splitInBatches", "typeVersion": 3, "position": [ -2448, 800 ], "id": "1839ebe9-19ad-4210-a7c2-0517827b47a7", "name": "Loop Over Items2" }, { "parameters": { "jsCode": "return $input.all().map(item => {\n let supervisor = item.json.supervisor;\n\n if (supervisor && supervisor.includes(\",\")) {\n const [lastName, firstName] = supervisor\n .split(\",\")\n .map(s => s.trim());\n\n supervisor = `${firstName} ${lastName}`;\n }\n\n return {\n json: {\n ...item.json,\n supervisor,\n }\n };\n});" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -2080, 800 ], "id": "38940eea-a953-4b43-bd57-e8c431d1fef6", "name": "Arreglar nombre de supervisor3" }, { "parameters": { "documentId": { "__rl": true, "value": "1DzUjeikfp8eSdFqEW0LEZZBkn13jI8Uhy15DjGZ2tK4", "mode": "list", "cachedResultName": "Empleados GLM Prueba", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DzUjeikfp8eSdFqEW0LEZZBkn13jI8Uhy15DjGZ2tK4/edit?usp=drivesdk" }, "sheetName": { "__rl": true, "value": "gid=0", "mode": "list", "cachedResultName": "Hoja 1", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DzUjeikfp8eSdFqEW0LEZZBkn13jI8Uhy15DjGZ2tK4/edit#gid=0" }, "filtersUI": { "values": [ { "lookupColumn": "mobilePhone", "lookupValue": "={{ $json.phoneNumber }}" }, { "lookupColumn": "workPhone", "lookupValue": "={{ $json.phoneNumber }}" } ] }, "combineFilters": "OR", "options": {} }, "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.7, "position": [ -2784, -16 ], "id": "e88db085-f6a2-4671-aabd-79841fe7cd2a", "name": "Obtener empleados", "credentials": { "googleSheetsOAuth2Api": { "id": "8Pp0ek3NPsEkyXfY", "name": "Eidan - Google Sheets account" } } }, { "parameters": { "jsCode": "return $input.all().map(item => {\n let phoneNumber = item.json.cleanPhone;\n\n if (phoneNumber) {\n phoneNumber = phoneNumber.replace(/\\D/g, \"\");\n phoneNumber = phoneNumber.slice(-10);\n }\n\n return {\n json: {\n ...item.json,\n phoneNumber: phoneNumber\n }\n };\n});" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -2960, -16 ], "id": "c9396923-66c1-461c-af78-9c68b52e6851", "name": "Eliminar extension del numero" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "1d2a6999-7fb8-425f-85c5-b40f5c1299d0", "leftValue": "={{ $json.status }}", "rightValue": "Active", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ -2352, -16 ], "id": "5410d5da-e9b1-40d6-b5f5-45175169ac1c", "name": "El empleado esta activo?" }, { "parameters": { "operation": "get", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "keyValue": "={{ $json.mobilePhone || $json.workPhone }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ -2112, -16 ], "id": "406edede-d423-4123-9b22-a6e20a553cbc", "name": "Get a row", "alwaysOutputData": true, "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "dup-check-001", "leftValue": "={{ Object.keys($json).length }}", "rightValue": 0, "operator": { "type": "number", "operation": "gt" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ -2608, -16 ], "id": "ae81a00e-8b84-4217-9a4d-889d91da9429", "name": "Numero esta registrado en GLM?" }, { "parameters": { "jsCode": "// Datos del webhook (nodo anterior)\nconst phone = $('Eliminar extension del numero').first().json.phoneNumber;\n\n// Datos del nodo con los teléfonos del empleado\nconst mobilePhone = $('Obtener empleados').first().json.mobilePhone;\nconst workPhone = $('Obtener empleados').first().json.workPhone;\n\n// Normalizar: quitar espacios y caracteres no numéricos para comparar\nconst normalize = (num) => String(num).replace(/\\D/g, '').trim();\n\nconst phoneNorm = normalize(phone);\nconst mobileNorm = normalize(mobilePhone);\nconst workNorm = normalize(workPhone);\n\n// Match\nlet matchedField = null;\nlet matchedValue = null;\n\nif (phoneNorm === mobileNorm) {\n matchedField = 'mobilePhone';\n matchedValue = mobilePhone;\n} else if (phoneNorm === workNorm) {\n matchedField = 'workPhone';\n matchedValue = workPhone;\n}\n\nreturn [{\n json: {\n phone,\n matchedField, // 'mobilePhone' | 'workPhone' | null\n matchedValue, // el valor original con formato\n matched: matchedField !== null,\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -1712, 96 ], "id": "6559ddeb-5f77-4219-8469-e5d0851dd69a", "name": "Matchear numero de Whatsapp" }, { "parameters": { "content": "## Poner aca una validacion si la IA dio error\n" }, "type": "n8n-nodes-base.stickyNote", "position": [ 928, 1936 ], "typeVersion": 1, "id": "1e8f158c-88d9-4042-9cad-0df090c37cc4", "name": "Sticky Note3" }, { "parameters": { "operation": "get", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "keyValue": "={{ $json.phone }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ -144, -816 ], "id": "ed081e87-5075-40e8-b982-14ee734f11bd", "name": "Obtener reporte", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "content": "## Añade y actualiza la informacion de los empleados todos los dias a las 2am ", "height": 432, "width": 1152 }, "type": "n8n-nodes-base.stickyNote", "position": [ -2880, 736 ], "typeVersion": 1, "id": "472aedd4-2aeb-4822-9016-44703d3076db", "name": "Sticky Note8" }, { "parameters": { "content": "## Aqui los botones para confirmar si crear un reporte" }, "type": "n8n-nodes-base.stickyNote", "position": [ -16, -688 ], "typeVersion": 1, "id": "0e16131e-8116-482a-9984-09267f643e83", "name": "Sticky Note9" }, { "parameters": { "jsCode": "\nconst tipoReporte = \"Anticipo\"; \nconst pais = $input.first().json.country; \nconst fecha = DateTime.now();\nconst fechaFormateado = fecha.toFormat(\"yyyyMM\");\n\n// Retorna \"\" si pais o D9 están vacíos\n//if (!pais || !D9) return [{ json: { codigo: \"\" } }];\n\nconst prefijo = pais.replace(/\\s/g, \"\").substring(0, 3).toUpperCase();\n\nconst tipoNum =\n tipoReporte === \"Anticipo\" ? 1 :\n tipoReporte === \"Reembolso\" ? 2 : 3;\nconst tipoStr = String(tipoNum).padStart(4, \"0\");\n\nconst reporteID = `${prefijo}-${fechaFormateado}-${tipoStr}`;\n\nreturn [{ json: { reporteID: reporteID } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 192, -688 ], "id": "f00dfdbe-5223-4fc5-abcd-813189d7f05b", "name": "Crear reporte del id" }, { "parameters": { "jsCode": "\n\nreturn {\n reporteID: $('Crear reporte del id').first().json.reporteID,\n pais: $('Empleado tiene reporte abierto?').first().json.country,\n departamento: $('Numero esta registrado en GLM?').first().json.departamento,\n fechaSolicitud: $input.first().json.fechaSolicitud,\n cargo: $('Numero esta registrado en GLM?').first().json.cargo,\n empleado: $('Numero esta registrado en GLM?').first().json.name,\n idCedula: $('Numero esta registrado en GLM?').first().json.id + \" / \" + $('Numero esta registrado en GLM?').first().json.cedula,\n jefeDirecto: $('Numero esta registrado en GLM?').first().json.supervisor,\n \n}" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 3632, -688 ], "id": "6886cea4-40ae-4c99-a370-4f593304c982", "name": "Detalles del reporte" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "loose", "version": 3 }, "conditions": [ { "id": "ac86564e-1b34-49d4-be74-0685297a6f86", "leftValue": "={{ Object.keys($json).length }}", "rightValue": "=0", "operator": { "type": "number", "operation": "gt" } } ], "combinator": "and" }, "looseTypeValidation": true, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ -1936, -16 ], "id": "7cb04147-9d6e-4796-b6ae-556b01b68ca1", "name": "Telefono registrado BD?" }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $('Crear reporte').item.json.id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!O4\", \"values\": [[\"{{ $json.reporteID }}\"]] },\n { \"range\": \"Liquidación!D7\", \"values\": [[\"{{ $json.pais }}\"]] },\n { \"range\": \"Liquidación!D8\", \"values\": [[\"{{ $json.departamento }}\"]] },\n { \"range\": \"Liquidación!D9\", \"values\": [[\"{{ $json.fechaSolicitud }}\"]] },\n { \"range\": \"Liquidación!L8\", \"values\": [[\"{{ $json.cargo }}\"]] },\n { \"range\": \"Liquidación!L9\", \"values\": [[\"{{ $json.empleado }}\"]] },\n { \"range\": \"Liquidación!L10\", \"values\": [[\"{{ $json.idCedula }}\"]] },\n { \"range\": \"Liquidación!L11\", \"values\": [[\"{{ $json.jefeDirecto }}\"]] }\n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 3824, -688 ], "id": "913cc91c-893b-4e91-968c-c7b1ae4a87ea", "name": "Insertar id del reporte al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "method": "POST", "url": "https://script.google.com/macros/s/AKfycbwB3R5Wv2rKUvJTd1gsJn1kPkOLGbdzIgqNgwxGRkIxU_xGyThp1g2OE9R-7aPvLXc/exec", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify($json) }}", "options": { "redirect": { "redirect": {} } } }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 2768, 1696 ], "id": "9e3c13b9-3eb3-40ac-ba96-2bf093a8a828", "name": "Insertar detalles de la factura al sheets" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=📸 *Factura procesada*:\n\n🏢 {{ $('Edit Fields').item.json.output.proveedor }}\n📄 {{ $('Edit Fields').item.json.output.numero_factura }}\n📅 {{ $('Edit Fields').item.json.output.fecha }}\n💰 Subtotal {{ $('Edit Fields').item.json.output.moneda }} {{ $('Edit Fields').item.json.output.subtotal }}\n {{ $('Edit Fields').item.json.output.impuesto1_tipo }} {{ $('Edit Fields').item.json.output.impuesto1_porciento }}% → {{ $('Edit Fields').item.json.output.impuesto1_monto }}\n *Total {{ $('Edit Fields').item.json.output.moneda }} {{ $('Edit Fields').item.json.output.total }}*\n📂 {{ $('Edit Fields').item.json.output.gasto_categoria }}\n\n¿Está correcto?" }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 2960, 1696 ], "id": "240c50a5-9af1-4789-8c6a-ea63fc05c3cf", "name": "Confirmacion factura recibida" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Es imagen?').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "draft_invoice", "fieldValue": "={{ JSON.stringify($json) }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 1712, 2048 ], "id": "a8ce782d-4f4f-4d20-8b4c-c147d841671b", "name": "Guardar factura temporalmente", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D10\", \"values\": [[\"{{ $('Webhook').item.json.body.data.message.conversation }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 192, 816 ], "id": "569b6210-d5de-4710-9cf0-9e7fe5fa3120", "name": "Insertar periodoDesde al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D11\", \"values\": [[\"{{ $('Webhook').item.json.body.data.message.conversation }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 192, 1008 ], "id": "e489ae8b-389e-4b60-ad0c-d54b647763e7", "name": "Insertar periodoHasta al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D14\", \"values\": [[\"{{ $('Webhook').item.json.body.data.message.conversation }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 192, 448 ], "id": "1bacb766-c826-40fa-81c9-819395de22ac", "name": "Insertar ruta al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!L6\", \"values\": [[\"{{ $('Webhook').item.json.body.data.message.conversation }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 192, 1392 ], "id": "23643afb-4f8e-4f14-8a78-fdb0890c7d91", "name": "Insertar cliente/proyecto al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendReaction/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"key\": {\n \"remoteJid\": \"{{ \"18097159076@s.whatsapp.net\" }}\",\n \"fromMe\": false,\n \"id\": \"{{ $('Webhook').item.json.body.data.key.id }}\"\n },\n \"reaction\": \"⏳\"\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 448, 1792 ], "id": "0ad99326-cf8b-44b4-9932-ed4b0a9f01b4", "name": "Reaccionar" }, { "parameters": { "resource": "folder", "name": "={{ $('Empleado tiene reporte abierto?').item.json.country }}", "driveId": { "__rl": true, "mode": "list", "value": "My Drive" }, "folderId": { "__rl": true, "value": "1v7znbHi9H39hg0RPJyGf5VShaNIxESgo", "mode": "list", "cachedResultName": "Liquidaciones", "cachedResultUrl": "https://drive.google.com/drive/folders/1v7znbHi9H39hg0RPJyGf5VShaNIxESgo" }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 880, -592 ], "id": "7dabdc5b-3cf9-43b0-a8e6-77b88f5d9a10", "name": "Crear carpeta pais", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "resource": "folder", "name": "={{ $('Obtener mes y año').item.json.mes_nombre }}", "driveId": { "__rl": true, "mode": "list", "value": "My Drive" }, "folderId": { "__rl": true, "value": "={{ (() => { try { return $('Crear carpeta año').item.json.id } catch(e) { return $('Buscar carpeta X año').item.json.id } })() }}", "mode": "id" }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 1872, -592 ], "id": "aa4eafdf-a7f1-49cc-a854-e2be89af04d2", "name": "Crear carpeta mes", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "9cd817f5-661e-471b-b1b1-461778d95e15", "leftValue": "={{ Object.keys($json).length }}", "rightValue": 0, "operator": { "type": "number", "operation": "gt" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 720, -688 ], "id": "2d233a2a-3f97-4412-8024-7ec0431fccd7", "name": "Existe carpeta X pais?" }, { "parameters": { "resource": "fileFolder", "queryString": "={{ $('Empleado tiene reporte abierto?').item.json.country }}", "returnAll": true, "filter": { "includeTrashed": false }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 544, -688 ], "id": "e59815d2-d34b-4d37-81a1-40991659e180", "name": "Buscar carpeta X pais", "alwaysOutputData": true, "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "jsCode": "const now = new Date();\n\nreturn [{\n json: {\n mes: now.getMonth() + 1,\n mes_nombre: now.toLocaleString('es-ES', { month: 'long' }),\n año: now.getFullYear(),\n mes_año: now.toLocaleString('es-ES', { month: 'long', year: 'numeric' })\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 368, -688 ], "id": "7e6c9d47-6887-4e27-b650-4aa8b5ac2652", "name": "Obtener mes y año" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "9cd817f5-661e-471b-b1b1-461778d95e15", "leftValue": "={{ Object.keys($json).length }}", "rightValue": 0, "operator": { "type": "number", "operation": "gt" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 1712, -688 ], "id": "80ea42b6-a28d-4b4a-b5e9-8146daefc8e6", "name": "Existe carpeta X mes?" }, { "parameters": { "resource": "fileFolder", "queryString": "={{ $('Obtener mes y año').item.json.mes_nombre }}", "returnAll": true, "filter": { "folderId": { "__rl": true, "value": "={{ $json.id || $('Buscar carpeta X año').item.json.id}}", "mode": "id" }, "includeTrashed": false }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 1520, -688 ], "id": "fcb9a536-1be4-4e61-aa98-2e6f72b75120", "name": "Buscar carpeta X mes", "alwaysOutputData": true, "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "resource": "fileFolder", "queryString": "={{ $('Obtener mes y año').item.json['año'] }}", "returnAll": true, "filter": { "folderId": { "__rl": true, "value": "={{ $json.id }}", "mode": "id" }, "includeTrashed": false }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 1024, -688 ], "id": "220d6435-5e25-435a-85a3-013c840a1ec3", "name": "Buscar carpeta X año", "alwaysOutputData": true, "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "9cd817f5-661e-471b-b1b1-461778d95e15", "leftValue": "={{ Object.keys($json).length }}", "rightValue": 0, "operator": { "type": "number", "operation": "gt" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 1216, -688 ], "id": "cb389c48-af80-4a04-8538-0394986dc88c", "name": "Existe carpeta X año?" }, { "parameters": { "resource": "folder", "name": "={{ $('Obtener mes y año').item.json['año'] }}", "driveId": { "__rl": true, "mode": "list", "value": "My Drive" }, "folderId": { "__rl": true, "value": "={{ (() => { try { return $('Crear carpeta pais').item.json.id } catch(e) { return $('Buscar carpeta X pais').item.json.id } })() }}", "mode": "id" }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 1376, -592 ], "id": "b4d12d76-69b0-4770-86d3-d8b2d1ee84e0", "name": "Crear carpeta año", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "resource": "fileFolder", "queryString": "={{ $('Crear reporte del id').item.json.reporteID }}", "returnAll": true, "filter": { "folderId": { "__rl": true, "value": "={{ $json.id || $('Buscar carpeta X mes').item.json.id }}", "mode": "id" } }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 2032, -688 ], "id": "b7315899-dc61-420a-aa7a-5caf2e81479c", "name": "Buscar carpeta X reporte", "alwaysOutputData": true, "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "9cd817f5-661e-471b-b1b1-461778d95e15", "leftValue": "={{ Object.keys($json).length }}", "rightValue": 0, "operator": { "type": "number", "operation": "gt" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 2240, -688 ], "id": "08c93234-8b7e-4e53-8ccd-106e62defa16", "name": "Existe carpeta X reporte?" }, { "parameters": { "resource": "folder", "name": "={{ $('Crear reporte del id').item.json.reporteID + '-' + $('Empleado tiene reporte abierto?').item.json.name.split(' ')[0] + ($('Empleado tiene reporte abierto?').item.json.name.split(' ')[1] ? $('Empleado tiene reporte abierto?').item.json.name.split(' ')[1][0] : '') }}", "driveId": { "__rl": true, "mode": "list", "value": "My Drive" }, "folderId": { "__rl": true, "value": "={{ (() => { try { return $('Crear carpeta mes').item.json.id } catch(e) { return $('Buscar carpeta X mes').item.json.id } })() }}", "mode": "id" }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 2400, -592 ], "id": "804ae7ef-81f5-4586-a4b3-bd192e36a17b", "name": "Crear carpeta reporte", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "operation": "copy", "fileId": { "__rl": true, "value": "1Zuw5qcioFzZgTlWPmYXxpMKx3Ji4jLwH2a60qEsnwHc", "mode": "list", "cachedResultName": "Copia de GLM_Liquidacion_Gastos_DEMO", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Zuw5qcioFzZgTlWPmYXxpMKx3Ji4jLwH2a60qEsnwHc/edit?usp=drivesdk" }, "name": "={{ $('Crear reporte del id').item.json.reporteID + '-' + $('Empleado tiene reporte abierto?').item.json.name.split(' ')[0] + ($('Empleado tiene reporte abierto?').item.json.name.split(' ')[1] ? $('Empleado tiene reporte abierto?').item.json.name.split(' ')[1][0] : '') }}", "sameFolder": false, "driveId": { "__rl": true, "mode": "list", "value": "My Drive" }, "folderId": { "__rl": true, "value": "={{ (() => { try { return $('Crear carpeta reporte').item.json.id } catch(e) { return $('Buscar carpeta X reporte').item.json.id } })() }}", "mode": "id" }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 2736, -688 ], "id": "7dd87738-d903-4d98-a30f-b9e3101fc2dc", "name": "Crear reporte", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "jsCode": "const date = new Date();\nconst formatted = date.toLocaleDateString('en-GB', {\n day: '2-digit',\n month: 'short',\n year: 'numeric'\n});\n\nreturn [{ json: { fechaSolicitud: formatted } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 3440, -688 ], "id": "ee2533a7-f4cb-4467-955c-3d2d2d6e6e9e", "name": "Obtener mes y año para el sheet" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Empleado tiene reporte abierto?').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "awaiting_tipoReporte" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 2896, -688 ], "id": "5d5e0dfa-cbdd-4e23-acbf-f3a298e5ca8b", "name": "Actualizar status a awaiting_tipoReporte", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "jsCode": "const fullName = $input.first().json.name; \nconst firstName = fullName.trim().split(/\\s+/)[0];\n\nreturn [{ json: { firstName } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 3072, -688 ], "id": "ff06051a-cc26-4e44-a471-1d9dc15305c7", "name": "Solo primer nombre" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=¡Hola {{ $json.firstName }}! 👋 Bienvenido al asistente de liquidación de gastos.\n\nAntes de procesar tu factura, necesito los siguientes datos para abrir tu reporte de {{ $('Obtener mes y año').item.json.mes_nombre }} 2026:\n\n¿Qué tipo de reporte es?\n\n1️⃣ Anticipo — Liquidación facturas de un anticipo que recibí\n2️⃣ Reembolso — Gastos out-of-pocket que pagué de mi bolsillo\n\nResponde con el número o el nombre." }, { "name": "delay", "value": "={{4000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 3264, -688 ], "id": "94957c2f-4db7-4dac-a1b5-da8e18e39b0a", "name": "Pedir tipo reporte" }, { "parameters": { "rules": { "values": [ { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "leftValue": "={{ [\"1\", \"Anticipo\", \"anticipo\"].includes($('Webhook').item.json.body.data.message.conversation).toString() }}", "rightValue": "=true", "operator": { "type": "string", "operation": "equals" }, "id": "e586aecc-ad7d-43b0-86c7-52ffe9a395c1" } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "99c670dc-8bba-4d78-9adc-2b2824a1e811", "leftValue": "={{ [\"2\", \"Reembolso\", \"reembolso\"].includes($('Webhook').item.json.body.data.message.conversation).toString() }}", "rightValue": "=true", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "72a3027d-a437-4721-a2b1-dc8ebc779f61", "leftValue": "={{ ![\"1\", \"Anticipo\", \"2\", \"Reembolso\", \"3\", \"Caja chica\"].includes($('Webhook').item.json.body.data.message.conversation) }}", "rightValue": "false", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" } } ] }, "options": {} }, "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ 192, -272 ], "id": "7263147e-cc9d-4bc9-ab3d-e1bf9dbc5e9f", "name": "Tipo de reporte" }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $('Tipo de reporte').item.json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D6\", \"values\": [[\"Liquidación Anticipo\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 608, -384 ], "id": "f9cbc3ab-79f2-4a70-9629-3397a2f0c104", "name": "Insertar anticipo al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $('Tipo de reporte').item.json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D6\", \"values\": [[\"Liquidación Reembolso\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 608, -256 ], "id": "0e53efb6-4894-41e2-b10b-1be220121cf3", "name": "Insertar reembolso al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=Opción no válida. Por favor responde con el número o nombre del tipo de reporte:\n\n1️⃣ Anticipo\n2️⃣ Reembolso" }, { "name": "delay", "value": "={{5000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 416, -112 ], "id": "af4e8d5d-283a-422d-bab8-420953d1ceeb", "name": "Alerta opcion no valida" }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D13\", \"values\": [[\"{{ $('Webhook').item.json.body.data.message.conversation }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 192, 1200 ], "id": "4f9377ef-0e9c-4c36-9fad-2f2089a7b49e", "name": "Insertar motivo o destino al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "resource": "folder", "name": "={{ $('Crear reporte del id').item.json.reporteID }}-Facturas", "driveId": { "__rl": true, "mode": "list", "value": "My Drive" }, "folderId": { "__rl": true, "value": "={{ (() => { try { return $('Crear carpeta reporte').item.json.id } catch(e) { return $('Buscar carpeta X reporte').item.json.id } })() }}", "mode": "id" }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 2576, -688 ], "id": "3a8ef3e9-471d-41ae-b247-c9900c379c0d", "name": "Crear folder facturas", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Empleado tiene reporte abierto?').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "report_id", "fieldValue": "={{ $('Detalles del reporte').item.json.reporteID }}" }, { "fieldId": "sheet_id", "fieldValue": "={{ $('Crear reporte').item.json.id }}" }, { "fieldId": "invoice_photos_folder_id", "fieldValue": "={{ $('Crear folder facturas').item.json.id }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 4224, -688 ], "id": "c3d504e3-1d35-4589-967b-952c843d49ef", "name": "Insertar reporte id, sheet id y factura folder id", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "jsCode": "const tipoReporte = \"Liquidación Anticipo\";\n\nreturn [{ json: { tipoReporte } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 416, -384 ], "id": "d0b15432-1636-4b27-882c-968beb8c477f", "name": "Anticipo" }, { "parameters": { "jsCode": "const tipoReporte = \"Liquidación Reembolso\";\n\nreturn [{ json: { tipoReporte } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 416, -256 ], "id": "241a7aaf-d2f7-4ab3-8f84-f8abcabdcd9d", "name": "Reembolso" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ periodoInicio: $('Webhook').item.json.body.data.message.conversation }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 400, 816 ], "id": "a17dd40a-7587-4185-8057-9ddaa1386494", "name": "Insertar periodoDesde en la bd" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ motivoDescripcion: $('Webhook').item.json.body.data.message.conversation }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 400, 1200 ], "id": "91691ad5-3146-4f15-b550-8ce3f6d1a266", "name": "Insertar motivo o destino en la bd" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ periodoFinalizacion: $('Webhook').item.json.body.data.message.conversation }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 400, 1008 ], "id": "c42d6376-9759-4ebc-8a41-0144b2b497d3", "name": "Insertar periodoHasta en la bd" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ ruta: $('Webhook').item.json.body.data.message.conversation }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 400, 448 ], "id": "fa4d3912-c582-4d99-8ab4-594e851ba88f", "name": "Insertar ruta en la bd" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ clienteProyecto: $('Webhook').item.json.body.data.message.conversation }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 400, 1392 ], "id": "bf0a2f32-2127-46f3-b04f-5a3ceddb8772", "name": "Insertar cliente/proyecto en la bd" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ \n reporteID: $('Detalles del reporte').item.json.reporteID, \n pais: $('Detalles del reporte').item.json.pais, \n departamento: $('Detalles del reporte').item.json.departamento, \n fechaSolicitud: $('Detalles del reporte').item.json.fechaSolicitud, \n cargo: $('Detalles del reporte').item.json.cargo, \n empleado: $('Detalles del reporte').item.json.empleado, \n idCedula: $('Detalles del reporte').item.json.idCedula, \n jefeDirecto: $('Detalles del reporte').item.json.jefeDirecto \n }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 4016, -688 ], "id": "3eb5d2a6-2a76-41e5-b720-1ad3738f3125", "name": "Insertar info bamboo a contexto" }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!O51\", \"values\": [[\"{{ $('Webhook').item.json.body.data.message.conversation }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 192, 624 ], "id": "2546a8cd-30a1-41db-a575-cb2fcb22ab2c", "name": "Insertar anticipo recibido al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ anticipoRecibido: $('Webhook').item.json.body.data.message.conversation }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 400, 624 ], "id": "ed0b1aac-c490-4571-9f15-528eddf5ce2a", "name": "Insertar anticipo recibido en la bd" }, { "parameters": { "jsCode": "const now = new Date(new Date().toLocaleString('en-US', { timeZone: 'America/Santo_Domingo' }));\n\nconst pad = n => String(n).padStart(2, '0');\n\nconst dd = pad(now.getDate());\nconst mm = pad(now.getMonth() + 1);\nconst yyyy = now.getFullYear();\n\nreturn [{\n json: {\n timestamp: `${dd}-${mm}-${yyyy}`\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1936, 1696 ], "id": "867a7357-08aa-430d-b839-61df62883423", "name": "Generar timestamp" }, { "parameters": { "jsCode": "const output = $('Edit Fields').item.json.output;\n\nreturn [{\n json: {\n spreadsheetId: $('Es imagen?').first().json.sheetId,\n valores: [\n output.fecha || \"-\",\n output.numero_factura || \"-\",\n output.proveedor || \"-\",\n output.nif_glm || \"-\",\n output.gasto_categoria || \"-\",\n $('Webhook').first().json.caption,\n output.moneda || \"-\",\n output.subtotal || \"ninguno\",\n output.impuesto1_tipo || \"ninguno\",\n output.impuesto1_porciento || \"ninguno\",\n output.impuesto1_monto || \"0.00\",\n output.impuesto2_tipo || \"ninguno\",\n output.impuesto2_monto || \"0.00\",\n output.total || \"0.00\",\n \"-\",\n $input.first().json.webViewLink || \"-\",\n ]\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 2592, 1696 ], "id": "7d781acd-292f-4cbc-bfc7-c85ab7793778", "name": "Detalles de factura" }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.spreadsheetId }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D12\", \"values\": [[\"{{ $json.valores[6] }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 2768, 1888 ], "id": "f1d84244-f0be-43b8-8068-ab01516bc41b", "name": "Insertar moneda al contexto de reporte", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Es imagen?').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "pending_invoice", "fieldValue": "={{ $json.campos_faltantes }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 2048, 2208 ], "id": "45ebdf41-ede9-4aa1-9cc9-15a75b27b1f8", "name": "Guardar valores faltantes", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "jsCode": "const data = $input.first().json;\n\nconst camposRequeridos = {\n proveedor: data.proveedor,\n nif_glm: data.nif_glm,\n total: data.total,\n};\n\nconst camposFaltantes = Object.entries(camposRequeridos)\n .filter(([_, valor]) => valor === null || valor === undefined || valor === \"\")\n .map(([campo]) => campo);\n\nreturn [{\n json: {\n campos_faltantes: camposFaltantes,\n tiene_faltantes: camposFaltantes.length > 0,\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1712, 2208 ], "id": "00ca65f0-812d-4055-adbd-c2a78156aa8a", "name": "Detectar valor critico" }, { "parameters": { "jsCode": "const camposFaltantes = $input.first().json.campos_faltantes;\nconst campo = camposFaltantes[0];\n\nconst statusMap = {\n total: \"awaiting_total\",\n proveedor: \"awaiting_proveedor\",\n nif_glm: \"awaiting_nif_glm\",\n};\n\nconst status = statusMap[campo] ?? \"awaiting_unknown\";\nconst texto =\n campo === \"total\" ? \"No pude detectar el *total* de la factura. Por favor escríbelo aquí para continuar.\" :\n campo === \"proveedor\" ? \"No pude detectar el *proveedor* de la factura. Por favor escríbelo aquí para continuar.\" :\n campo === \"nif_glm\" ? \"No pude detectar el *RNC* en la factura. Por favor escríbelo aquí para continuar.\" : \n campo === \"fecha\" ? \"No pude detectar la *fecha* de la factura. Por favor escribelo aqui para continuar.\" : \"\"\n \nreturn [{ json: { ...$input.first().json, status, texto } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1872, 2208 ], "id": "f05feb15-6907-48bd-b1c9-03f34a2d3cec", "name": "Awaiting" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Es imagen?').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "={{ $('Awaiting').item.json.status }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 2240, 2208 ], "id": "bc3027d0-ab38-4585-bedb-ac7f494d50a7", "name": "Actualizar awaiting", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D13\", \"values\": [[\"{{ $('Webhook').item.json.body.data.message.conversation }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 192, 2288 ], "id": "0bdea5f8-fae3-4848-aa1d-520335b6ef44", "name": "Insertar total de la factura", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "url": "=https://glm.bamboohr.com/api/v1/employees/{{ $json.id }}?fields=displayName,mobilePhone,workPhone,status,employeeNumber,supervisor,supervisorEmail,location,jobTitle,department", "authentication": "genericCredentialType", "genericAuthType": "httpBasicAuth", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "accept", "value": "application/json" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ -2256, 960 ], "id": "07b59187-1284-4830-9b5a-40d62dadc2c4", "name": "Informacion del empleado", "retryOnFail": true, "waitBetweenTries": 2000, "credentials": { "httpBasicAuth": { "id": "vXrW3oJWVhNbzB07", "name": "GLM Credential" } } }, { "parameters": { "resource": "audio", "operation": "analyze", "modelId": { "__rl": true, "value": "models/gemini-pro-latest", "mode": "list", "cachedResultName": "models/gemini-pro-latest" }, "text": "Que contiene este audio?\n\nDespues de extraer este audio debes analizar el texto y detectar los siguientes valores:\n- Ruta de viaje\n- Cantidad de dinero del anticipo\n- Fecha de periodo de inicio\n- Fecha de periodo de finalizacion\n- Motivo o destino del viaje\n- Cliente o proyecto\n", "inputType": "binary", "options": {} }, "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ 976, 80 ], "id": "cc4f685c-db7f-4241-b2c6-629c28104958", "name": "Analyze audio", "credentials": { "googlePalmApi": { "id": "tFqBJras00HUi1hA", "name": "Eidan - Google Gemini(PaLM) Api account" } } }, { "parameters": { "operation": "toBinary", "sourceProperty": "base64", "options": { "mimeType": "={{ $json.mimetype }}" } }, "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ 784, 80 ], "id": "e0dc6afc-3b65-4d31-8b1f-4e83b9192467", "name": "Convert to File2" }, { "parameters": { "rules": { "values": [ { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "leftValue": "={{ $('Webhook').item.json.body.data.messageType }}", "rightValue": "audioMessage", "operator": { "type": "string", "operation": "equals" }, "id": "34251b5f-5d31-4a40-9fdb-5a057d6a4218" } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "d43ac8f7-aa7b-4737-b13f-aa24b5393c23", "leftValue": "={{ $('Webhook').item.json.body.data.messageType }}", "rightValue": "conversation", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } } ] }, "options": {} }, "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ 336, 176 ], "id": "d6fcaa95-6c27-4a02-b243-042013c65fd7", "name": "Audio o texto" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "awaiting_answer" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 880, -384 ], "id": "212c1b12-4b90-47d4-aa17-936349e022b7", "name": "Actualizar status a awaiting_answer", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=Manda un texto o un audio contestando estas preguntas:\n\n1. ¿Cuál fue tu ruta?\n (ej: 'Santo Domingo → Santiago → Santo Domingo')\n\n2. ¿Cuánto recibiste de anticipo?\n\n3. Fecha de periodo de inicio y finalización.\n\n4. ¿Cuál es el motivo o destino del viaje?\n (ej. 'Viaje a Santiago — visita Cervecería Nacional')\n\n5. ¿Cliente o proyecto?\n (escribe 'general' si no aplica)" }, { "name": "delay", "value": "={{5000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1072, -384 ], "id": "a89d4832-9fb5-4874-9287-c00420732c37", "name": "Pedir info" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "awaiting_answer" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 880, -176 ], "id": "6861f725-ed5d-4f68-95c9-3a2319eb20a1", "name": "Actualizar status a awaiting_answer1", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=Manda un texto o un audio contestando estas preguntas:\n\n1. Fecha de periodo de inicio y finalización.\n\n2. ¿Cuál es el motivo o destino del viaje?\n (ej. 'Viaje a Santiago — visita Cervecería Nacional')\n\n3. ¿Cliente o proyecto?\n (escribe 'general' si no aplica)" }, { "name": "delay", "value": "={{5000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1072, -176 ], "id": "a0cdb5b1-b17c-4e4a-baef-22a917ad38d1", "name": "Pedir info1" }, { "parameters": { "modelId": { "__rl": true, "value": "models/gemini-2.5-flash", "mode": "list", "cachedResultName": "models/gemini-2.5-flash" }, "messages": { "values": [ { "content": "={{ $json.content.parts[0].text }}" }, { "content": "=Tipo de reporte: {{ $('Switch').item.json.context.tipoReporte }}\n\nEn el texto debes detectar los siguientes valores:\n- Ruta de viaje\n- Cantidad de dinero del anticipo\n- Fecha de periodo de inicio\n- Fecha de periodo de finalizacion\n- Motivo o destino del viaje\n- Cliente o proyecto\n\n## Reglas\n- Al insertar el valor del anticpoRecibido solo inserta el monto sin las palabras \"pesos, dolares\" y tampoco simbolos. Debes devolverlos con este formato: 0.00\n- Si el tipo de reporte es \"Liquidación Reembolso\", NO insertes en el JSON la ruta y y dinero del anticipo (anticipoRecibido). Ambos valores ruta y anticipoRecibido deben ser VACIOS, NO null.\n\n## Formato\n- Debes insertar las fechas de periodoInicio y periodoFinalizacion en este formato: dd (mes nombre) yyyy, ejemplo: 04 mayo 2026.\n- Si el usuario dice una ruta asi \"Desde Santo Domingo a Punta Cana y regreso a Santo Domingo\" debes formatearlo asi: \"Santo Domingo > Punta Cana > Santo Domingo\".\n\nLuego de detectar esos valores, crea un JSON valido:\n{\n ruta: \"ruta de viaje\" || null,\n anticipoRecibido: \"dinero anticipo\" || null,\n periodoInicio: \"fecha de periodo de inicio\" || null,\n periodoFinalizacion: \"fecha de periodo de finalizacion\" || null,\n motivoDescripcion: \"motivo o destino\" || null,\n clienteProyecto: \"cliente o proyecto\" || null\n} ", "role": "model" } ] }, "jsonOutput": true, "builtInTools": {}, "options": {} }, "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ 1152, 80 ], "id": "ae3aa908-bbb5-4715-8e49-8c91c6f6a509", "name": "Message a model", "credentials": { "googlePalmApi": { "id": "tFqBJras00HUi1hA", "name": "Eidan - Google Gemini(PaLM) Api account" } } }, { "parameters": { "assignments": { "assignments": [ { "id": "4bf34faf-ead0-491f-90a2-199fb7e8c6fa", "name": "content.parts[0].text", "value": "={{ $json.content.parts[0].text }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 1504, 176 ], "id": "340ce3b3-bd56-4bb1-964a-1b284b37c6d9", "name": "Edit Fields3" }, { "parameters": { "modelId": { "__rl": true, "value": "models/gemini-2.5-flash", "mode": "list", "cachedResultName": "models/gemini-2.5-flash" }, "messages": { "values": [ { "content": "={{ $('Webhook').item.json.body.data.message.conversation }}" }, { "content": "Tipo de reporte: {{ $('Switch').item.json.context.tipoReporte }}\n\nEn el texto debes detectar los siguientes valores:\n- Ruta de viaje\n- Cantidad de dinero del anticipo\n- Fecha de periodo de inicio\n- Fecha de periodo de finalizacion\n- Motivo o destino del viaje\n- Cliente o proyecto\n\n## Reglas\n- Al insertar el valor del anticpoRecibido solo inserta el monto sin las palabras \"pesos, dolares\" y tampoco simbolos. Debes devolverlos con este formato: 0.00\n- Si el tipo de reporte es \"Liquidación Reembolso\", NO insertes en el JSON la ruta y y dinero del anticipo (anticipoRecibido). Ambos valores ruta y anticipoRecibido deben ser VACIOS, NO null.\n\n## Formato\n- Debes insertar las fechas de periodoInicio y periodoFinalizacion en este formato: dd (mes nombre) yyyy, ejemplo: 04 mayo 2026.\n- Si el usuario dice una ruta asi \"Desde Santo Domingo a Punta Cana y regreso a Santo Domingo\" debes formatearlo asi: \"Santo Domingo > Punta Cana > Santo Domingo\".\n\nLuego de detectar esos valores, crea un JSON valido:\n{\n ruta: \"ruta de viaje\" || null,\n anticipoRecibido: \"dinero anticipo\" || null,\n periodoInicio: \"fecha de periodo de inicio\" || null,\n periodoFinalizacion: \"fecha de periodo de finalizacion\" || null,\n motivoDescripcion: \"motivo o destino\" || null,\n clienteProyecto: \"cliente o proyecto\" || null\n}", "role": "model" } ] }, "jsonOutput": true, "builtInTools": {}, "options": {} }, "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ 816, 272 ], "id": "d5297098-54d1-40eb-b6e3-af326bfb9cc4", "name": "Message a model1", "credentials": { "googlePalmApi": { "id": "tFqBJras00HUi1hA", "name": "Eidan - Google Gemini(PaLM) Api account" } } }, { "parameters": { "jsCode": "const data = $input.first().json.content.parts[0].text;\n\nconst camposRequeridos = {\n ruta: data.ruta,\n anticipoRecibido: data.anticipoRecibido,\n periodoInicio: data.periodoInicio,\n periodoFinalizacion: data.periodoFinalizacion,\n motivoDescripcion: data.motivoDescripcion,\n clienteProyecto: data.clienteProyecto\n};\n\nconst camposFaltantes = Object.entries(camposRequeridos)\n .filter(([_, valor]) => valor === null )\n .map(([campo]) => campo);\n\nreturn [{\n json: {\n campos_faltantes: camposFaltantes,\n tiene_faltantes: camposFaltantes.length > 0,\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1696, 176 ], "id": "eed9c2e0-b95d-4644-aadd-4e03f6685329", "name": "Detectar info faltante para contexto" }, { "parameters": { "jsCode": "const camposFaltantes = $('Detectar info faltante para contexto').first().json.campos_faltantes;\nconst campo = camposFaltantes[0];\n\nconst statusMap = {\n ruta: \"awaiting_ruta\",\n anticipoRecibido: \"awaiting_anticipoRecibido\",\n periodoInicio: \"awaiting_periodoInicio\",\n periodoFinalizacion: \"awaiting_periodoFinalizacion\",\n motivoDescripcion: \"awaiting_motivo\",\n clienteProyecto: \"awaiting_clienteProyecto\"\n};\n\nconst status = statusMap[campo] ?? \"awaiting_unknown\";\nconst texto =\n campo === \"ruta\" ? \"No pude detectar la *ruta*. Por favor escríbelo aquí para continuar.\" :\n campo === \"anticipoRecibido\" ? \"No pude detectar el *dinero* del anticipo. Por favor escríbelo aquí para continuar.\" :\n campo === \"periodoInicio\" ? \"No pude detectar la *fecha del periodo de inicio*. Por favor escríbelo aquí para continuar.\" :\n campo === \"periodoFinalizacion\" ? \"No pude detectar la *fecha del periodo de finalizacion*. Por favor escríbelo aquí para continuar.\" :\n campo === \"motivoDescripcion\" ? \"No pude detectar el *motivo o destino*. Por favor escríbelo aquí para continuar.\" :\n campo === \"clienteProyecto\" ? \"No pude detectar el *cliente o proyecto*. Por favor escríbelo aquí para continuar.\" : \"\"\n \nreturn [{ json: { status, texto } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 2336, 320 ], "id": "f35b34e2-d18c-4df0-b7cd-2409536ddf3a", "name": "Awaiting2" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "={{ $json.status }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 2512, 320 ], "id": "a98c18d7-42cf-4a1d-9f9a-b999954f59e2", "name": "Actualizar status a awaiting", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "={{ $('Awaiting2').item.json.texto }}" }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 2688, 320 ], "id": "6338ff56-d90d-4fe4-9430-813dcd9a6238", "name": "Enviar alerta falta info" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ \nperiodoInicio: $('Edit Fields3').item.json.content.parts[0].text.periodoInicio, \nperiodoFinalizacion: $('Edit Fields3').item.json.content.parts[0].text.periodoFinalizacion, \nmotivoDescripcion: $('Edit Fields3').item.json.content.parts[0].text.motivoDescripcion, \nruta: $('Edit Fields3').item.json.content.parts[0].text.ruta, \nclienteProyecto: $('Edit Fields3').item.json.content.parts[0].text.clienteProyecto,\nanticipoRecibido: parseFloat($('Edit Fields3').item.json.content.parts[0].text.anticipoRecibido)\n}) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 2144, 80 ], "id": "198edb5b-3c66-46d8-9fe6-7640b3ed10dd", "name": "Insertar contexto en la bd" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Audio o texto').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "pending_context", "fieldValue": "={{ $json.campos_faltantes }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 2144, 320 ], "id": "4d36ae8b-8bde-422c-aa5b-38ec39ec9ba0", "name": "Guardar valores faltantes de contexto", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/chat/getBase64FromMediaMessage/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "message.key.id", "value": "={{ $('Webhook').item.json.body.data.key.id }}" }, { "name": "convertToMp4", "value": "={{ Boolean(false) }}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 608, 80 ], "id": "203ef421-ac9b-4750-aca5-55b5d5d798b1", "name": "Descargar audio" }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $('Switch').item.json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D10\", \"values\": [[\"{{ $('Edit Fields3').item.json.content.parts[0].text.periodoInicio }}\"]] },\n { \"range\": \"Liquidación!D11\", \"values\": [[\"{{ $('Edit Fields3').item.json.content.parts[0].text.periodoFinalizacion }}\"]] },\n { \"range\": \"Liquidación!D13\", \"values\": [[\"{{ $('Edit Fields3').item.json.content.parts[0].text.motivoDescripcion }}\"]] },\n { \"range\": \"Liquidación!D14\", \"values\": [[\"{{ $('Edit Fields3').item.json.content.parts[0].text.ruta }}\"]] },\n { \"range\": \"Liquidación!L6\", \"values\": [[\"{{ $('Edit Fields3').item.json.content.parts[0].text.clienteProyecto }}\"]] },\n { \"range\": \"Liquidación!R51\", \"values\": [[\"{{ $('Edit Fields3').item.json.content.parts[0].text.anticipoRecibido }}\"]] }\n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 2336, 80 ], "id": "024c62f2-eb4a-4584-8cae-4cbd4adc4011", "name": "Insertar contexto al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "1ea8fa42-6c2d-47e8-89c4-46dba4fbdb94", "leftValue": "={{ $json.tiene_faltantes }}", "rightValue": false, "operator": { "type": "boolean", "operation": "false", "singleValue": true } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 1856, 176 ], "id": "d7b4d05a-eae5-4fd5-b775-0d1e0174f1a8", "name": "Campo faltante?" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "report_open" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 2512, 80 ], "id": "c2c1a6c5-473b-479b-91bd-f38d2b9400cf", "name": "Actualizar status a report_open1", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "jsCode": "const camposFaltantes = $('Detectar info faltante para contexto1').first().json.campos_faltantes;\nconst campo = camposFaltantes[0];\n\nconst statusMap = {\n ruta: \"awaiting_ruta\",\n anticipoRecibido: \"awaiting_anticipoRecibido\",\n periodoInicio: \"awaiting_periodoInicio\",\n periodoFinalizacion: \"awaiting_periodoFinalizacion\",\n motivoDescripcion: \"awaiting_motivo\",\n clienteProyecto: \"awaiting_clienteProyecto\"\n};\n\nconst status = statusMap[campo] ?? \"awaiting_unknown\";\nconst texto =\n campo === \"ruta\" ? \"No pude detectar la *ruta*. Por favor escríbelo aquí para continuar.\" :\n campo === \"anticipoRecibido\" ? \"No pude detectar el *dinero* del anticipo. Por favor escríbelo aquí para continuar.\" :\n campo === \"periodoInicio\" ? \"No pude detectar la *fecha del periodo de inicio*. Por favor escríbelo aquí para continuar.\" :\n campo === \"periodoFinalizacion\" ? \"No pude detectar la *fecha del periodo de finalizacion*. Por favor escríbelo aquí para continuar.\" :\n campo === \"motivoDescripcion\" ? \"No pude detectar el *motivo o destino*. Por favor escríbelo aquí para continuar.\" :\n campo === \"clienteProyecto\" ? \"No pude detectar el *cliente o proyecto*. Por favor escríbelo aquí para continuar.\" : \"\"\n \nreturn [{ json: { status, texto } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1136, 1040 ], "id": "d6a39d90-57e5-4435-8692-fc1a0664c7d3", "name": "Awaiting3" }, { "parameters": { "jsCode": "const data = $('Switch').first().json.context;\n\nconst camposRequeridos = {\n ruta: data.ruta,\n anticipoRecibido: data.anticipoRecibido,\n periodoInicio: data.periodoInicio,\n periodoFinalizacion: data.periodoFinalizacion,\n motivoDescripcion: data.motivoDescripcion,\n clienteProyecto: data.clienteProyecto\n};\n\nconst camposFaltantes = Object.entries(camposRequeridos)\n .filter(([_, valor]) => valor === null || valor === undefined || valor === \"\")\n .map(([campo]) => campo);\n\nreturn [{\n json: {\n campos_faltantes: camposFaltantes,\n tiene_faltantes: camposFaltantes.length > 0,\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 576, 448 ], "id": "ea962bf1-5e08-4284-903e-a10e9e16416f", "name": "Detectar info faltante para contexto1" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "report_open" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 1136, 848 ], "id": "accd45b1-0639-463f-8bf4-a49a97a14d9f", "name": "Actualizar status a report_open2", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "jsCode": "const data = $('Switch').first().json.context;\n\nconst camposRequeridos = {\n ruta: data.ruta,\n anticipoRecibido: data.anticipoRecibido,\n periodoInicio: data.periodoInicio,\n periodoFinalizacion: data.periodoFinalizacion,\n motivoDescripcion: data.motivoDescripcion,\n clienteProyecto: data.clienteProyecto\n};\n\nconst camposFaltantes = Object.entries(camposRequeridos)\n .filter(([_, valor]) => valor === null || valor === undefined || valor === \"\")\n .map(([campo]) => campo);\n\nreturn [{\n json: {\n campos_faltantes: camposFaltantes,\n tiene_faltantes: camposFaltantes.length > 0,\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 576, 624 ], "id": "08dcef2e-a428-43de-b134-e78b4bbd6a9c", "name": "Detectar info faltante para contexto2" }, { "parameters": { "jsCode": "const data = $('Switch').first().json.context;\n\nconst camposRequeridos = {\n ruta: data.ruta,\n anticipoRecibido: data.anticipoRecibido,\n periodoInicio: data.periodoInicio,\n periodoFinalizacion: data.periodoFinalizacion,\n motivoDescripcion: data.motivoDescripcion,\n clienteProyecto: data.clienteProyecto\n};\n\nconst camposFaltantes = Object.entries(camposRequeridos)\n .filter(([_, valor]) => valor === null || valor === undefined || valor === \"\")\n .map(([campo]) => campo);\n\nreturn [{\n json: {\n campos_faltantes: camposFaltantes,\n tiene_faltantes: camposFaltantes.length > 0,\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 576, 816 ], "id": "3b2d3354-1518-4237-ad89-f2f094e21c52", "name": "Detectar info faltante para contexto3" }, { "parameters": { "jsCode": "const data = $('Switch').first().json.context;\n\nconst camposRequeridos = {\n ruta: data.ruta,\n anticipoRecibido: data.anticipoRecibido,\n periodoInicio: data.periodoInicio,\n periodoFinalizacion: data.periodoFinalizacion,\n motivoDescripcion: data.motivoDescripcion,\n clienteProyecto: data.clienteProyecto\n};\n\nconst camposFaltantes = Object.entries(camposRequeridos)\n .filter(([_, valor]) => valor === null || valor === undefined || valor === \"\")\n .map(([campo]) => campo);\n\nreturn [{\n json: {\n campos_faltantes: camposFaltantes,\n tiene_faltantes: camposFaltantes.length > 0,\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 576, 1008 ], "id": "e6809ba3-a714-4a11-9fb5-15e6f3618d6a", "name": "Detectar info faltante para contexto4" }, { "parameters": { "jsCode": "const data = $('Switch').first().json.context;\n\nconst camposRequeridos = {\n ruta: data.ruta,\n anticipoRecibido: data.anticipoRecibido,\n periodoInicio: data.periodoInicio,\n periodoFinalizacion: data.periodoFinalizacion,\n motivoDescripcion: data.motivoDescripcion,\n clienteProyecto: data.clienteProyecto\n};\n\nconst camposFaltantes = Object.entries(camposRequeridos)\n .filter(([_, valor]) => valor === null || valor === undefined || valor === \"\")\n .map(([campo]) => campo);\n\nreturn [{\n json: {\n campos_faltantes: camposFaltantes,\n tiene_faltantes: camposFaltantes.length > 0,\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 576, 1200 ], "id": "1f8487a7-b309-4722-9130-866a645f1710", "name": "Detectar info faltante para contexto5" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "35e7fdb8-9add-4e4d-b1ab-ca1a20caf186", "leftValue": "={{ $json.tiene_faltantes }}", "rightValue": false, "operator": { "type": "boolean", "operation": "false", "singleValue": true } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 880, 928 ], "id": "ca6c5b47-961b-4429-9093-6dc0ee1681ef", "name": "Campo faltante?1" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "={{ $json.status }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 1296, 1040 ], "id": "92d093b1-bd57-4c9e-bf70-bee52a47a1d2", "name": "Actualizar status a awaiting1", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "={{ $('Awaiting2').item.json.texto }}" }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1488, 1040 ], "id": "cb70d833-29d8-4e2e-aa13-7644edb02ad4", "name": "Enviar alerta falta info1" }, { "parameters": { "jsCode": "const data = $('Switch').first().json.context;\n\nconst camposRequeridos = {\n ruta: data.ruta,\n anticipoRecibido: data.anticipoRecibido,\n periodoInicio: data.periodoInicio,\n periodoFinalizacion: data.periodoFinalizacion,\n motivoDescripcion: data.motivoDescripcion,\n clienteProyecto: data.clienteProyecto\n};\n\nconst camposFaltantes = Object.entries(camposRequeridos)\n .filter(([_, valor]) => valor === null || valor === undefined || valor === \"\")\n .map(([campo]) => campo);\n\nreturn [{\n json: {\n campos_faltantes: camposFaltantes,\n tiene_faltantes: camposFaltantes.length > 0,\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 576, 1392 ], "id": "225d4085-bdaf-4dde-8a6f-d8197f1bd008", "name": "Detectar info faltante para contexto6" }, { "parameters": { "rules": { "values": [ { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "leftValue": "={{ ($json.state == \"idle\" || $json.state == \"report_open\") && $('Webhook').item.json.body.data.message.conversation == \"/ayuda\" }}", "rightValue": "", "operator": { "type": "boolean", "operation": "true", "singleValue": true }, "id": "6b31bc51-bdc7-413e-ae15-9a287e0d97fd" } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "56ea685f-796f-4e0f-bfed-e7a6343cb875", "leftValue": "={{ ($json.state == \"report_open\") && $('Webhook').item.json.body.data.message.conversation == \"/estado\" }}", "rightValue": "", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "94efac47-c3b1-418d-bfaf-55a5f86e9389", "leftValue": "={{ ($json.state == \"report_open\") && $('Webhook').item.json.body.data.message.conversation == \"/cerrar\" }}", "rightValue": "", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "d5f2f59c-9ed1-4b11-ac3f-aa35710376c4", "leftValue": "={{ ($json.state == \"idle\") && $('Webhook').item.json.body.data.message.conversation == \"/inicio\" || $('Webhook').item.json.body.data.message.conversation == \"hola\" }}", "rightValue": "", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "5d97e4d1-a6e8-48c3-814c-41a6ea873a05", "leftValue": "={{ ($json.state == \"report_open\") && $('Webhook').item.json.body.data.message.conversation == \"/cancelar\" }}", "rightValue": "", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "e6efc7f6-b6a6-4e45-a0c3-2a53321de3bb", "leftValue": "={{ $json.state === \"report_open\" && ![\"/cerrar\", \"/ayuda\", \"/inicio\", \"/cancelar\", \"/estado\"].includes($('Webhook').item.json.body.data.message.conversation) }}", "rightValue": "", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" } } ] }, "options": {} }, "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ -1248, -288 ], "id": "34f05a7b-6913-4881-9301-35c9b70977dc", "name": "Switch1" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=📋 *{{ $json.context.reporteID }}*\n\nTipo: {{ $json.context.tipoReporte }}\nEmpleado: {{ $json.context.empleado }} ({{ $json.context.pais }})\nMotivo: {{ $json.context.motivoDescripcion }}\nCliente: {{ $json.context.clienteProyecto }}\n{{ $json.context.anticipoRecibido != null && $json.context.anticipoRecibido !== '' ? 'Anticipo: ' + $json.context.anticipoRecibido : '' }}\n\nYa puedes empezar a enviarme tus facturas. Una imagen por mensaje, acompañada de una breve descripción del gasto.\nCuando termines, escribe /cerrar para enviar al jefe." }, { "name": "delay", "value": "={{4000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 2688, 80 ], "id": "2f4d2c84-9810-4f7a-9eff-4ff8a899a4ed", "name": "Reporte abierto" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=📋 *{{ $json.context.reporteID }}*\n\nTipo: {{ $json.context.tipoReporte }}\nEmpleado: {{ $json.context.empleado }} ({{ $json.context.pais }})\nMotivo: {{ $json.context.motivoDescripcion }}\nCliente: {{ $json.context.clienteProyecto }}\n{{ $json.context.anticipoRecibido != null && $json.context.anticipoRecibido !== '' ? 'Anticipo: ' + $json.context.anticipoRecibido : '' }}\n\nYa puedes empezar a enviarme tus facturas. Una imagen por mensaje, acompañada de una breve descripción del gasto.\nCuando termines, escribe /cerrar para enviar al jefe." }, { "name": "delay", "value": "={{4000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1296, 848 ], "id": "c9b78b43-9502-4d63-9118-d7c53490841c", "name": "Reporte abierto1" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=Comandos disponibles:\n\n📸 Manda una foto — agrego la factura\n/estado — resumen del reporte abierto\n/cerrar — cerrar y enviar a aprobación\n/cancelar — descartar el reporte\n/editar [n] — editar la factura número n\n/borrar [n] — borrar la factura número n" }, { "name": "delay", "value": "={{5000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ -976, -800 ], "id": "ce37f7a7-4e2f-4d8c-8f1d-10090452d27e", "name": "Comando ayuda" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=📋 Tu reporte *{{ $json.context.reporteID }}*\n\nTipo: {{ $json.context.tipoReporte }} ({{ $json.context.pais }})\nPeríodo: {{ $json.context.motivoDescripcion }}\nFacturas: \nEjecutado:\n{{ $json.context.anticipoRecibido != null && $json.context.anticipoRecibido !== '' ? 'Anticipo recibido: ' + $json.context.anticipoRecibido : '' }} \n{{ $json.context.anticipoRecibido != null && $json.context.anticipoRecibido !== '' ? 'Saldo a devolver: ' + \"Aqui falta poner la variable\" : '' }}\n\nCategorías:\n\nEscribe /cerrar cuando termines o sigue mandando facturas." }, { "name": "delay", "value": "={{4000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ -976, -608 ], "id": "9d0701a3-8d00-4107-9f20-e1c7fb609432", "name": "Comando estado" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/calculate_invoice_totals", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"p_report_id\": \"{{ $json.report_id }}\"\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ -976, -448 ], "id": "8321f172-d435-45d9-8acd-7994c2cdad80", "name": "Obtener info reporte" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=¿Listo para cerrar y enviar a aprobación?\n\n📋 *{{ $('Obtener status').item.json.report_id }}*\n\n{{ $json.invoice_count }} {{ $json.invoice_count === 1 ? 'factura' : 'facturas' }} · {{ $json.total_invoices }}\nSaldo a devolver: {{ $json.balance }}\n\nUna vez cerrado, se enviará a tu jefe directo ({{ $('Obtener status').item.json.context.jefeDirecto }})\ny al equipo de Finanzas para aprobación." }, { "name": "delay", "value": "={{4000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ -768, -448 ], "id": "f385286e-8ff1-47f7-8500-eabc583d062f", "name": "Comando cerrar" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/append_invoice", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"p_report_id\": {{ JSON.stringify($('Factura tiene descripcion?').item.json.report_id) }},\n \"p_invoice\": {{ JSON.stringify({\n numero: $('Detalles de factura').item.json.valores[1],\n proveedor: $('Detalles de factura').item.json.valores[2],\n rnc: $('Detalles de factura').item.json.valores[3],\n categoria: $('Detalles de factura').item.json.valores[4],\n moneda: $('Detalles de factura').item.json.valores[6],\n fecha: $('Detalles de factura').item.json.valores[0],\n subtotal: $('Detalles de factura').item.json.valores[7],\n impuesto1_tipo: $('Detalles de factura').item.json.valores[8],\n impuesto1: $('Detalles de factura').item.json.valores[10],\n impuesto2_tipo: $('Detalles de factura').item.json.valores[11],\n impuesto2: $('Detalles de factura').item.json.valores[12],\n total: parseFloat($('Detalles de factura').item.json.valores[13]),\n descripcion: $('Detalles de factura').item.json.valores[5],\n file_url: $('Detalles de factura').item.json.valores[15]\n }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 2960, 1888 ], "id": "8d82341d-741b-427d-a5f1-4d583e81849b", "name": "Insertar factura valida a la bd" }, { "parameters": { "sendTo": "eidan.then14@gmail.com", "options": {} }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ -112, -448 ], "id": "a84bdc0e-4dfa-467a-870e-c56fe000ab3d", "name": "Send a message", "webhookId": "ed5d65a4-ad2d-4660-ae9d-1f5aadae4660", "credentials": { "gmailOAuth2": { "id": "QWNicjw1khRm5BVI", "name": "Eidan - Gmail account" } }, "disabled": true }, { "parameters": { "content": "## Aqui poner confirmacion" }, "type": "n8n-nodes-base.stickyNote", "position": [ -752, -336 ], "typeVersion": 1, "id": "ca09010b-3f64-4f2c-8644-50be0b9e55e2", "name": "Sticky Note2" }, { "parameters": { "resource": "folder", "operation": "share", "folderNoRootId": { "__rl": true, "value": "={{ $('Switch1').item.json.invoice_photos_folder_id }}", "mode": "id" }, "permissionsUi": { "permissionsValues": { "role": "writer", "type": "user", "emailAddress": "eidan.then14@gmail.com" } }, "options": { "sendNotificationEmail": true } }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ -560, -528 ], "id": "84802e15-9032-4e3e-b32e-ebcd1e431a1a", "name": "Compartir fotos con jefe directo", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "resource": "folder", "operation": "share", "folderNoRootId": { "__rl": true, "value": "={{ $('Switch1').item.json.invoice_photos_folder_id }}", "mode": "id" }, "permissionsUi": { "permissionsValues": { "role": "writer", "type": "user", "emailAddress": "eidan.then14@gmail.com" } }, "options": { "sendNotificationEmail": true } }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ -560, -352 ], "id": "9c36cc1a-8bc9-4908-8b97-4ec3581ef515", "name": "Compartir fotos con finanzas pais", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "operation": "share", "fileId": { "__rl": true, "value": "={{ $('Switch1').item.json.sheet_id }}", "mode": "id" }, "permissionsUi": { "permissionsValues": { "role": "writer", "type": "user", "emailAddress": "eidan.then14@gmail.com" } }, "options": { "emailMessage": "Mensaje de ejemplo, probando", "sendNotificationEmail": true } }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ -352, -352 ], "id": "0caf546e-82a0-4823-98f0-5951bfb5430f", "name": "Compartir sheet con finanzas pais", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "operation": "share", "fileId": { "__rl": true, "value": "={{ $('Switch1').item.json.sheet_id }}", "mode": "id" }, "permissionsUi": { "permissionsValues": { "role": "writer", "type": "user", "emailAddress": "eidan.then14@gmail.com" } }, "options": { "emailMessage": "Mensaje de ejemplo, probando", "sendNotificationEmail": true } }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ -352, -528 ], "id": "cacf7fd3-c0d1-44d8-b670-f9fa0627119e", "name": "Compartir sheet con jefe directo", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "content": "## Ver si puedo mandar todo en un solo correo" }, "type": "n8n-nodes-base.stickyNote", "position": [ -272, -288 ], "typeVersion": 1, "id": "2c71b670-e9eb-45c7-8ec2-17c7edc423f6", "name": "Sticky Note10" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=⚠️ ¿Cancelar el reporte *{{ $json.context.reporteID }}*?\nSe perderán las 4 facturas registradas.\n\nResponde \"CONFIRMAR CANCELAR\" para proceder." }, { "name": "delay", "value": "={{4000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ -976, -176 ], "id": "30b9c533-e8b1-4b9f-9f8a-b4ff28f2aa25", "name": "Comando cancelar" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "draft_invoice", "fieldValue": "={{ JSON.stringify({ ...$('Edit Fields2').item.json.draft_invoice, total: parseFloat($('Webhook').item.json.body.data.message.conversation )}) }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 528, 2288 ], "id": "a1b7e539-6efd-487b-9324-514810f518ff", "name": "Insertar total", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "assignments": { "assignments": [ { "id": "965a971b-c570-4a09-bcfd-ca26e6a72080", "name": "draft_invoice", "value": "={{ $('Switch').item.json.draft_invoice }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 368, 2288 ], "id": "6186a30d-01a8-4438-be30-e5145cfdf6c4", "name": "Edit Fields2" }, { "parameters": { "assignments": { "assignments": [ { "id": "965a971b-c570-4a09-bcfd-ca26e6a72080", "name": "draft_invoice", "value": "={{ $json.draft_invoice }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 736, 2608 ], "id": "ba478640-b801-4418-a4a0-dac75821cdc5", "name": "Edit Fields4" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "35e7fdb8-9add-4e4d-b1ab-ca1a20caf186", "leftValue": "={{ $json.tiene_faltantes }}", "rightValue": false, "operator": { "type": "boolean", "operation": "false", "singleValue": true } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ 1072, 2608 ], "id": "e6dc31ab-e2c9-43f2-bf7e-c2085d19681b", "name": "Campo faltante?2" }, { "parameters": { "jsCode": "const data = $('Edit Fields4').first().json.draft_invoice;\n\nconst camposRequeridos = {\n fecha: data.fecha,\n proveedor: data.proveedor,\n nif_glm: data.nif_glm,\n total: data.total\n};\n\nconst camposFaltantes = Object.entries(camposRequeridos)\n .filter(([_, valor]) => valor === null || valor === undefined || valor === \"\")\n .map(([campo]) => campo);\n\nreturn [{\n json: {\n campos_faltantes: camposFaltantes,\n tiene_faltantes: camposFaltantes.length > 0,\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 896, 2608 ], "id": "444281e7-b26d-4db1-9087-4fb0d1f6ea41", "name": "Detectar valor critico1" }, { "parameters": { "jsCode": "const camposFaltantes = $('Detectar valor critico1').first().json.campos_faltantes;\nconst campo = camposFaltantes[0];\n\nconst statusMap = {\n fecha: \"awaiting_fecha\",\n proveedor: \"awaiting_proveedor\",\n nif_glm: \"awaiting_nif_glm\",\n total: \"awaiting_total\"\n};\n\nconst status = statusMap[campo] ?? \"awaiting_unknown\";\nconst texto =\n campo === \"total\" ? \"No pude detectar el *total* de la factura. Por favor escríbelo aquí para continuar.\" :\n campo === \"proveedor\" ? \"No pude detectar el *proveedor* de la factura. Por favor escríbelo aquí para continuar.\" :\n campo === \"nif_glm\" ? \"No pude detectar el *RNC* en la factura. Por favor escríbelo aquí para continuar.\" : \n campo === \"fecha\" ? \"No pude detectar la *fecha* de la factura. Por favor escribelo aqui para continuar.\" : \"\"\n \nreturn [{ json: { status, texto } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1280, 2736 ], "id": "75bfa968-99c2-45e7-8ca4-b0f81bc5b5d5", "name": "Awaiting4" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "={{ $json.status }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 1440, 2736 ], "id": "6fd8aeb5-5e9e-4dd2-8f49-9cde6995bfae", "name": "Actualizar status a awaiting2", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "={{ $('Awaiting4').item.json.texto }}" }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1632, 2736 ], "id": "44844aa3-0184-4524-a50c-ca2d7c07d528", "name": "Enviar alerta falta info2" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "report_open" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 1280, 2560 ], "id": "2328807e-c3fb-47f9-961b-dd31c118b0a7", "name": "Actualizar status a report_open", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "assignments": { "assignments": [ { "id": "965a971b-c570-4a09-bcfd-ca26e6a72080", "name": "draft_invoice", "value": "={{ $('Switch').item.json.draft_invoice }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 368, 2496 ], "id": "2063a3ae-d56b-41f5-93dd-c2416d93b21e", "name": "Edit Fields5" }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D13\", \"values\": [[\"{{ $('Webhook').item.json.body.data.message.conversation }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 192, 2496 ], "id": "292bc28f-d4c3-4d15-b9e3-aac8e13478b1", "name": "Insertar proveedor de la factura", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "draft_invoice", "fieldValue": "={{ JSON.stringify({ ...$('Edit Fields5').item.json.draft_invoice, proveedor: $('Webhook').item.json.body.data.message.conversation }) }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 528, 2496 ], "id": "bbd87c71-795b-48b9-b3ba-8861e0f1ffcc", "name": "Insertar proveedor", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "assignments": { "assignments": [ { "id": "965a971b-c570-4a09-bcfd-ca26e6a72080", "name": "draft_invoice", "value": "={{ $('Switch').item.json.draft_invoice }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 368, 2688 ], "id": "99f830e8-a979-4ad1-a063-b64a1e54411f", "name": "Edit Fields6" }, { "parameters": { "assignments": { "assignments": [ { "id": "965a971b-c570-4a09-bcfd-ca26e6a72080", "name": "draft_invoice", "value": "={{ $('Switch').item.json.draft_invoice }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 368, 2864 ], "id": "05da15f6-c08a-424c-8af8-859255a33db7", "name": "Edit Fields7" }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D13\", \"values\": [[\"{{ $('Webhook').item.json.body.data.message.conversation }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 192, 2688 ], "id": "37e6deb8-d892-4d4d-83a8-16efb4b4c8be", "name": "Insertar rnc de la factura", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "draft_invoice", "fieldValue": "={{ JSON.stringify({ ...$('Edit Fields6').item.json.draft_invoice, nif_glm: $('Webhook').item.json.body.data.message.conversation }) }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 528, 2688 ], "id": "ad7ff633-df1f-4d92-b0e0-d8ab3404b628", "name": "Insertar rnc", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D13\", \"values\": [[\"{{ $('Webhook').item.json.body.data.message.conversation }}\"]] }\n \n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 192, 2864 ], "id": "4e0c335d-0af1-4db6-a6bd-b8cb4d1ea071", "name": "Insertar fecha de la factura", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Obtener status').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "draft_invoice", "fieldValue": "={{ JSON.stringify({ ...$('Edit Fields7').item.json.draft_invoice, fecha: $('Webhook').item.json.body.data.message.conversation }) }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 528, 2864 ], "id": "03b8ba19-34ea-4759-97e1-d4f32b9421db", "name": "Insertar fecha", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=📸 *Factura procesada*:\n\n🏢 {{ $json.draft_invoice.proveedor }}\n📄 {{ $json.draft_invoice.numero_factura }}\n📅 {{ $json.draft_invoice.fecha }}\n💰 Subtotal {{ $json.draft_invoice.moneda }} {{ $json.draft_invoice.subtotal }}\n {{ $('Edit Fields').item.json.output.impuesto1_tipo }} {{ $('Edit Fields').item.json.output.impuesto1_porciento }}% → {{ $('Edit Fields').item.json.output.impuesto1_monto }}\n *Total {{ $json.draft_invoice.moneda }} {{ $json.draft_invoice.total }}*\n📂 {{ $json.draft_invoice.gasto_categoria }}\n\n¿Está correcto?" }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1632, 2560 ], "id": "f0da2da8-d6cc-4370-b785-31f72f3f84c1", "name": "Confirmacion factura recibida1" }, { "parameters": { "assignments": { "assignments": [ { "id": "965a971b-c570-4a09-bcfd-ca26e6a72080", "name": "draft_invoice", "value": "={{ $json.draft_invoice }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 1440, 2560 ], "id": "d7f84785-197d-4055-a569-7670159ab266", "name": "Edit Fields8" }, { "parameters": { "content": "## Botones de confirmacion si quiere editar" }, "type": "n8n-nodes-base.stickyNote", "position": [ 1760, 2560 ], "typeVersion": 1, "id": "bb40e0ca-928f-4012-bfe3-3a85eb21d8d7", "name": "Sticky Note11" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=✅ ¡Listo! Tu factura ha sido guardada exitosamente." }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1984, 2576 ], "id": "0ed48df8-a9e7-4e2b-a5d0-abb4c9d8ba1d", "name": "Enviar mensaje de exito" }, { "parameters": { "content": "## Valores criticos faltantes de la factura", "height": 832, "width": 1920, "color": 3 }, "type": "n8n-nodes-base.stickyNote", "position": [ 160, 2208 ], "typeVersion": 1, "id": "79e667ee-3c45-4b39-b7d3-6d82eb2a52d4", "name": "Sticky Note12" }, { "parameters": { "content": "## Valores faltantes del contexto", "height": 1184, "width": 1520, "color": 3 }, "type": "n8n-nodes-base.stickyNote", "position": [ 144, 384 ], "typeVersion": 1, "id": "4d302623-74b3-4084-add4-af4e12c4f5b6", "name": "Sticky Note13" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ tipoReporte: $('Reembolso').item.json.tipoReporte }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 1264, -176 ], "id": "c7a8ca7b-07e5-4f1b-98ce-f41b2d16c369", "name": "Insertar reembolso en la bd" }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ tipoReporte: $('Anticipo').item.json.tipoReporte }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 1264, -384 ], "id": "444e6d6c-252e-40a9-a4e1-4103fd746d86", "name": "Insertar anticipo en la bd" }, { "parameters": { "content": "## Crear carpetas y reporte", "height": 400, "width": 2704, "color": 4 }, "type": "n8n-nodes-base.stickyNote", "position": [ 160, -848 ], "typeVersion": 1, "id": "3031d44a-c570-4ca3-bd84-d3d625b5fc9c", "name": "Sticky Note14" }, { "parameters": { "content": "## Procesar mensajes\n\nDetecta si es un audio o texto", "height": 352, "width": 1136, "color": 6 }, "type": "n8n-nodes-base.stickyNote", "position": [ 288, 32 ], "typeVersion": 1, "id": "83459f99-79d7-4b7d-8bee-916a2da61051", "name": "Sticky Note15" }, { "parameters": { "content": "## Insertar contexto a la bd, cambia el status a report_open y abrir reporte", "height": 240, "width": 704, "color": 4 }, "type": "n8n-nodes-base.stickyNote", "position": [ 2112, 0 ], "typeVersion": 1, "id": "d02ed269-ab2d-47e0-a383-f9f5e4a5549b", "name": "Sticky Note16" }, { "parameters": { "content": "## Insertar tipo de reporte al sheets y bd", "height": 448, "width": 1248, "color": 4 }, "type": "n8n-nodes-base.stickyNote", "position": [ 160, -432 ], "typeVersion": 1, "id": "51612150-a5dd-44e2-aade-da86ec7b335d", "name": "Sticky Note17" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=⚠️ Esta factura es del {{ $('Factura es valida?').item.json.output.fecha }}, pero tu reporte es del {{ $json.fecha }}.\n\n¿Qué hago?\n1️⃣ Agregarla igual (caso excepcional)\n2️⃣ Cambiar el período del reporte\n3️⃣ Descartar" }, { "name": "delay", "value": "={{2000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 2240, 1872 ], "id": "eeccb194-7499-49f7-94f7-1a02e421ba30", "name": "Alerta factura fuera de periodo" }, { "parameters": { "jsCode": "const inicio = $('Es imagen?').first().json.context.periodoInicio.split(' ');\nconst fin = $('Es imagen?').first().json.context.periodoFinalizacion.split(' ');\n\n\nreturn {\n fecha: `${inicio[0]} al ${fin[0]} de ${fin[1]} ${fin[2]}`\n}" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 2064, 1872 ], "id": "7dbae3be-2ccf-4032-a409-a5ba48a5096a", "name": "Fecha periodo" }, { "parameters": { "rules": { "values": [ { "conditions": { "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "leftValue": "={{ [\"1\", \"Agregarla\", \"agregarla\", \"Agregar\", \"agregar\"].includes($('Webhook').item.json.body.data.message.conversation).toString() }}", "rightValue": "=true", "operator": { "type": "string", "operation": "equals" }, "id": "e586aecc-ad7d-43b0-86c7-52ffe9a395c1" } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "99c670dc-8bba-4d78-9adc-2b2824a1e811", "leftValue": "={{ [\"2\", \"Cambiar\", \"cambiar\"].includes($('Webhook').item.json.body.data.message.conversation).toString() }}", "rightValue": "=true", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "72a3027d-a437-4721-a2b1-dc8ebc779f61", "leftValue": "={{ [\"3\", \"Descartar\", \"descartar\"].includes($('Webhook').item.json.body.data.message.conversation) }}", "rightValue": "false", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "87f75a76-c1a6-42d2-8f2a-f2785df5b9f0", "leftValue": "={{ ![\"1\", \"Agregarla\", \"agregarla\", \"Agregar\", \"agregar\", \"2\", \"Cambiar\", \"cambiar\", \"3\", \"Descartar\", \"descartar\", \"descartar\"].includes($('Webhook').item.json.body.data.message.conversation) }}", "rightValue": "", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" } } ] }, "options": { "ignoreCase": true } }, "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ 192, 3184 ], "id": "d442054d-b71d-4b03-8b63-5e28b12e6d31", "name": "Opciones fecha afuera periodo" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Es imagen?').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "=awaiting_fechaFuera" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 1504, 1872 ], "id": "d4979db7-4e2f-42d1-8b2a-882e0aeef049", "name": "Actualizar awaiting_fechaFuera", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "https://script.google.com/macros/s/AKfycbwB3R5Wv2rKUvJTd1gsJn1kPkOLGbdzIgqNgwxGRkIxU_xGyThp1g2OE9R-7aPvLXc/exec", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify($json) }}", "options": { "redirect": { "redirect": {} } } }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 1520, 3056 ], "id": "c92f3b85-7857-479c-810f-ed129c7095c8", "name": "Insertar detalles de la factura al sheets1" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=📸 *Factura procesada*:\n\n🏢 {{ $('Edit Fields10').item.json.draft_invoice.factura.proveedor }}\n📄 {{ $('Edit Fields10').item.json.draft_invoice.factura.numero_factura }}\n📅 {{ $('Edit Fields10').item.json.draft_invoice.factura.fecha }}\n💰 Subtotal {{ $('Edit Fields10').item.json.draft_invoice.factura.moneda }} {{ $('Edit Fields10').item.json.draft_invoice.factura.subtotal }}\n {{ $('Edit Fields10').item.json.draft_invoice.factura.impuesto1_tipo }} {{ $('Edit Fields10').item.json.draft_invoice.factura.impuesto1_porciento }}% → {{ $('Edit Fields10').item.json.draft_invoice.factura.impuesto1_monto }}\n *Total {{ $('Edit Fields10').item.json.draft_invoice.factura.moneda }} {{ $('Edit Fields10').item.json.draft_invoice.factura.total }}*\n📂 {{ $('Edit Fields10').item.json.draft_invoice.factura.gasto_categoria }}\n\n¿Está correcto?" }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1712, 3056 ], "id": "471d6dbd-c57d-4ee8-b6f3-1b22a317e2bb", "name": "Confirmacion factura recibida2" }, { "parameters": { "jsCode": "const output = $('Edit Fields10').first().json.draft_invoice.factura;\n\nreturn [{\n json: {\n spreadsheetId: $('Opciones fecha afuera periodo').first().json.sheet_id,\n valores: [\n output.fecha || \"-\",\n output.numero_factura || \"-\",\n output.proveedor || \"-\",\n output.nif_glm || \"-\",\n output.gasto_categoria || \"-\",\n $('Webhook').first().json.caption,\n output.moneda || \"-\",\n output.subtotal || \"ninguno\",\n output.impuesto1_tipo || \"ninguno\",\n output.impuesto1_porciento || \"ninguno\",\n output.impuesto1_monto || \"0.00\",\n output.impuesto2_tipo || \"ninguno\",\n output.impuesto2_monto || \"0.00\",\n output.total || \"0.00\",\n \"-\",\n $input.first().json.webViewLink || \"-\",\n ]\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1344, 3056 ], "id": "a237173b-9353-4063-a2c7-6f21b76d2ed8", "name": "Detalles de factura1" }, { "parameters": { "resource": "audio", "operation": "analyze", "modelId": { "__rl": true, "value": "models/gemini-pro-latest", "mode": "list", "cachedResultName": "models/gemini-pro-latest" }, "text": "Que contiene este audio?\n\nDespues de extraer este audio debes analizar el texto y detectar los siguientes valores:\n- Fecha de periodo de inicio\n- Fecha de periodo de finalizacion\n", "inputType": "binary", "options": {} }, "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ 832, 3760 ], "id": "ba190f10-167a-4961-91f1-819aed748457", "name": "Analyze audio1", "credentials": { "googlePalmApi": { "id": "tFqBJras00HUi1hA", "name": "Eidan - Google Gemini(PaLM) Api account" } } }, { "parameters": { "operation": "toBinary", "sourceProperty": "base64", "options": { "mimeType": "={{ $json.mimetype }}" } }, "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ 640, 3760 ], "id": "78456797-9b50-4385-a68f-0bf854720b3e", "name": "Convert to File3" }, { "parameters": { "rules": { "values": [ { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "leftValue": "={{ $('Webhook').item.json.body.data.messageType }}", "rightValue": "audioMessage", "operator": { "type": "string", "operation": "equals" }, "id": "34251b5f-5d31-4a40-9fdb-5a057d6a4218" } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "d43ac8f7-aa7b-4737-b13f-aa24b5393c23", "leftValue": "={{ $('Webhook').item.json.body.data.messageType }}", "rightValue": "conversation", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } } ] }, "options": {} }, "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ 192, 3856 ], "id": "b0b10778-5dcf-48d7-815b-389794a71272", "name": "Audio o texto1" }, { "parameters": { "modelId": { "__rl": true, "value": "models/gemini-2.5-flash", "mode": "list", "cachedResultName": "models/gemini-2.5-flash" }, "messages": { "values": [ { "content": "={{ $json.content.parts[0].text }}" }, { "content": "=En el texto debes detectar los siguientes valores:\n- Fecha de periodo de inicio\n- Fecha de periodo de finalizacion\n\n## Formato\n- Debes insertar las fechas de periodoInicio y periodoFinalizacion en este formato: dd (mes nombre) yyyy, ejemplo: 04 mayo 2026.\n\nLuego de detectar esos valores, crea un JSON valido:\n{\n periodoInicio: \"fecha de periodo de inicio\" || null,\n periodoFinalizacion: \"fecha de periodo de finalizacion\" || null,\n} ", "role": "model" } ] }, "jsonOutput": true, "builtInTools": {}, "options": {} }, "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ 1008, 3760 ], "id": "b3a9dfed-0d4b-4e21-bc58-5f961d51510f", "name": "Message a model2", "credentials": { "googlePalmApi": { "id": "tFqBJras00HUi1hA", "name": "Eidan - Google Gemini(PaLM) Api account" } } }, { "parameters": { "assignments": { "assignments": [ { "id": "4bf34faf-ead0-491f-90a2-199fb7e8c6fa", "name": "content.parts[0].text", "value": "={{ $json.content.parts[0].text }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 1360, 3856 ], "id": "7dd5a395-0983-439b-b8ad-1a216640bce9", "name": "Edit Fields9" }, { "parameters": { "modelId": { "__rl": true, "value": "models/gemini-2.5-flash", "mode": "list", "cachedResultName": "models/gemini-2.5-flash" }, "messages": { "values": [ { "content": "={{ $('Webhook').item.json.body.data.message.conversation }}" }, { "content": "En el texto debes detectar los siguientes valores:\n- Fecha de periodo de inicio\n- Fecha de periodo de finalizacion\n\n## Formato\n- Debes insertar las fechas de periodoInicio y periodoFinalizacion en este formato: dd (mes nombre) yyyy, ejemplo: 04 mayo 2026.\n\nLuego de detectar esos valores, crea un JSON valido:\n{\n periodoInicio: \"fecha de periodo de inicio\" || null,\n periodoFinalizacion: \"fecha de periodo de finalizacion\" || null,\n} ", "role": "model" } ] }, "jsonOutput": true, "builtInTools": {}, "options": {} }, "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ 672, 3952 ], "id": "625bf77b-db79-4da3-b8ab-c16482398523", "name": "Message a model3", "credentials": { "googlePalmApi": { "id": "tFqBJras00HUi1hA", "name": "Eidan - Google Gemini(PaLM) Api account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/chat/getBase64FromMediaMessage/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "message.key.id", "value": "={{ $('Webhook').item.json.body.data.key.id }}" }, { "name": "convertToMp4", "value": "={{ Boolean(false) }}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 464, 3760 ], "id": "97eaaed4-77d6-47ca-972c-3bf6da6f68cb", "name": "Descargar audio1" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Switch').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "=awaiting_nuevaFechaPeriodo" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 464, 3232 ], "id": "314bcb45-82fd-4f9f-ad3f-1803706944cf", "name": "Actualizar awaiting_nuevaFechaPeriodo", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=Manda un texto o un audio de las nuevas fecha de periodo de inicio y finalización." }, { "name": "delay", "value": "={{3000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 656, 3232 ], "id": "b11090e2-8c2c-4820-92b5-6f25edc9f8ee", "name": "Pedir nueva fecha periodo" }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "number", "value": "={{ \"18097159076@s.whatsapp.net\" }}" }, { "name": "mediatype", "value": "=image" }, { "name": "text", "value": "=Opción no válida. Por favor responde con el número o nombre del tipo de reporte:\n\n1️⃣ Anticipo\n2️⃣ Reembolso" }, { "name": "delay", "value": "={{5000}}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 464, 3584 ], "id": "c0bd3237-e44b-4fb9-8f01-893ddc10f165", "name": "Alerta opcion no valida1" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Switch').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "=report_open" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 656, 3408 ], "id": "3bef8c72-a52f-4fb9-b4fe-cfbffbb0b532", "name": "Actualizar report_open", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Es imagen?').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "draft_invoice", "fieldValue": "={{ JSON.stringify($json) }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 1888, 1872 ], "id": "c3aa54bd-745e-4b48-9efa-e03b3f3eb929", "name": "Guardar factura temporalmente1", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "jsCode": "return [{\n json: {\n fecha: $('Edit Fields').first().json.output.fecha || null,\n numero_factura: $('Edit Fields').first().json.output.numero_factura || null,\n proveedor: $('Edit Fields').first().json.output.proveedor || null,\n nif_glm: $('Edit Fields').first().json.output.nif_glm || null,\n gasto_categoria: $('Edit Fields').first().json.output.gasto_categoria || null,\n moneda: $('Edit Fields').first().json.output.moneda || null,\n subtotal: $('Edit Fields').first().json.output.subtotal || null,\n impuesto1_tipo: $('Edit Fields').first().json.output.impuesto1_tipo || null,\n impuesto1_porciento: $('Edit Fields').first().json.output.impuesto1_porciento || null,\n impuesto1_monto: $('Edit Fields').first().json.output.impuesto1_monto || null,\n impuesto2_tipo: $('Edit Fields').first().json.output.impuesto2_tipo || null,\n impuesto2_monto: $('Edit Fields').first().json.output.impuesto2_monto || null,\n total: $('Edit Fields').first().json.output.total || null,\n \n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1504, 2048 ], "id": "6f90773a-38fa-4b53-8d23-7d56eb9e19dc", "name": "Detalles de factura2" }, { "parameters": { "assignments": { "assignments": [ { "id": "965a971b-c570-4a09-bcfd-ca26e6a72080", "name": "draft_invoice", "value": "={{ $('Switch').item.json.draft_invoice }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 464, 3056 ], "id": "02df5dc1-4ce4-4b18-b368-347269abd9bc", "name": "Edit Fields10" }, { "parameters": { "jsCode": "return {\n base64: $('Descargar imagen de whatsapp').first().json.base64,\n mimetype: $('Descargar imagen de whatsapp').first().json.mimetype\n}" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 2112, 1696 ], "id": "456e9864-ce69-49d0-908a-741668f748b1", "name": "Binarios" }, { "parameters": { "jsCode": "return [{\n json: {\n base64: $('Descargar imagen de whatsapp').first().json.base64,\n mimetype: $('Descargar imagen de whatsapp').first().json.mimetype,\n factura: {\n fecha: $('Edit Fields').first().json.output.fecha || null,\n numero_factura: $('Edit Fields').first().json.output.numero_factura || null,\n proveedor: $('Edit Fields').first().json.output.proveedor || null,\n nif_glm: $('Edit Fields').first().json.output.nif_glm || null,\n gasto_categoria: $('Edit Fields').first().json.output.gasto_categoria || null,\n moneda: $('Edit Fields').first().json.output.moneda || null,\n subtotal: $('Edit Fields').first().json.output.subtotal || null,\n impuesto1_tipo: $('Edit Fields').first().json.output.impuesto1_tipo || null,\n impuesto1_porciento: $('Edit Fields').first().json.output.impuesto1_porciento || null,\n impuesto1_monto: $('Edit Fields').first().json.output.impuesto1_monto || null,\n impuesto2_tipo: $('Edit Fields').first().json.output.impuesto2_tipo || null,\n impuesto2_monto: $('Edit Fields').first().json.output.impuesto2_monto || null,\n total: $('Edit Fields').first().json.output.total || null,\n }\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1712, 1872 ], "id": "0a97a718-1eba-4269-a3b7-49af7ede87a2", "name": "Detalles de factura y binarios imagen" }, { "parameters": { "inputDataFieldName": "=data", "name": "=IMG_{{ $('Generar timestamp1').item.json.timestamp }}", "driveId": { "__rl": true, "mode": "list", "value": "My Drive" }, "folderId": { "__rl": true, "value": "={{ $('Opciones fecha afuera periodo').item.json.invoice_photos_folder_id }}", "mode": "id" }, "options": {} }, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 1168, 3056 ], "id": "964fbb71-b9c0-4e65-a9c3-e4fac1a117f1", "name": "Upload file1", "credentials": { "googleDriveOAuth2Api": { "id": "gL2ZTwJb6xojauac", "name": "Eidan - Google Drive account" } } }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Opciones fecha afuera periodo').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "draft_invoice", "fieldValue": "={{ null }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 1904, 3056 ], "id": "b61cd0f1-435f-49d6-86b6-2f86dddaf09a", "name": "Borrar factura temporal", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "jsCode": "const now = new Date(new Date().toLocaleString('en-US', { timeZone: 'America/Santo_Domingo' }));\n\nconst pad = n => String(n).padStart(2, '0');\n\nconst dd = pad(now.getDate());\nconst mm = pad(now.getMonth() + 1);\nconst yyyy = now.getFullYear();\n\nreturn [{\n json: {\n timestamp: `${dd}-${mm}-${yyyy}`\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 640, 3056 ], "id": "e1e05aa1-ad22-4c76-8184-6f0ad2b37a09", "name": "Generar timestamp1" }, { "parameters": { "operation": "toBinary", "sourceProperty": "base64", "options": { "mimeType": "={{ $json.mimetype }}" } }, "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ 992, 3056 ], "id": "b1f4cf97-4393-4a7d-b4ea-51713b7e6515", "name": "Convert to File4" }, { "parameters": { "jsCode": "return {\n base64: $('Edit Fields10').first().json.draft_invoice.base64,\n mimetype: $('Edit Fields10').first().json.draft_invoice.mimetype\n}" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 816, 3056 ], "id": "d82bdcc5-84c8-4f42-82c9-ccbb4b467efe", "name": "Binarios1" }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Switch').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "draft_invoice", "fieldValue": "={{ null }}" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 464, 3408 ], "id": "c2b56a96-499c-44b6-8e82-c876fcd0724d", "name": "Borrar factura temporal1", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Switch').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "=report_open" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 2096, 3056 ], "id": "76c49f9f-eac8-42af-a629-04aea5250f9f", "name": "Actualizar status a report_open3", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "operation": "update", "tableId": "user_states", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", "keyValue": "={{ $('Switch').item.json.phone }}" } ] }, "fieldsUi": { "fieldValues": [ { "fieldId": "state", "fieldValue": "=report_open" } ] } }, "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ 1920, 3856 ], "id": "645c3d1e-2622-4de5-a6d6-6fb9ec78687c", "name": "Actualizar report_open1", "credentials": { "supabaseApi": { "id": "yoWccgZ7JLKAGZPr", "name": "Eidan reembolso - Supabase account" } } }, { "parameters": { "method": "POST", "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $('Switch').item.json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"valueInputOption\": \"USER_ENTERED\",\n \"data\": [\n { \"range\": \"Liquidación!D10\", \"values\": [[\"{{ $json.content.parts[0].text.periodoInicio }}\"]] },\n { \"range\": \"Liquidación!D11\", \"values\": [[\"{{ $json.content.parts[0].text.periodoFinalizacion }}\"]] }\n ]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 1536, 3856 ], "id": "20dd69ef-164b-45dd-be04-54d8877bab7b", "name": "Insertar nuevo periodo al sheet", "credentials": { "googleOAuth2Api": { "id": "0HsSRUm82KPsWdiJ", "name": "Eidan - Google account" } } }, { "parameters": { "method": "POST", "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" }, { "name": "Authorization", "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ \nperiodoInicio: $('Edit Fields9').item.json.content.parts[0].text.periodoInicio, \nperiodoFinalizacion: $('Edit Fields9').item.json.content.parts[0].text.periodoFinalizacion }) \n\n}}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ 1728, 3856 ], "id": "07c6e4d1-e68e-4466-beab-7239d81cdb1f", "name": "Insertar nuevo periodo en la bd" }, { "parameters": { "resource": "audio", "operation": "analyze", "modelId": { "__rl": true, "value": "models/gemini-pro-latest", "mode": "list", "cachedResultName": "models/gemini-pro-latest" }, "text": "Que contiene este audio?\n\nDespues de extraer este audio debes analizar el texto y detectar los siguientes valores:\n- Ruta de viaje\n- Cantidad de dinero del anticipo\n- Fecha de periodo de inicio\n- Fecha de periodo de finalizacion\n- Motivo o destino del viaje\n- Cliente o proyecto\n", "inputType": "binary", "options": {} }, "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ 2368, 848 ], "id": "d65ef80f-512f-45bb-b4b3-ac735ae90a74", "name": "Analyze audio2", "credentials": { "googlePalmApi": { "id": "tFqBJras00HUi1hA", "name": "Eidan - Google Gemini(PaLM) Api account" } } }, { "parameters": { "operation": "toBinary", "sourceProperty": "base64", "options": { "mimeType": "={{ $json.mimetype }}" } }, "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ 2176, 848 ], "id": "4d310c8f-e30e-4d03-b581-9dc9172b843e", "name": "Convert to File5" }, { "parameters": { "rules": { "values": [ { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "leftValue": "={{ $('Webhook').item.json.body.data.messageType }}", "rightValue": "audioMessage", "operator": { "type": "string", "operation": "equals" }, "id": "34251b5f-5d31-4a40-9fdb-5a057d6a4218" } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "d43ac8f7-aa7b-4737-b13f-aa24b5393c23", "leftValue": "={{ $('Webhook').item.json.body.data.messageType }}", "rightValue": "conversation", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "and" } } ] }, "options": {} }, "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ 1728, 944 ], "id": "bdf9f66a-2a17-45ea-9d7e-c2bfab3b53df", "name": "Audio o texto2" }, { "parameters": { "modelId": { "__rl": true, "value": "models/gemini-2.5-flash", "mode": "list", "cachedResultName": "models/gemini-2.5-flash" }, "messages": { "values": [ { "content": "={{ $json.content.parts[0].text }}" }, { "content": "=Tipo de reporte: {{ $('Switch').item.json.context.tipoReporte }}\n\nEn el texto debes detectar los siguientes valores:\n- Ruta de viaje\n- Cantidad de dinero del anticipo\n- Fecha de periodo de inicio\n- Fecha de periodo de finalizacion\n- Motivo o destino del viaje\n- Cliente o proyecto\n\n## Reglas\n- Al insertar el valor del anticpoRecibido solo inserta el monto sin las palabras \"pesos, dolares\" y tampoco simbolos. Debes devolverlos con este formato: 0.00\n- Si el tipo de reporte es \"Liquidación Reembolso\", NO insertes en el JSON la ruta y y dinero del anticipo (anticipoRecibido). Ambos valores ruta y anticipoRecibido deben ser VACIOS, NO null.\n\n## Formato\n- Debes insertar las fechas de periodoInicio y periodoFinalizacion en este formato: dd (mes nombre) yyyy, ejemplo: 04 mayo 2026.\n- Si el usuario dice una ruta asi \"Desde Santo Domingo a Punta Cana y regreso a Santo Domingo\" debes formatearlo asi: \"Santo Domingo > Punta Cana > Santo Domingo\".\n\nLuego de detectar esos valores, crea un JSON valido:\n{\n ruta: \"ruta de viaje\" || null,\n anticipoRecibido: \"dinero anticipo\" || null,\n periodoInicio: \"fecha de periodo de inicio\" || null,\n periodoFinalizacion: \"fecha de periodo de finalizacion\" || null,\n motivoDescripcion: \"motivo o destino\" || null,\n clienteProyecto: \"cliente o proyecto\" || null\n} ", "role": "model" } ] }, "jsonOutput": true, "builtInTools": {}, "options": {} }, "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ 2544, 848 ], "id": "f9f8c1cf-8223-41df-aa29-4e05fd23e941", "name": "Message a model4", "credentials": { "googlePalmApi": { "id": "tFqBJras00HUi1hA", "name": "Eidan - Google Gemini(PaLM) Api account" } } }, { "parameters": { "assignments": { "assignments": [ { "id": "4bf34faf-ead0-491f-90a2-199fb7e8c6fa", "name": "content.parts[0].text", "value": "={{ $json.content.parts[0].text }}", "type": "object" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 2896, 944 ], "id": "6bb38dfb-5903-41a7-9b07-dd641f8515cf", "name": "Edit Fields11" }, { "parameters": { "modelId": { "__rl": true, "value": "models/gemini-2.5-flash", "mode": "list", "cachedResultName": "models/gemini-2.5-flash" }, "messages": { "values": [ { "content": "={{ $('Webhook').item.json.body.data.message.conversation }}" }, { "content": "Tipo de reporte: {{ $('Switch').item.json.context.tipoReporte }}\n\nEn el texto debes detectar los siguientes valores:\n- Ruta de viaje\n- Cantidad de dinero del anticipo\n- Fecha de periodo de inicio\n- Fecha de periodo de finalizacion\n- Motivo o destino del viaje\n- Cliente o proyecto\n\n## Reglas\n- Al insertar el valor del anticpoRecibido solo inserta el monto sin las palabras \"pesos, dolares\" y tampoco simbolos. Debes devolverlos con este formato: 0.00\n- Si el tipo de reporte es \"Liquidación Reembolso\", NO insertes en el JSON la ruta y y dinero del anticipo (anticipoRecibido). Ambos valores ruta y anticipoRecibido deben ser VACIOS, NO null.\n\n## Formato\n- Debes insertar las fechas de periodoInicio y periodoFinalizacion en este formato: dd (mes nombre) yyyy, ejemplo: 04 mayo 2026.\n- Si el usuario dice una ruta asi \"Desde Santo Domingo a Punta Cana y regreso a Santo Domingo\" debes formatearlo asi: \"Santo Domingo > Punta Cana > Santo Domingo\".\n\nLuego de detectar esos valores, crea un JSON valido:\n{\n ruta: \"ruta de viaje\" || null,\n anticipoRecibido: \"dinero anticipo\" || null,\n periodoInicio: \"fecha de periodo de inicio\" || null,\n periodoFinalizacion: \"fecha de periodo de finalizacion\" || null,\n motivoDescripcion: \"motivo o destino\" || null,\n clienteProyecto: \"cliente o proyecto\" || null\n}", "role": "model" } ] }, "jsonOutput": true, "builtInTools": {}, "options": {} }, "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ 2208, 1040 ], "id": "149b4ff8-ba2a-4ece-9f68-6536f869aca3", "name": "Message a model5", "credentials": { "googlePalmApi": { "id": "tFqBJras00HUi1hA", "name": "Eidan - Google Gemini(PaLM) Api account" } } }, { "parameters": { "method": "POST", "url": "={{'https://wsp.gomezleemarketing.com'}}/chat/getBase64FromMediaMessage/{{'botsoporte'}}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", "value": "={{'C267126ABB45-4C12-B626-6BAB1833F5D7'}}" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "message.key.id", "value": "={{ $('Webhook').item.json.body.data.key.id }}" }, { "name": "convertToMp4", "value": "={{ Boolean(false) }}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 2000, 848 ], "id": "8a09674d-fe34-44ee-b125-2f7538deeb1a", "name": "Descargar audio2" }, { "parameters": { "method": "POST", "url": "=https://git.digitalcompass.agency/api/v1/repos/EidanThen/{{ $('Valores').item.json.repo_name }}/contents/{{ $('Valores').item.json.file_name }}.json", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Authorization", "value": "token f68f177ebd3d5795ffc09c1cd880c4007b063fd8" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"message\": \"{{ $json.message }}\",\n \"content\": \"{{ $json.content }}\",\n \"branch\": \"{{ $json.branch }}\"\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ -2400, -304 ], "id": "c0f663e4-8f67-47a6-902b-f02b7c62d30c", "name": "Subir archivo", "retryOnFail": false }, { "parameters": { "url": "=https://git.digitalcompass.agency/api/v1/repos/EidanThen/{{ $json.repo_name }}/contents/{{ $json.file_name }}.json", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "sendHeaders": true, "headerParameters": { "parameters": [] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ -3008, -416 ], "id": "9fe01190-a6b0-48b5-bff0-68740fe7c8dc", "name": "Obtener archivo", "credentials": { "httpHeaderAuth": { "id": "KMhOYCzV5kCW5ztz", "name": "Header Auth account 3" } }, "onError": "continueErrorOutput" }, { "parameters": { "method": "PUT", "url": "=https://git.digitalcompass.agency/api/v1/repos/EidanThen/{{ $('Valores').item.json.repo_name }}/contents/{{ $('Valores').item.json.file_name }}.json", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Authorization", "value": "token f68f177ebd3d5795ffc09c1cd880c4007b063fd8" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"message\": \"{{ $json.message }}\",\n \"content\": \"{{ $json.content }}\",\n \"sha\": \"{{ $json.sha }}\",\n \"branch\": \"{{ $json.branch }}\"\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ -2400, -512 ], "id": "91e04338-dd73-41fc-8557-5eb5815a9006", "name": "Actualizar archivo" }, { "parameters": { "operation": "get", "workflowId": { "__rl": true, "value": "eM8ZZafSC9M8GYd4", "mode": "list", "cachedResultName": "Procesador de facturas VERSION AUDIO (#eM8ZZafSC9M8GYd4)" }, "requestOptions": {} }, "type": "n8n-nodes-base.n8n", "typeVersion": 1, "position": [ -2752, -512 ], "id": "97b1058d-9a9c-4179-beb0-7e44ae4bb4b0", "name": "Get a workflow1", "credentials": { "n8nApi": { "id": "73Ydc9X8h5HXvFrt", "name": "Eidan - n8n account" } } }, { "parameters": { "operation": "get", "workflowId": { "__rl": true, "value": "eM8ZZafSC9M8GYd4", "mode": "list", "cachedResultName": "Procesador de facturas VERSION AUDIO (#eM8ZZafSC9M8GYd4)" }, "requestOptions": {} }, "type": "n8n-nodes-base.n8n", "typeVersion": 1, "position": [ -2752, -304 ], "id": "9ee32ae6-1792-4fb7-8bd4-61ed84bc3ece", "name": "Get a workflow2", "credentials": { "n8nApi": { "id": "73Ydc9X8h5HXvFrt", "name": "Eidan - n8n account" } } }, { "parameters": { "assignments": { "assignments": [ { "id": "3519ad4c-6d66-4963-ab76-ee5517d88d67", "name": "repo_name", "value": "liquidacion", "type": "string" }, { "id": "0df99f1e-1354-43b9-9d20-9f994cc82cf6", "name": "file_name", "value": "liquidacion", "type": "string" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -3184, -416 ], "id": "bbdb65bd-aebe-4e7f-91e1-e54190c50db1", "name": "Valores" }, { "parameters": { "jsCode": "const sha = $('Obtener archivo').first().json.sha;\nconst data = { $json };\n\nreturn [{\n json: {\n message: \"Update \" + $('Valores').first().json.file_name + \".json\",\n content: Buffer.from(JSON.stringify(data, null, 2)).toString(\"base64\"),\n sha: sha,\n branch: \"main\"\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -2576, -512 ], "id": "27182c76-5730-4623-b15e-80580f464b9c", "name": "Code in JavaScript2" }, { "parameters": { "jsCode": "const sha = $json.sha; // viene del GET anterior\nconst data = { $json };\n\nconst base64 = Buffer.from(JSON.stringify(data, null, 2)).toString(\"base64\");\n\nreturn [{\n json: {\n message: \"Create \" + $('Valores').first().json.file_name + \".json\",\n content: base64,\n sha: sha,\n branch: \"main\"\n }\n}];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -2576, -304 ], "id": "e1f4a452-0bd7-4ba9-ab2a-443d856a9e3d", "name": "Code in JavaScript4" }, { "parameters": {}, "type": "n8n-nodes-base.manualTrigger", "typeVersion": 1, "position": [ -3392, -416 ], "id": "a66245c9-5ff8-4f8d-bc47-c6f041111d07", "name": "When clicking ‘Execute workflow’" } ], "connections": { "Upload file": { "main": [ [ { "node": "Detalles de factura", "type": "main", "index": 0 } ] ] }, "Webhook": { "main": [ [ { "node": "Mi numero TESTING", "type": "main", "index": 0 }, { "node": "Limpiar numero de telefono", "type": "main", "index": 0 } ] ] }, "Factura es valida?": { "main": [ [ { "node": "Buscar NCF duplicado", "type": "main", "index": 0 } ], [ { "node": "Actualizar awaiting_fechaFuera", "type": "main", "index": 0 } ], [ { "node": "Detalles de factura2", "type": "main", "index": 0 } ] ] }, "Mi numero TESTING": { "main": [ [] ] }, "Es imagen?": { "main": [ [ { "node": "Reaccionar", "type": "main", "index": 0 } ], [ { "node": "Alerta no es imagen", "type": "main", "index": 0 } ] ] }, "Descargar imagen de whatsapp": { "main": [ [ { "node": "Convert to File", "type": "main", "index": 0 } ] ] }, "Edit Fields": { "main": [ [ { "node": "Factura es valida?", "type": "main", "index": 0 } ] ] }, "Convert to File": { "main": [ [ { "node": "Analyze an image1", "type": "main", "index": 0 } ] ] }, "Convert to File1": { "main": [ [ { "node": "Upload file", "type": "main", "index": 0 } ] ] }, "Analyze an image1": { "main": [ [ { "node": "Edit Fields", "type": "main", "index": 0 } ] ] }, "Send message and wait for response": { "main": [ [] ] }, "Buscar NCF duplicado": { "main": [ [ { "node": "Es duplicado?", "type": "main", "index": 0 } ] ] }, "Es duplicado?": { "main": [ [ { "node": "Alerta factura duplicada", "type": "main", "index": 0 } ], [ { "node": "Generar timestamp", "type": "main", "index": 0 } ] ] }, "Limpiar numero de telefono": { "main": [ [ { "node": "Eliminar extension del numero", "type": "main", "index": 0 } ] ] }, "Create a row": { "main": [ [ { "node": "Switch", "type": "main", "index": 0 } ] ] }, "Obtener status": { "main": [ [ { "node": "Switch", "type": "main", "index": 0 } ] ] }, "Switch": { "main": [ [ { "node": "Obtener reporte", "type": "main", "index": 0 } ], [ { "node": "Tipo de reporte", "type": "main", "index": 0 } ], [ { "node": "Audio o texto", "type": "main", "index": 0 } ], [ { "node": "Insertar ruta al sheet", "type": "main", "index": 0 } ], [ { "node": "Insertar anticipo recibido al sheet", "type": "main", "index": 0 } ], [ { "node": "Insertar periodoDesde al sheet", "type": "main", "index": 0 } ], [ { "node": "Insertar periodoHasta al sheet", "type": "main", "index": 0 } ], [ { "node": "Insertar motivo o destino al sheet", "type": "main", "index": 0 } ], [ { "node": "Insertar cliente/proyecto al sheet", "type": "main", "index": 0 } ], [ { "node": "Es imagen?", "type": "main", "index": 0 } ], [ { "node": "Insertar total de la factura", "type": "main", "index": 0 } ], [ { "node": "Insertar proveedor de la factura", "type": "main", "index": 0 } ], [ { "node": "Insertar rnc de la factura", "type": "main", "index": 0 } ], [ { "node": "Insertar fecha de la factura", "type": "main", "index": 0 } ], [ { "node": "Opciones fecha afuera periodo", "type": "main", "index": 0 } ], [ { "node": "Audio o texto1", "type": "main", "index": 0 } ], [], [] ] }, "Schedule Trigger1": { "main": [ [ { "node": "BambooHR4", "type": "main", "index": 0 } ] ] }, "BambooHR4": { "main": [ [ { "node": "Loop Over Items2", "type": "main", "index": 0 } ] ] }, "Eliminar extension del numero3": { "main": [ [ { "node": "Arreglar nombre de supervisor3", "type": "main", "index": 0 } ] ] }, "Wait1": { "main": [ [ { "node": "Loop Over Items2", "type": "main", "index": 0 } ] ] }, "Loop Over Items2": { "main": [ [ { "node": "Eliminar extension del numero3", "type": "main", "index": 0 } ], [ { "node": "Informacion del empleado", "type": "main", "index": 0 } ] ] }, "Arreglar nombre de supervisor3": { "main": [ [ { "node": "Append or update row in sheet1", "type": "main", "index": 0 } ] ] }, "Obtener empleados": { "main": [ [ { "node": "Numero esta registrado en GLM?", "type": "main", "index": 0 } ] ] }, "Eliminar extension del numero": { "main": [ [ { "node": "Obtener empleados", "type": "main", "index": 0 } ] ] }, "El empleado esta activo?": { "main": [ [ { "node": "Get a row", "type": "main", "index": 0 } ], [ { "node": "Alerta empleado no activo", "type": "main", "index": 0 } ] ] }, "Get a row": { "main": [ [ { "node": "Telefono registrado BD?", "type": "main", "index": 0 } ] ] }, "Numero esta registrado en GLM?": { "main": [ [ { "node": "El empleado esta activo?", "type": "main", "index": 0 } ], [ { "node": "Alerta numero no registrado", "type": "main", "index": 0 } ] ] }, "Matchear numero de Whatsapp": { "main": [ [ { "node": "Create a row", "type": "main", "index": 0 } ] ] }, "Obtener reporte": { "main": [ [ { "node": "Empleado tiene reporte abierto?", "type": "main", "index": 0 } ] ] }, "Empleado tiene reporte abierto?": { "main": [ [], [ { "node": "Crear reporte del id", "type": "main", "index": 0 } ] ] }, "Crear reporte del id": { "main": [ [ { "node": "Obtener mes y año", "type": "main", "index": 0 } ] ] }, "Detalles del reporte": { "main": [ [ { "node": "Insertar id del reporte al sheet", "type": "main", "index": 0 } ] ] }, "Telefono registrado BD?": { "main": [ [ { "node": "Obtener status", "type": "main", "index": 0 } ], [ { "node": "Matchear numero de Whatsapp", "type": "main", "index": 0 } ] ] }, "Insertar id del reporte al sheet": { "main": [ [ { "node": "Insertar info bamboo a contexto", "type": "main", "index": 0 } ] ] }, "Insertar detalles de la factura al sheets": { "main": [ [ { "node": "Confirmacion factura recibida", "type": "main", "index": 0 } ] ] }, "Confirmacion factura recibida": { "main": [ [] ] }, "Alerta factura no es valida": { "main": [ [] ] }, "Guardar factura temporalmente": { "main": [ [] ] }, "Insertar periodoDesde al sheet": { "main": [ [ { "node": "Insertar periodoDesde en la bd", "type": "main", "index": 0 } ] ] }, "Insertar periodoHasta al sheet": { "main": [ [ { "node": "Insertar periodoHasta en la bd", "type": "main", "index": 0 } ] ] }, "Insertar ruta al sheet": { "main": [ [ { "node": "Insertar ruta en la bd", "type": "main", "index": 0 } ] ] }, "Insertar cliente/proyecto al sheet": { "main": [ [ { "node": "Insertar cliente/proyecto en la bd", "type": "main", "index": 0 } ] ] }, "Crear carpeta pais": { "main": [ [ { "node": "Buscar carpeta X año", "type": "main", "index": 0 } ] ] }, "Buscar carpeta X pais": { "main": [ [ { "node": "Existe carpeta X pais?", "type": "main", "index": 0 } ] ] }, "Existe carpeta X pais?": { "main": [ [ { "node": "Buscar carpeta X año", "type": "main", "index": 0 } ], [ { "node": "Crear carpeta pais", "type": "main", "index": 0 } ] ] }, "Obtener mes y año": { "main": [ [ { "node": "Buscar carpeta X pais", "type": "main", "index": 0 } ] ] }, "Buscar carpeta X mes": { "main": [ [ { "node": "Existe carpeta X mes?", "type": "main", "index": 0 } ] ] }, "Existe carpeta X mes?": { "main": [ [ { "node": "Buscar carpeta X reporte", "type": "main", "index": 0 } ], [ { "node": "Crear carpeta mes", "type": "main", "index": 0 } ] ] }, "Buscar carpeta X año": { "main": [ [ { "node": "Existe carpeta X año?", "type": "main", "index": 0 } ] ] }, "Existe carpeta X año?": { "main": [ [ { "node": "Buscar carpeta X mes", "type": "main", "index": 0 } ], [ { "node": "Crear carpeta año", "type": "main", "index": 0 } ] ] }, "Crear carpeta año": { "main": [ [ { "node": "Buscar carpeta X mes", "type": "main", "index": 0 } ] ] }, "Crear carpeta mes": { "main": [ [ { "node": "Buscar carpeta X reporte", "type": "main", "index": 0 } ] ] }, "Buscar carpeta X reporte": { "main": [ [ { "node": "Existe carpeta X reporte?", "type": "main", "index": 0 } ] ] }, "Existe carpeta X reporte?": { "main": [ [ { "node": "Crear folder facturas", "type": "main", "index": 0 } ], [ { "node": "Crear carpeta reporte", "type": "main", "index": 0 } ] ] }, "Crear carpeta reporte": { "main": [ [ { "node": "Crear folder facturas", "type": "main", "index": 0 } ] ] }, "Crear reporte": { "main": [ [ { "node": "Actualizar status a awaiting_tipoReporte", "type": "main", "index": 0 } ] ] }, "Obtener mes y año para el sheet": { "main": [ [ { "node": "Detalles del reporte", "type": "main", "index": 0 } ] ] }, "Actualizar status a awaiting_tipoReporte": { "main": [ [ { "node": "Solo primer nombre", "type": "main", "index": 0 } ] ] }, "Solo primer nombre": { "main": [ [ { "node": "Pedir tipo reporte", "type": "main", "index": 0 } ] ] }, "Pedir tipo reporte": { "main": [ [ { "node": "Obtener mes y año para el sheet", "type": "main", "index": 0 } ] ] }, "Insertar anticipo al sheet": { "main": [ [ { "node": "Actualizar status a awaiting_answer", "type": "main", "index": 0 } ] ] }, "Tipo de reporte": { "main": [ [ { "node": "Anticipo", "type": "main", "index": 0 } ], [ { "node": "Reembolso", "type": "main", "index": 0 } ], [ { "node": "Alerta opcion no valida", "type": "main", "index": 0 } ] ] }, "Insertar reembolso al sheet": { "main": [ [ { "node": "Actualizar status a awaiting_answer1", "type": "main", "index": 0 } ] ] }, "Insertar motivo o destino al sheet": { "main": [ [ { "node": "Insertar motivo o destino en la bd", "type": "main", "index": 0 } ] ] }, "Crear folder facturas": { "main": [ [ { "node": "Crear reporte", "type": "main", "index": 0 } ] ] }, "Insertar reporte id, sheet id y factura folder id": { "main": [ [] ] }, "Anticipo": { "main": [ [ { "node": "Insertar anticipo al sheet", "type": "main", "index": 0 } ] ] }, "Reembolso": { "main": [ [ { "node": "Insertar reembolso al sheet", "type": "main", "index": 0 } ] ] }, "Insertar periodoDesde en la bd": { "main": [ [ { "node": "Detectar info faltante para contexto3", "type": "main", "index": 0 } ] ] }, "Insertar motivo o destino en la bd": { "main": [ [ { "node": "Detectar info faltante para contexto5", "type": "main", "index": 0 } ] ] }, "Insertar periodoHasta en la bd": { "main": [ [ { "node": "Detectar info faltante para contexto4", "type": "main", "index": 0 } ] ] }, "Insertar ruta en la bd": { "main": [ [ { "node": "Detectar info faltante para contexto1", "type": "main", "index": 0 } ] ] }, "Insertar cliente/proyecto en la bd": { "main": [ [ { "node": "Detectar info faltante para contexto6", "type": "main", "index": 0 } ] ] }, "Insertar info bamboo a contexto": { "main": [ [ { "node": "Insertar reporte id, sheet id y factura folder id", "type": "main", "index": 0 } ] ] }, "Insertar anticipo recibido al sheet": { "main": [ [ { "node": "Insertar anticipo recibido en la bd", "type": "main", "index": 0 } ] ] }, "Insertar anticipo recibido en la bd": { "main": [ [ { "node": "Detectar info faltante para contexto2", "type": "main", "index": 0 } ] ] }, "Reaccionar": { "main": [ [ { "node": "Descargar imagen de whatsapp", "type": "main", "index": 0 } ] ] }, "Generar timestamp": { "main": [ [ { "node": "Binarios", "type": "main", "index": 0 } ] ] }, "Detalles de factura": { "main": [ [ { "node": "Insertar detalles de la factura al sheets", "type": "main", "index": 0 }, { "node": "Insertar moneda al contexto de reporte", "type": "main", "index": 0 } ] ] }, "Detectar valor critico": { "main": [ [ { "node": "Awaiting", "type": "main", "index": 0 } ] ] }, "Guardar valores faltantes": { "main": [ [ { "node": "Actualizar awaiting", "type": "main", "index": 0 } ] ] }, "Awaiting": { "main": [ [ { "node": "Guardar valores faltantes", "type": "main", "index": 0 } ] ] }, "Actualizar awaiting": { "main": [ [ { "node": "Alerta factura no es valida", "type": "main", "index": 0 } ] ] }, "Insertar total de la factura": { "main": [ [ { "node": "Edit Fields2", "type": "main", "index": 0 } ] ] }, "Informacion del empleado": { "main": [ [ { "node": "Wait1", "type": "main", "index": 0 } ] ] }, "Convert to File2": { "main": [ [ { "node": "Analyze audio", "type": "main", "index": 0 } ] ] }, "Analyze audio": { "main": [ [ { "node": "Message a model", "type": "main", "index": 0 } ] ] }, "Actualizar status a awaiting_answer": { "main": [ [ { "node": "Pedir info", "type": "main", "index": 0 } ] ] }, "Pedir info": { "main": [ [ { "node": "Insertar anticipo en la bd", "type": "main", "index": 0 } ] ] }, "Actualizar status a awaiting_answer1": { "main": [ [ { "node": "Pedir info1", "type": "main", "index": 0 } ] ] }, "Pedir info1": { "main": [ [ { "node": "Insertar reembolso en la bd", "type": "main", "index": 0 } ] ] }, "Audio o texto": { "main": [ [ { "node": "Descargar audio", "type": "main", "index": 0 } ], [ { "node": "Message a model1", "type": "main", "index": 0 } ] ] }, "Message a model": { "main": [ [ { "node": "Edit Fields3", "type": "main", "index": 0 } ] ] }, "Message a model1": { "main": [ [ { "node": "Edit Fields3", "type": "main", "index": 0 } ] ] }, "Edit Fields3": { "main": [ [ { "node": "Detectar info faltante para contexto", "type": "main", "index": 0 } ] ] }, "Detectar info faltante para contexto": { "main": [ [ { "node": "Campo faltante?", "type": "main", "index": 0 } ] ] }, "Awaiting2": { "main": [ [ { "node": "Actualizar status a awaiting", "type": "main", "index": 0 } ] ] }, "Actualizar status a awaiting": { "main": [ [ { "node": "Enviar alerta falta info", "type": "main", "index": 0 } ] ] }, "Insertar contexto en la bd": { "main": [ [ { "node": "Insertar contexto al sheet", "type": "main", "index": 0 } ] ] }, "Guardar valores faltantes de contexto": { "main": [ [ { "node": "Awaiting2", "type": "main", "index": 0 } ] ] }, "Descargar audio": { "main": [ [ { "node": "Convert to File2", "type": "main", "index": 0 } ] ] }, "Insertar contexto al sheet": { "main": [ [ { "node": "Actualizar status a report_open1", "type": "main", "index": 0 } ] ] }, "Campo faltante?": { "main": [ [ { "node": "Insertar contexto en la bd", "type": "main", "index": 0 } ], [ { "node": "Guardar valores faltantes de contexto", "type": "main", "index": 0 } ] ] }, "Actualizar status a report_open1": { "main": [ [ { "node": "Reporte abierto", "type": "main", "index": 0 } ] ] }, "Detectar info faltante para contexto1": { "main": [ [ { "node": "Campo faltante?1", "type": "main", "index": 0 } ] ] }, "Detectar info faltante para contexto2": { "main": [ [ { "node": "Campo faltante?1", "type": "main", "index": 0 } ] ] }, "Detectar info faltante para contexto3": { "main": [ [ { "node": "Campo faltante?1", "type": "main", "index": 0 } ] ] }, "Detectar info faltante para contexto4": { "main": [ [ { "node": "Campo faltante?1", "type": "main", "index": 0 } ] ] }, "Detectar info faltante para contexto5": { "main": [ [ { "node": "Campo faltante?1", "type": "main", "index": 0 } ] ] }, "Campo faltante?1": { "main": [ [ { "node": "Actualizar status a report_open2", "type": "main", "index": 0 } ], [ { "node": "Awaiting3", "type": "main", "index": 0 } ] ] }, "Actualizar status a awaiting1": { "main": [ [ { "node": "Enviar alerta falta info1", "type": "main", "index": 0 } ] ] }, "Awaiting3": { "main": [ [ { "node": "Actualizar status a awaiting1", "type": "main", "index": 0 } ] ] }, "Detectar info faltante para contexto6": { "main": [ [ { "node": "Campo faltante?1", "type": "main", "index": 0 } ] ] }, "Switch1": { "main": [ [ { "node": "Comando ayuda", "type": "main", "index": 0 } ], [ { "node": "Comando estado", "type": "main", "index": 0 } ], [ { "node": "Obtener info reporte", "type": "main", "index": 0 } ], [ { "node": "Obtener reporte", "type": "main", "index": 0 } ], [ { "node": "Comando cancelar", "type": "main", "index": 0 } ], [ { "node": "Switch", "type": "main", "index": 0 } ] ] }, "Actualizar status a report_open2": { "main": [ [ { "node": "Reporte abierto1", "type": "main", "index": 0 } ] ] }, "Obtener info reporte": { "main": [ [ { "node": "Comando cerrar", "type": "main", "index": 0 } ] ] }, "Insertar moneda al contexto de reporte": { "main": [ [ { "node": "Insertar factura valida a la bd", "type": "main", "index": 0 } ] ] }, "Comando cerrar": { "main": [ [ { "node": "Compartir fotos con jefe directo", "type": "main", "index": 0 }, { "node": "Compartir fotos con finanzas pais", "type": "main", "index": 0 } ] ] }, "Compartir fotos con jefe directo": { "main": [ [ { "node": "Compartir sheet con jefe directo", "type": "main", "index": 0 } ] ] }, "Compartir fotos con finanzas pais": { "main": [ [ { "node": "Compartir sheet con finanzas pais", "type": "main", "index": 0 } ] ] }, "Compartir sheet con jefe directo": { "main": [ [] ] }, "Edit Fields2": { "main": [ [ { "node": "Insertar total", "type": "main", "index": 0 } ] ] }, "Insertar total": { "main": [ [ { "node": "Edit Fields4", "type": "main", "index": 0 } ] ] }, "Edit Fields4": { "main": [ [ { "node": "Detectar valor critico1", "type": "main", "index": 0 } ] ] }, "Detectar valor critico1": { "main": [ [ { "node": "Campo faltante?2", "type": "main", "index": 0 } ] ] }, "Awaiting4": { "main": [ [ { "node": "Actualizar status a awaiting2", "type": "main", "index": 0 } ] ] }, "Actualizar status a awaiting2": { "main": [ [ { "node": "Enviar alerta falta info2", "type": "main", "index": 0 } ] ] }, "Campo faltante?2": { "main": [ [ { "node": "Actualizar status a report_open", "type": "main", "index": 0 } ], [ { "node": "Awaiting4", "type": "main", "index": 0 } ] ] }, "Edit Fields5": { "main": [ [ { "node": "Insertar proveedor", "type": "main", "index": 0 } ] ] }, "Insertar proveedor de la factura": { "main": [ [ { "node": "Edit Fields5", "type": "main", "index": 0 } ] ] }, "Insertar proveedor": { "main": [ [ { "node": "Edit Fields4", "type": "main", "index": 0 } ] ] }, "Edit Fields6": { "main": [ [ { "node": "Insertar rnc", "type": "main", "index": 0 } ] ] }, "Edit Fields7": { "main": [ [ { "node": "Insertar fecha", "type": "main", "index": 0 } ] ] }, "Insertar rnc de la factura": { "main": [ [ { "node": "Edit Fields6", "type": "main", "index": 0 } ] ] }, "Insertar fecha de la factura": { "main": [ [ { "node": "Edit Fields7", "type": "main", "index": 0 } ] ] }, "Insertar rnc": { "main": [ [ { "node": "Edit Fields4", "type": "main", "index": 0 } ] ] }, "Insertar fecha": { "main": [ [ { "node": "Edit Fields4", "type": "main", "index": 0 } ] ] }, "Actualizar status a report_open": { "main": [ [ { "node": "Edit Fields8", "type": "main", "index": 0 } ] ] }, "Edit Fields8": { "main": [ [ { "node": "Confirmacion factura recibida1", "type": "main", "index": 0 } ] ] }, "Alerta factura fuera de periodo": { "main": [ [] ] }, "Fecha periodo": { "main": [ [ { "node": "Alerta factura fuera de periodo", "type": "main", "index": 0 } ] ] }, "Actualizar awaiting_fechaFuera": { "main": [ [ { "node": "Detalles de factura y binarios imagen", "type": "main", "index": 0 } ] ] }, "Insertar detalles de la factura al sheets1": { "main": [ [ { "node": "Confirmacion factura recibida2", "type": "main", "index": 0 } ] ] }, "Detalles de factura1": { "main": [ [ { "node": "Insertar detalles de la factura al sheets1", "type": "main", "index": 0 } ] ] }, "Opciones fecha afuera periodo": { "main": [ [ { "node": "Edit Fields10", "type": "main", "index": 0 } ], [ { "node": "Actualizar awaiting_nuevaFechaPeriodo", "type": "main", "index": 0 } ], [ { "node": "Borrar factura temporal1", "type": "main", "index": 0 } ], [ { "node": "Alerta opcion no valida1", "type": "main", "index": 0 } ] ] }, "Analyze audio1": { "main": [ [ { "node": "Message a model2", "type": "main", "index": 0 } ] ] }, "Convert to File3": { "main": [ [ { "node": "Analyze audio1", "type": "main", "index": 0 } ] ] }, "Audio o texto1": { "main": [ [ { "node": "Descargar audio1", "type": "main", "index": 0 } ], [ { "node": "Message a model3", "type": "main", "index": 0 } ] ] }, "Message a model2": { "main": [ [ { "node": "Edit Fields9", "type": "main", "index": 0 } ] ] }, "Message a model3": { "main": [ [ { "node": "Edit Fields9", "type": "main", "index": 0 } ] ] }, "Descargar audio1": { "main": [ [ { "node": "Convert to File3", "type": "main", "index": 0 } ] ] }, "Actualizar awaiting_nuevaFechaPeriodo": { "main": [ [ { "node": "Pedir nueva fecha periodo", "type": "main", "index": 0 } ] ] }, "Guardar factura temporalmente1": { "main": [ [ { "node": "Fecha periodo", "type": "main", "index": 0 } ] ] }, "Detalles de factura2": { "main": [ [ { "node": "Detectar valor critico", "type": "main", "index": 0 }, { "node": "Guardar factura temporalmente", "type": "main", "index": 0 } ] ] }, "Confirmacion factura recibida2": { "main": [ [ { "node": "Borrar factura temporal", "type": "main", "index": 0 } ] ] }, "Edit Fields10": { "main": [ [ { "node": "Generar timestamp1", "type": "main", "index": 0 } ] ] }, "Binarios": { "main": [ [ { "node": "Convert to File1", "type": "main", "index": 0 } ] ] }, "Detalles de factura y binarios imagen": { "main": [ [ { "node": "Guardar factura temporalmente1", "type": "main", "index": 0 } ] ] }, "Upload file1": { "main": [ [ { "node": "Detalles de factura1", "type": "main", "index": 0 } ] ] }, "Generar timestamp1": { "main": [ [ { "node": "Binarios1", "type": "main", "index": 0 } ] ] }, "Convert to File4": { "main": [ [ { "node": "Upload file1", "type": "main", "index": 0 } ] ] }, "Binarios1": { "main": [ [ { "node": "Convert to File4", "type": "main", "index": 0 } ] ] }, "Borrar factura temporal1": { "main": [ [ { "node": "Actualizar report_open", "type": "main", "index": 0 } ] ] }, "Borrar factura temporal": { "main": [ [ { "node": "Actualizar status a report_open3", "type": "main", "index": 0 } ] ] }, "Edit Fields9": { "main": [ [ { "node": "Insertar nuevo periodo al sheet", "type": "main", "index": 0 } ] ] }, "Insertar nuevo periodo al sheet": { "main": [ [ { "node": "Insertar nuevo periodo en la bd", "type": "main", "index": 0 } ] ] }, "Insertar nuevo periodo en la bd": { "main": [ [ { "node": "Actualizar report_open1", "type": "main", "index": 0 } ] ] }, "Analyze audio2": { "main": [ [ { "node": "Message a model4", "type": "main", "index": 0 } ] ] }, "Convert to File5": { "main": [ [ { "node": "Analyze audio2", "type": "main", "index": 0 } ] ] }, "Audio o texto2": { "main": [ [ { "node": "Descargar audio2", "type": "main", "index": 0 } ], [ { "node": "Message a model5", "type": "main", "index": 0 } ] ] }, "Message a model4": { "main": [ [ { "node": "Edit Fields11", "type": "main", "index": 0 } ] ] }, "Message a model5": { "main": [ [ { "node": "Edit Fields11", "type": "main", "index": 0 } ] ] }, "Descargar audio2": { "main": [ [ { "node": "Convert to File5", "type": "main", "index": 0 } ] ] }, "Obtener archivo": { "main": [ [ { "node": "Get a workflow1", "type": "main", "index": 0 } ], [ { "node": "Get a workflow2", "type": "main", "index": 0 } ] ] }, "Get a workflow1": { "main": [ [ { "node": "Code in JavaScript2", "type": "main", "index": 0 } ] ] }, "Get a workflow2": { "main": [ [ { "node": "Code in JavaScript4", "type": "main", "index": 0 } ] ] }, "Valores": { "main": [ [ { "node": "Obtener archivo", "type": "main", "index": 0 } ] ] }, "Code in JavaScript2": { "main": [ [ { "node": "Actualizar archivo", "type": "main", "index": 0 } ] ] }, "Code in JavaScript4": { "main": [ [ { "node": "Subir archivo", "type": "main", "index": 0 } ] ] }, "When clicking ‘Execute workflow’": { "main": [ [ { "node": "Valores", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1", "binaryMode": "separate", "timeSavedMode": "fixed", "timezone": "America/Santo_Domingo", "callerPolicy": "workflowsFromSameOwner", "availableInMCP": false }, "staticData": { "node:Schedule Trigger1": { "recurrenceRules": [] } }, "meta": { "templateCredsSetupCompleted": true }, "pinData": { "Webhook": [ { "json": { "headers": { "host": "agenteit.digitalcompass.agency", "user-agent": "axios/1.13.2", "content-length": "1731", "accept": "application/json, text/plain, */*", "accept-encoding": "gzip, compress, deflate, br", "content-type": "application/json", "x-forwarded-for": "34.173.64.212", "x-forwarded-host": "agenteit.digitalcompass.agency", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-forwarded-server": "07b4f09d2c65", "x-real-ip": "34.173.64.212" }, "params": {}, "query": {}, "body": { "event": "messages.upsert", "instance": "botsoporte", "data": { "key": { "remoteJid": "18097159076@s.whatsapp.net", "remoteJidAlt": "18097159076@s.whatsapp.net", "fromMe": false, "id": "3EB01296C2461A6FE68406", "participant": "", "addressingMode": "lid" }, "pushName": "Eidan Then Elizo", "status": "DELIVERY_ACK", "message": { "messageContextInfo": { "threadId": [], "deviceListMetadata": { "senderKeyIndexes": [], "recipientKeyIndexes": [], "senderKeyHash": { "0": 181, "1": 137, "2": 21, "3": 60, "4": 125, "5": 187, "6": 67, "7": 165, "8": 52, "9": 221 }, "senderTimestamp": { "low": 1779582572, "high": 0, "unsigned": true }, "senderAccountType": 0, "receiverAccountType": 0, "recipientKeyHash": { "0": 18, "1": 158, "2": 135, "3": 110, "4": 80, "5": 17, "6": 136, "7": 191, "8": 133, "9": 96 }, "recipientTimestamp": { "low": 1779102960, "high": 0, "unsigned": true } }, "deviceListMetadataVersion": 2, "messageSecret": { "0": 244, "1": 112, "2": 186, "3": 42, "4": 239, "5": 18, "6": 204, "7": 64, "8": 169, "9": 220, "10": 232, "11": 239, "12": 132, "13": 173, "14": 142, "15": 154, "16": 231, "17": 154, "18": 88, "19": 11, "20": 114, "21": 198, "22": 182, "23": 96, "24": 236, "25": 249, "26": 184, "27": 153, "28": 135, "29": 75, "30": 82, "31": 3 } }, "conversation": "Desde 1 de mayo a 20 de mayo 2026" }, "contextInfo": { "mentionedJid": [], "groupMentions": [], "statusAttributions": [], "ephemeralSettingTimestamp": { "low": 1780337771, "high": 0, "unsigned": false }, "disappearingMode": { "initiator": 0, "trigger": 1, "initiatedByMe": false } }, "messageType": "conversation", "messageTimestamp": 1780510635, "instanceId": "87540898-d022-4ebb-b83a-0200e123d202", "source": "web" }, "destination": "https://agenteit.digitalcompass.agency/webhook/factura", "date_time": "2026-06-03T15:17:15.122Z", "sender": "18099662003@s.whatsapp.net", "server_url": "https://wsp.gomezleemarketing.com", "apikey": "C267126ABB45-4C12-B626-6BAB1833F5D7" }, "webhookUrl": "https://agenteit.digitalcompass.agency/webhook/factura", "executionMode": "production" }, "pairedItem": { "item": 0 } } ] }, "versionId": "4ede5eec-57d9-4a2f-ae6b-8f6572f8c341", "activeVersionId": null, "versionCounter": 2543, "triggerCount": 3, "shared": [ { "updatedAt": "2026-05-28T13:53:39.519Z", "createdAt": "2026-05-28T13:53:39.519Z", "role": "workflow:owner", "workflowId": "eM8ZZafSC9M8GYd4", "projectId": "0bH6HfYEL8n6SDmr", "project": { "updatedAt": "2026-04-22T14:25:04.701Z", "createdAt": "2026-04-22T14:22:54.790Z", "id": "0bH6HfYEL8n6SDmr", "name": "Eidan Then ", "type": "personal", "icon": null, "description": null, "creatorId": "de14e7e5-491b-4983-abb2-f88af42e92fd" } } ], "tags": [], "activeVersion": null } }