diff --git a/liquidacion.json b/liquidacion.json index 570acf7..d324219 100644 --- a/liquidacion.json +++ b/liquidacion.json @@ -1,11 +1,11 @@ { "$json": { - "updatedAt": "2026-06-08T20:20:56.084Z", + "updatedAt": "2026-07-29T13:27:51.523Z", "createdAt": "2026-05-28T13:53:39.482Z", "id": "eM8ZZafSC9M8GYd4", - "name": "Procesador de facturas VERSION AUDIO", + "name": "Procesador de facturas VERSION AUDIO (WHATSAPP OFICIAL)", "description": null, - "active": false, + "active": true, "isArchived": false, "nodes": [ { @@ -27,8 +27,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 2432, - 1696 + 2416, + 2448 ], "id": "7ccd0408-1cc5-44d1-8466-56fb0b0f0b58", "name": "Upload file", @@ -39,22 +39,6 @@ } } }, - { - "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", @@ -63,8 +47,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - -3456, - -16 + -4368, + -576 ], "typeVersion": 1, "id": "ee478bf2-ae8f-495f-8af3-a339692a5fd7", @@ -79,8 +63,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - 176, - 1616 + 160, + 2368 ], "typeVersion": 1, "id": "7891d420-b1e1-4dca-bd0c-af7499d51d28", @@ -164,45 +148,12 @@ "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ - 1296, - 1792 + 1280, + 2544 ], "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": { @@ -230,8 +181,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - -3088, - 192 + -3664, + -32 ], "id": "0fc94f6a-2ebd-4c1b-976c-7b17c2939aeb", "name": "Mi numero TESTING" @@ -263,8 +214,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - 192, - 1792 + 176, + 2544 ], "id": "147eee37-1ad7-4b84-bd08-1654f49b9f23", "name": "Es imagen?" @@ -300,11 +251,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 624, - 1792 + 608, + 2544 ], "id": "e6bb63d2-fa54-43ba-a27e-0954a92c21c7", - "name": "Descargar imagen de whatsapp" + "name": "Descargar imagen de whatsapp", + "disabled": true }, { "parameters": { @@ -323,8 +275,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - 1136, - 1792 + 1120, + 2544 ], "id": "4ac3b5e6-ef5c-4829-8103-f188e065a1fb", "name": "Edit Fields" @@ -340,8 +292,8 @@ "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ - 816, - 1792 + 800, + 2544 ], "id": "21f8a9f4-c324-447a-be6a-25f9bd4df407", "name": "Convert to File" @@ -357,8 +309,8 @@ "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ - 2272, - 1696 + 2256, + 2448 ], "id": "810c988e-1ffb-438d-8d9b-847f9be60573", "name": "Convert to File1" @@ -402,56 +354,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 352, - 1936 + 336, + 2688 ], "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" + "name": "Alerta no es imagen", + "disabled": true }, { "parameters": { @@ -461,8 +369,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - 2400, - 1584 + 2384, + 2336 ], "typeVersion": 1, "id": "1a32fee7-9643-4fa8-9b06-1093bcc98317", @@ -476,51 +384,13 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - 2064, - 1632 + 2048, + 2384 ], "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", @@ -535,6 +405,12 @@ "id": "84a27682-ff38-4b46-abed-61f44c99b25a", "name": "Download media", "webhookId": "68cf4848-d0a9-4325-995e-4b067eee50ba", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + }, "disabled": true }, { @@ -547,13 +423,18 @@ "type": "n8n-nodes-base.whatsAppTrigger", "typeVersion": 1, "position": [ - -1536, - 1232 + -4272, + -464 ], "id": "04830804-459a-49fa-97ba-1c864641583c", "name": "WhatsApp Trigger", "webhookId": "11875011-47ee-4be7-81d2-f58384918645", - "disabled": true + "credentials": { + "whatsAppTriggerApi": { + "id": "6UhrcQx21RbAmGPV", + "name": "Eidan - WhatsApp OAuth account" + } + } }, { "parameters": {}, @@ -566,6 +447,12 @@ "id": "c1082e16-ef63-4a41-b666-be4875c770ba", "name": "Send template", "webhookId": "73315d8d-e5bd-4b52-b2cd-6f983998a0e3", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + }, "disabled": true }, { @@ -598,8 +485,8 @@ "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.7, "position": [ - 1504, - 1696 + 1488, + 2448 ], "id": "829c288f-8400-47f3-9a22-859d4a5523eb", "name": "Buscar NCF duplicado", @@ -623,7 +510,7 @@ "conditions": [ { "id": "dup-check-001", - "leftValue": "={{ $json['Nº Factura / NCF / DTE'] }}", + "leftValue": "={{ $json['Nº Factura / NCF / DTE'].toString() }}", "rightValue": "={{ $('Factura es valida?').item.json.output.numero_factura }}", "operator": { "type": "string", @@ -638,8 +525,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - 1712, - 1696 + 1696, + 2448 ], "id": "ad928736-a65e-4d3d-a791-b3e061f19ee0", "name": "Es duplicado?" @@ -683,11 +570,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 1936, - 1520 + 1920, + 2272 ], "id": "321c0e69-d2cb-49d0-a3bb-f2df98e5f9dd", - "name": "Alerta factura duplicada" + "name": "Alerta factura duplicada", + "disabled": true }, { "parameters": { @@ -698,49 +586,13 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - 1456, - 1504 + 1440, + 2256 ], "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}];" @@ -748,8 +600,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - -3136, - -16 + -3456, + -144 ], "id": "20ccd833-a512-403b-abc5-f6173520f7cf", "name": "Limpiar numero de telefono" @@ -793,11 +645,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - -2464, - 96 + -3360, + -352 ], "id": "d190a852-6785-4e69-afcb-094f821bfb7e", - "name": "Alerta numero no registrado" + "name": "Alerta numero no registrado", + "disabled": true }, { "parameters": { @@ -808,8 +661,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - -3168, - -128 + -4064, + -576 ], "typeVersion": 1, "id": "2afe000f-fe83-42d6-9ab8-e676cc47253c", @@ -854,11 +707,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - -2208, - 96 + -3104, + -352 ], "id": "0bacaa6f-5d3d-4941-b7d5-6bc30851feaa", - "name": "Alerta empleado no activo" + "name": "Alerta empleado no activo", + "disabled": true }, { "parameters": { @@ -888,8 +742,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - 32, - -816 + -1312, + -2016 ], "id": "cc1bf3fc-fbe6-4896-b569-254b9f9eb3a5", "name": "Empleado tiene reporte abierto?" @@ -898,6 +752,29 @@ "parameters": { "rules": { "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "2fe4c704-a5e0-4483-a3e0-670f8183a597", + "leftValue": "={{ $json.state }}", + "rightValue": "awaiting_open_report_confirm", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, { "conditions": { "options": { @@ -943,6 +820,52 @@ "combinator": "and" } }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "f44e2174-0d46-4d47-a42c-80021cdcf444", + "leftValue": "={{ $json.state }}", + "rightValue": "awaiting_answerAnticipo", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "1b7f8895-8a5c-44d9-a0ed-47128209c844", + "leftValue": "={{ $json.state }}", + "rightValue": "awaiting_answerReembolso", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, { "conditions": { "options": { @@ -1316,7 +1239,7 @@ "typeVersion": 3.4, "position": [ -928, - 32 + 464 ], "id": "c86e3729-6827-4580-bb09-93cfff9e1eb2", "name": "Switch" @@ -1324,7 +1247,7 @@ { "parameters": { "operation": "get", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -1337,325 +1260,27 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - -1632, - -64 + -2608, + -544 ], "id": "07c3dcfd-9d6c-483b-865d-918fc83237aa", "name": "Obtener status", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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});" + "jsCode": "return $input.all().map(item => {\n let phoneNumber = item.json.phone;\n\n if (phoneNumber) {\n phoneNumber = phoneNumber.replace(/\\D/g, \"\");\n phoneNumber = phoneNumber.slice(-10);\n }\n\n return {\n json: {\n phone: phoneNumber,\n message: $input.first().json.message,\n has_media: $input.first().json.has_media,\n media_id: $input.first().json.media_id\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 + -3856, + -464 ], "id": "c9396923-66c1-461c-af78-9c68b52e6851", "name": "Eliminar extension del numero" @@ -1687,41 +1312,12 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - -2352, - -16 + -3248, + -464 ], "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": { @@ -1749,21 +1345,21 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - -2608, - -16 + -3504, + -464 ], "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}];" + "jsCode": "// Datos del webhook (nodo anterior)\nconst phone = $('Eliminar extension del numero').first().json.phone;\n\n// Datos del nodo con los teléfonos del empleado\nconst mobilePhone = $('Obtener empleado').first().json.mobilePhone;\nconst workPhone = $('Obtener empleado').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 + -1760, + 272 ], "id": "6559ddeb-5f77-4219-8469-e5d0851dd69a", "name": "Matchear numero de Whatsapp" @@ -1774,8 +1370,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - 928, - 1936 + 912, + 2736 ], "typeVersion": 1, "id": "1e8f158c-88d9-4042-9cad-0df090c37cc4", @@ -1784,7 +1380,7 @@ { "parameters": { "operation": "get", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -1797,46 +1393,18 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - -144, - -816 + -1488, + -2016 ], "id": "ed081e87-5075-40e8-b982-14ee734f11bd", "name": "Obtener reporte", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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 } }];" @@ -1844,21 +1412,21 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 192, - -688 + -1120, + -1184 ], "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}" + "jsCode": "\n\nreturn {\n reporteID: $('Crear reporte del id').first().json.reporteID,\n pais: $('Tiene reporte abierto?1').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 + 2320, + -1184 ], "id": "6886cea4-40ae-4c99-a370-4f593304c982", "name": "Detalles del reporte" @@ -1891,8 +1459,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - -1936, - -16 + -2832, + -464 ], "id": "7cb04147-9d6e-4796-b6ae-556b01b68ca1", "name": "Telefono registrado BD?" @@ -1920,8 +1488,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 3824, - -688 + 2512, + -1184 ], "id": "913cc91c-893b-4e91-968c-c7b1ae4a87ea", "name": "Insertar id del reporte al sheet", @@ -1957,61 +1525,16 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 2768, - 1696 + 2752, + 2448 ], "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", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -2033,15 +1556,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 1712, - 2048 + 1696, + 2800 ], "id": "a8ce782d-4f4f-4d20-8b4c-c147d841671b", "name": "Guardar factura temporalmente", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -2068,8 +1591,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 192, - 816 + 176, + 1568 ], "id": "569b6210-d5de-4710-9cf0-9e7fe5fa3120", "name": "Insertar periodoDesde al sheet", @@ -2103,8 +1626,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 192, - 1008 + 176, + 1760 ], "id": "e489ae8b-389e-4b60-ad0c-d54b647763e7", "name": "Insertar periodoHasta al sheet", @@ -2138,8 +1661,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 192, - 448 + 176, + 1200 ], "id": "1bacb766-c826-40fa-81c9-819395de22ac", "name": "Insertar ruta al sheet", @@ -2173,8 +1696,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 192, - 1392 + 176, + 2144 ], "id": "23643afb-4f8e-4f14-8a78-fdb0890c7d91", "name": "Insertar cliente/proyecto al sheet", @@ -2206,16 +1729,17 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 448, - 1792 + 432, + 2544 ], "id": "0ad99326-cf8b-44b4-9932-ed4b0a9f01b4", - "name": "Reaccionar" + "name": "Reaccionar", + "disabled": true }, { "parameters": { "resource": "folder", - "name": "={{ $('Empleado tiene reporte abierto?').item.json.country }}", + "name": "={{ $('Tiene reporte abierto?1').item.json.country }}", "driveId": { "__rl": true, "mode": "list", @@ -2233,8 +1757,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 880, - -592 + -432, + -1088 ], "id": "7dabdc5b-3cf9-43b0-a8e6-77b88f5d9a10", "name": "Crear carpeta pais", @@ -2264,8 +1788,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 1872, - -592 + 560, + -1088 ], "id": "aa4eafdf-a7f1-49cc-a854-e2be89af04d2", "name": "Crear carpeta mes", @@ -2303,8 +1827,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - 720, - -688 + -592, + -1184 ], "id": "2d233a2a-3f97-4412-8024-7ec0431fccd7", "name": "Existe carpeta X pais?" @@ -2312,7 +1836,7 @@ { "parameters": { "resource": "fileFolder", - "queryString": "={{ $('Empleado tiene reporte abierto?').item.json.country }}", + "queryString": "={{ $('Tiene reporte abierto?1').item.json.country }}", "returnAll": true, "filter": { "includeTrashed": false @@ -2322,8 +1846,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 544, - -688 + -768, + -1184 ], "id": "e59815d2-d34b-4d37-81a1-40991659e180", "name": "Buscar carpeta X pais", @@ -2342,8 +1866,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 368, - -688 + -944, + -1184 ], "id": "7e6c9d47-6887-4e27-b650-4aa8b5ac2652", "name": "Obtener mes y año" @@ -2375,8 +1899,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - 1712, - -688 + 400, + -1184 ], "id": "80ea42b6-a28d-4b4a-b5e9-8146daefc8e6", "name": "Existe carpeta X mes?" @@ -2399,8 +1923,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 1520, - -688 + 208, + -1184 ], "id": "fcb9a536-1be4-4e61-aa98-2e6f72b75120", "name": "Buscar carpeta X mes", @@ -2430,8 +1954,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 1024, - -688 + -288, + -1184 ], "id": "220d6435-5e25-435a-85a3-013c840a1ec3", "name": "Buscar carpeta X año", @@ -2470,8 +1994,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - 1216, - -688 + -96, + -1184 ], "id": "cb389c48-af80-4a04-8538-0394986dc88c", "name": "Existe carpeta X año?" @@ -2495,8 +2019,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 1376, - -592 + 64, + -1088 ], "id": "b4d12d76-69b0-4770-86d3-d8b2d1ee84e0", "name": "Crear carpeta año", @@ -2524,8 +2048,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 2032, - -688 + 720, + -1184 ], "id": "b7315899-dc61-420a-aa7a-5caf2e81479c", "name": "Buscar carpeta X reporte", @@ -2564,8 +2088,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - 2240, - -688 + 928, + -1184 ], "id": "08c93234-8b7e-4e53-8ccd-106e62defa16", "name": "Existe carpeta X reporte?" @@ -2573,7 +2097,7 @@ { "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] : '') }}", + "name": "={{ $('Crear reporte del id').item.json.reporteID + '-' + $('Tiene reporte abierto?1').item.json.name.split(' ')[0] + ($('Tiene reporte abierto?1').item.json.name.split(' ')[1] ? $('Tiene reporte abierto?1').item.json.name.split(' ')[1][0] : '') }}", "driveId": { "__rl": true, "mode": "list", @@ -2589,8 +2113,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 2400, - -592 + 1088, + -1088 ], "id": "804ae7ef-81f5-4586-a4b3-bd192e36a17b", "name": "Crear carpeta reporte", @@ -2611,7 +2135,7 @@ "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] : '') }}", + "name": "={{ $('Crear reporte del id').item.json.reporteID + '-' + $('Tiene reporte abierto?1').item.json.name.split(' ')[0] + ($('Tiene reporte abierto?1').item.json.name.split(' ')[1] ? $('Tiene reporte abierto?1').item.json.name.split(' ')[1][0] : '') }}", "sameFolder": false, "driveId": { "__rl": true, @@ -2628,8 +2152,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 2736, - -688 + 1424, + -1184 ], "id": "7dd87738-d903-4d98-a30f-b9e3101fc2dc", "name": "Crear reporte", @@ -2647,8 +2171,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 3440, - -688 + 2128, + -1184 ], "id": "ee2533a7-f4cb-4467-955c-3d2d2d6e6e9e", "name": "Obtener mes y año para el sheet" @@ -2656,13 +2180,13 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", - "keyValue": "={{ $('Empleado tiene reporte abierto?').item.json.phone }}" + "keyValue": "={{ $('Tiene reporte abierto?1').item.json.phone }}" } ] }, @@ -2678,15 +2202,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 2896, - -688 + 1584, + -1184 ], "id": "5d5e0dfa-cbdd-4e23-acbf-f3a298e5ca8b", "name": "Actualizar status a awaiting_tipoReporte", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -2697,57 +2221,12 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 3072, - -688 + 1760, + -1184 ], "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": { @@ -2762,8 +2241,8 @@ }, "conditions": [ { - "leftValue": "={{ [\"1\", \"Anticipo\", \"anticipo\"].includes($('Webhook').item.json.body.data.message.conversation).toString() }}", - "rightValue": "=true", + "leftValue": "={{ $('Limpiador').item.json.button_answer }}", + "rightValue": "=anticipo", "operator": { "type": "string", "operation": "equals" @@ -2785,8 +2264,8 @@ "conditions": [ { "id": "99c670dc-8bba-4d78-9adc-2b2824a1e811", - "leftValue": "={{ [\"2\", \"Reembolso\", \"reembolso\"].includes($('Webhook').item.json.body.data.message.conversation).toString() }}", - "rightValue": "=true", + "leftValue": "={{ $('Limpiador').item.json.button_answer }}", + "rightValue": "=reembolso", "operator": { "type": "string", "operation": "equals", @@ -2807,9 +2286,9 @@ }, "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", + "id": "c45748cc-d1ba-47c3-a5ac-e990bc3fbddc", + "leftValue": "={{ ![\"reembolso\", \"anticipo\"].includes($('Limpiador').item.json.message) }}", + "rightValue": "", "operator": { "type": "boolean", "operation": "true", @@ -2971,8 +2450,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 192, - 1200 + 176, + 1952 ], "id": "4f9377ef-0e9c-4c36-9fad-2f2089a7b49e", "name": "Insertar motivo o destino al sheet", @@ -3002,8 +2481,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 2576, - -688 + 1264, + -1184 ], "id": "3a8ef3e9-471d-41ae-b247-c9900c379c0d", "name": "Crear folder facturas", @@ -3017,13 +2496,13 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { "keyName": "phone", "condition": "eq", - "keyValue": "={{ $('Empleado tiene reporte abierto?').item.json.phone }}" + "keyValue": "={{ $('Eliminar extension del numero').item.json.phone }}" } ] }, @@ -3040,6 +2519,10 @@ { "fieldId": "invoice_photos_folder_id", "fieldValue": "={{ $('Crear folder facturas').item.json.id }}" + }, + { + "fieldId": "google_drive_report_folder_id", + "fieldValue": "={{ $('Crear carpeta reporte').item.json.id }}" } ] } @@ -3047,15 +2530,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 4224, - -688 + 2912, + -1184 ], "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" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -3110,8 +2593,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 400, - 816 + 384, + 1568 ], "id": "a17dd40a-7587-4185-8057-9ddaa1386494", "name": "Insertar periodoDesde en la bd" @@ -3141,8 +2624,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 400, - 1200 + 384, + 1952 ], "id": "91691ad5-3146-4f15-b550-8ce3f6d1a266", "name": "Insertar motivo o destino en la bd" @@ -3172,8 +2655,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 400, - 1008 + 384, + 1760 ], "id": "c42d6376-9759-4ebc-8a41-0144b2b497d3", "name": "Insertar periodoHasta en la bd" @@ -3203,8 +2686,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 400, - 448 + 384, + 1200 ], "id": "fa4d3912-c582-4d99-8ab4-594e851ba88f", "name": "Insertar ruta en la bd" @@ -3234,8 +2717,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 400, - 1392 + 384, + 2144 ], "id": "bf0a2f32-2127-46f3-b04f-5a3ceddb8772", "name": "Insertar cliente/proyecto en la bd" @@ -3243,30 +2726,30 @@ { "parameters": { "method": "POST", - "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" }, { "name": "Authorization", - "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" } ] }, "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}", + "jsonBody": "={\n \"user_phone\": \"{{ $('Eliminar extension del numero').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 + 2704, + -1184 ], "id": "3eb5d2a6-2a76-41e5-b720-1ad3738f3125", "name": "Insertar info bamboo a contexto" @@ -3294,8 +2777,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 192, - 624 + 176, + 1376 ], "id": "2546a8cd-30a1-41db-a575-cb2fcb22ab2c", "name": "Insertar anticipo recibido al sheet", @@ -3331,8 +2814,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 400, - 624 + 384, + 1376 ], "id": "ed0b1aac-c490-4571-9f15-528eddf5ce2a", "name": "Insertar anticipo recibido en la bd" @@ -3344,21 +2827,21 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 1936, - 1696 + 1920, + 2448 ], "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}];" + "jsCode": "const output = $('Edit Fields').item.json.output;\n\nreturn [{\n json: {\n spreadsheetId: $('Es imagen?').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": [ - 2592, - 1696 + 2576, + 2448 ], "id": "7d781acd-292f-4cbc-bfc7-c85ab7793778", "name": "Detalles de factura" @@ -3366,7 +2849,7 @@ { "parameters": { "method": "POST", - "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $json.spreadsheetId }}/values:batchUpdate", + "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $('Es imagen?').item.json.sheet_id }}/values:batchUpdate", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleOAuth2Api", "sendHeaders": true, @@ -3386,8 +2869,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 2768, - 1888 + 2752, + 2640 ], "id": "f1d84244-f0be-43b8-8068-ab01516bc41b", "name": "Insertar moneda al contexto de reporte", @@ -3401,7 +2884,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -3423,15 +2906,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 2048, - 2208 + 2032, + 2960 ], "id": "45ebdf41-ede9-4aa1-9cc9-15a75b27b1f8", "name": "Guardar valores faltantes", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -3442,8 +2925,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 1712, - 2208 + 1696, + 2960 ], "id": "00ca65f0-812d-4055-adbd-c2a78156aa8a", "name": "Detectar valor critico" @@ -3455,8 +2938,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 1872, - 2208 + 1856, + 2960 ], "id": "f05feb15-6907-48bd-b1c9-03f34a2d3cec", "name": "Awaiting" @@ -3464,7 +2947,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -3486,15 +2969,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 2240, - 2208 + 2224, + 2960 ], "id": "bc3027d0-ab38-4585-bedb-ac7f494d50a7", "name": "Actualizar awaiting", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -3521,8 +3004,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 192, - 2288 + 176, + 3040 ], "id": "0bdea5f8-fae3-4848-aa1d-520335b6ef44", "name": "Insertar total de la factura", @@ -3533,39 +3016,6 @@ } } }, - { - "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", @@ -3674,170 +3124,6 @@ "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": { @@ -3852,7 +3138,7 @@ "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} ", + "content": "=En 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\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" } ] @@ -3913,7 +3199,7 @@ "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}", + "content": "En 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\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" } ] @@ -3966,7 +3252,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -3995,70 +3281,25 @@ "name": "Actualizar status a awaiting", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, { "parameters": { "method": "POST", - "url": "={{'https://wsp.gomezleemarketing.com'}}/message/sendText/{{'botsoporte'}}", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_merge_context", "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" + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" }, { "name": "Authorization", - "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" } ] }, @@ -4079,7 +3320,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -4108,8 +3349,8 @@ "name": "Guardar valores faltantes de contexto", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -4222,7 +3463,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -4251,8 +3492,8 @@ "name": "Actualizar status a report_open1", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -4263,8 +3504,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 1136, - 1040 + 1120, + 1792 ], "id": "d6a39d90-57e5-4435-8692-fc1a0664c7d3", "name": "Awaiting3" @@ -4276,8 +3517,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 576, - 448 + 560, + 1200 ], "id": "ea962bf1-5e08-4284-903e-a10e9e16416f", "name": "Detectar info faltante para contexto1" @@ -4285,7 +3526,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -4307,15 +3548,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 1136, - 848 + 1120, + 1600 ], "id": "accd45b1-0639-463f-8bf4-a49a97a14d9f", "name": "Actualizar status a report_open2", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -4326,8 +3567,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 576, - 624 + 560, + 1376 ], "id": "08dcef2e-a428-43de-b134-e78b4bbd6a9c", "name": "Detectar info faltante para contexto2" @@ -4339,8 +3580,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 576, - 816 + 560, + 1568 ], "id": "3b2d3354-1518-4237-ad89-f2f094e21c52", "name": "Detectar info faltante para contexto3" @@ -4352,8 +3593,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 576, - 1008 + 560, + 1760 ], "id": "e6809ba3-a714-4a11-9fb5-15e6f3618d6a", "name": "Detectar info faltante para contexto4" @@ -4365,8 +3606,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 576, - 1200 + 560, + 1952 ], "id": "1f8487a7-b309-4722-9130-866a645f1710", "name": "Detectar info faltante para contexto5" @@ -4399,8 +3640,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - 880, - 928 + 864, + 1680 ], "id": "ca6c5b47-961b-4429-9093-6dc0ee1681ef", "name": "Campo faltante?1" @@ -4408,7 +3649,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -4430,63 +3671,18 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 1296, - 1040 + 1280, + 1792 ], "id": "92d093b1-bd57-4c9e-bf70-bee52a47a1d2", "name": "Actualizar status a awaiting1", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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}];" @@ -4494,8 +3690,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 576, - 1392 + 560, + 2144 ], "id": "225d4085-bdaf-4dde-8a6f-d8197f1bd008", "name": "Detectar info faltante para contexto6" @@ -4514,7 +3710,30 @@ }, "conditions": [ { - "leftValue": "={{ ($json.state == \"idle\" || $json.state == \"report_open\") && $('Webhook').item.json.body.data.message.conversation == \"/ayuda\" }}", + "id": "d5f2f59c-9ed1-4b11-ac3f-aa35710376c4", + "leftValue": "={{ ($json.state == \"idle\") && $('Limpiador').item.json.message == \"/inicio\" || $('Limpiador').item.json.message == \"hola\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "leftValue": "={{ ($json.state == \"idle\" || $json.state == \"report_open\") && $('Limpiador').item.json.message == \"/ayuda\" }}", "rightValue": "", "operator": { "type": "boolean", @@ -4538,7 +3757,7 @@ "conditions": [ { "id": "56ea685f-796f-4e0f-bfed-e7a6343cb875", - "leftValue": "={{ ($json.state == \"report_open\") && $('Webhook').item.json.body.data.message.conversation == \"/estado\" }}", + "leftValue": "={{ ($json.state == \"report_open\") && $('Limpiador').item.json.message == \"/estado\" }}", "rightValue": "", "operator": { "type": "boolean", @@ -4561,30 +3780,7 @@ "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\" }}", + "leftValue": "={{ ($json.state == \"report_open\") && $('Limpiador').item.json.message == \"/cerrar\" }}", "rightValue": "", "operator": { "type": "boolean", @@ -4607,7 +3803,7 @@ "conditions": [ { "id": "5d97e4d1-a6e8-48c3-814c-41a6ea873a05", - "leftValue": "={{ ($json.state == \"report_open\") && $('Webhook').item.json.body.data.message.conversation == \"/cancelar\" }}", + "leftValue": "={{ ($json.state == \"report_open\") && $('Limpiador').item.json.message == \"/cancelar\" }}", "rightValue": "", "operator": { "type": "boolean", @@ -4619,6 +3815,29 @@ "combinator": "and" } }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "def3e19f-cd23-45a2-8add-c1e54a428405", + "leftValue": "={{ ($json.state == \"awaiting_open_report_confirm\") && $('Limpiador').item.json.button_answer }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, { "conditions": { "options": { @@ -4630,7 +3849,7 @@ "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) }}", + "leftValue": "={{ $json.state === \"report_open\" && ![\"/cerrar\", \"/ayuda\", \"/inicio\", \"/cancelar\", \"/estado\"].includes($('Limpiador').item.json.message) }}", "rightValue": "", "operator": { "type": "boolean", @@ -4649,102 +3868,12 @@ "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ - -1248, - -288 + -1856, + -1344 ], "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", @@ -4784,11 +3913,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - -976, - -800 + -2160, + -1936 ], "id": "ce37f7a7-4e2f-4d8c-8f1d-10090452d27e", - "name": "Comando ayuda" + "name": "Comando ayuda", + "disabled": true }, { "parameters": { @@ -4829,11 +3959,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - -976, - -608 + -2304, + -1760 ], "id": "9d0701a3-8d00-4107-9f20-e1c7fb609432", - "name": "Comando estado" + "name": "Comando estado", + "disabled": true }, { "parameters": { @@ -4860,11 +3991,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - -976, - -448 + -1120, + -544 ], "id": "8321f172-d435-45d9-8acd-7994c2cdad80", - "name": "Obtener info reporte" + "name": "Obtener info reporte", + "disabled": true }, { "parameters": { @@ -4905,39 +4037,40 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - -768, - -448 + -928, + -544 ], "id": "f385286e-8ff1-47f7-8500-eabc583d062f", - "name": "Comando cerrar" + "name": "Comando cerrar", + "disabled": true }, { "parameters": { "method": "POST", - "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/append_invoice", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_append_invoice", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" }, { "name": "Authorization", - "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" } ] }, "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}", + "jsonBody": "={\n \"p_report_id\": {{ JSON.stringify($('Es imagen?').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 + 2944, + 2640 ], "id": "8d82341d-741b-427d-a5f1-4d583e81849b", "name": "Insertar factura valida a la bd" @@ -4950,8 +4083,8 @@ "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ - -112, - -448 + -304, + -528 ], "id": "a84bdc0e-4dfa-467a-870e-c56fe000ab3d", "name": "Send a message", @@ -4970,8 +4103,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - -752, - -336 + -1008, + -96 ], "typeVersion": 1, "id": "ca09010b-3f64-4f2c-8644-50be0b9e55e2", @@ -5000,8 +4133,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - -560, - -528 + -720, + -624 ], "id": "84802e15-9032-4e3e-b32e-ebcd1e431a1a", "name": "Compartir fotos con jefe directo", @@ -5035,8 +4168,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - -560, - -352 + -720, + -448 ], "id": "9c36cc1a-8bc9-4908-8b97-4ec3581ef515", "name": "Compartir fotos con finanzas pais", @@ -5070,8 +4203,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - -352, - -352 + -512, + -448 ], "id": "0caf546e-82a0-4823-98f0-5951bfb5430f", "name": "Compartir sheet con finanzas pais", @@ -5105,8 +4238,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - -352, - -528 + -512, + -624 ], "id": "cacf7fd3-c0d1-44d8-b670-f9fa0627119e", "name": "Compartir sheet con jefe directo", @@ -5123,8 +4256,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - -272, - -288 + -528, + -48 ], "typeVersion": 1, "id": "2c71b670-e9eb-45c7-8ec2-17c7edc423f6", @@ -5169,16 +4302,17 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - -976, - -176 + -2304, + -1584 ], "id": "30b9c533-e8b1-4b9f-9f8a-b4ff28f2aa25", - "name": "Comando cancelar" + "name": "Comando cancelar", + "disabled": true }, { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -5191,7 +4325,7 @@ "fieldsUi": { "fieldValues": [ { - "fieldId": "draft_invoice", + "fieldId": "invoices", "fieldValue": "={{ JSON.stringify({ ...$('Edit Fields2').item.json.draft_invoice, total: parseFloat($('Webhook').item.json.body.data.message.conversation )}) }}" } ] @@ -5200,15 +4334,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 528, - 2288 + 512, + 3040 ], "id": "a1b7e539-6efd-487b-9324-514810f518ff", "name": "Insertar total", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -5229,8 +4363,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - 368, - 2288 + 352, + 3040 ], "id": "6186a30d-01a8-4438-be30-e5145cfdf6c4", "name": "Edit Fields2" @@ -5252,8 +4386,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - 736, - 2608 + 720, + 3360 ], "id": "ba478640-b801-4418-a4a0-dac75821cdc5", "name": "Edit Fields4" @@ -5286,8 +4420,8 @@ "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ - 1072, - 2608 + 1056, + 3360 ], "id": "e6dc31ab-e2c9-43f2-bf7e-c2085d19681b", "name": "Campo faltante?2" @@ -5299,8 +4433,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 896, - 2608 + 880, + 3360 ], "id": "444281e7-b26d-4db1-9087-4fb0d1f6ea41", "name": "Detectar valor critico1" @@ -5312,8 +4446,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 1280, - 2736 + 1264, + 3488 ], "id": "75bfa968-99c2-45e7-8ca4-b0f81bc5b5d5", "name": "Awaiting4" @@ -5321,7 +4455,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -5343,15 +4477,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 1440, - 2736 + 1424, + 3488 ], "id": "6fd8aeb5-5e9e-4dd2-8f49-9cde6995bfae", "name": "Actualizar status a awaiting2", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -5394,16 +4528,17 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 1632, - 2736 + 1616, + 3488 ], "id": "44844aa3-0184-4524-a50c-ca2d7c07d528", - "name": "Enviar alerta falta info2" + "name": "Enviar alerta falta info2", + "disabled": true }, { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -5425,15 +4560,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 1280, - 2560 + 1264, + 3312 ], "id": "2328807e-c3fb-47f9-961b-dd31c118b0a7", "name": "Actualizar status a report_open", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -5454,8 +4589,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - 368, - 2496 + 352, + 3248 ], "id": "2063a3ae-d56b-41f5-93dd-c2416d93b21e", "name": "Edit Fields5" @@ -5483,8 +4618,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 192, - 2496 + 176, + 3248 ], "id": "292bc28f-d4c3-4d15-b9e3-aac8e13478b1", "name": "Insertar proveedor de la factura", @@ -5498,7 +4633,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -5511,7 +4646,7 @@ "fieldsUi": { "fieldValues": [ { - "fieldId": "draft_invoice", + "fieldId": "invoices", "fieldValue": "={{ JSON.stringify({ ...$('Edit Fields5').item.json.draft_invoice, proveedor: $('Webhook').item.json.body.data.message.conversation }) }}" } ] @@ -5520,15 +4655,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 528, - 2496 + 512, + 3248 ], "id": "bbd87c71-795b-48b9-b3ba-8861e0f1ffcc", "name": "Insertar proveedor", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -5549,8 +4684,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - 368, - 2688 + 352, + 3440 ], "id": "99f830e8-a979-4ad1-a063-b64a1e54411f", "name": "Edit Fields6" @@ -5572,8 +4707,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - 368, - 2864 + 352, + 3616 ], "id": "05da15f6-c08a-424c-8af8-859255a33db7", "name": "Edit Fields7" @@ -5601,8 +4736,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 192, - 2688 + 176, + 3440 ], "id": "37e6deb8-d892-4d4d-83a8-16efb4b4c8be", "name": "Insertar rnc de la factura", @@ -5616,7 +4751,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -5629,7 +4764,7 @@ "fieldsUi": { "fieldValues": [ { - "fieldId": "draft_invoice", + "fieldId": "invoices", "fieldValue": "={{ JSON.stringify({ ...$('Edit Fields6').item.json.draft_invoice, nif_glm: $('Webhook').item.json.body.data.message.conversation }) }}" } ] @@ -5638,15 +4773,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 528, - 2688 + 512, + 3440 ], "id": "ad7ff633-df1f-4d92-b0e0-d8ab3404b628", "name": "Insertar rnc", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -5673,8 +4808,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 192, - 2864 + 176, + 3616 ], "id": "4e0c335d-0af1-4db6-a6bd-b8cb4d1ea071", "name": "Insertar fecha de la factura", @@ -5688,7 +4823,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -5701,7 +4836,7 @@ "fieldsUi": { "fieldValues": [ { - "fieldId": "draft_invoice", + "fieldId": "invoices", "fieldValue": "={{ JSON.stringify({ ...$('Edit Fields7').item.json.draft_invoice, fecha: $('Webhook').item.json.body.data.message.conversation }) }}" } ] @@ -5710,15 +4845,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 528, - 2864 + 512, + 3616 ], "id": "03b8ba19-34ea-4759-97e1-d4f32b9421db", "name": "Insertar fecha", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -5761,11 +4896,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 1632, - 2560 + 1616, + 3312 ], "id": "f0da2da8-d6cc-4370-b785-31f72f3f84c1", - "name": "Confirmacion factura recibida1" + "name": "Confirmacion factura recibida1", + "disabled": true }, { "parameters": { @@ -5784,8 +4920,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - 1440, - 2560 + 1424, + 3312 ], "id": "d7f84785-197d-4055-a569-7670159ab266", "name": "Edit Fields8" @@ -5796,8 +4932,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - 1760, - 2560 + 1744, + 3312 ], "typeVersion": 1, "id": "bb40e0ca-928f-4012-bfe3-3a85eb21d8d7", @@ -5842,8 +4978,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 1984, - 2576 + 1968, + 3328 ], "id": "0ed48df8-a9e7-4e2b-a5d0-abb4c9d8ba1d", "name": "Enviar mensaje de exito" @@ -5857,8 +4993,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - 160, - 2208 + 144, + 2960 ], "typeVersion": 1, "id": "79e667ee-3c45-4b39-b7d3-6d82eb2a52d4", @@ -5873,8 +5009,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - 144, - 384 + 160, + 1072 ], "typeVersion": 1, "id": "4d302623-74b3-4084-add4-af4e12c4f5b6", @@ -5883,23 +5019,23 @@ { "parameters": { "method": "POST", - "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" }, { "name": "Authorization", - "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" } ] }, "sendBody": true, "specifyBody": "json", - "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ tipoReporte: $('Reembolso').item.json.tipoReporte }) }}\n}", + "jsonBody": "={\n \"user_phone\": \"{{ $('Tipo de reporte').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ tipoReporte: $('Reembolso').item.json.tipoReporte }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", @@ -5914,23 +5050,23 @@ { "parameters": { "method": "POST", - "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" }, { "name": "Authorization", - "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" } ] }, "sendBody": true, "specifyBody": "json", - "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ tipoReporte: $('Anticipo').item.json.tipoReporte }) }}\n}", + "jsonBody": "={\n \"user_phone\": \"{{ $('Tipo de reporte').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ tipoReporte: $('Anticipo').item.json.tipoReporte }) }}\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", @@ -5951,8 +5087,8 @@ }, "type": "n8n-nodes-base.stickyNote", "position": [ - 160, - -848 + -1152, + -1344 ], "typeVersion": 1, "id": "3031d44a-c570-4ca3-bd84-d3d625b5fc9c", @@ -5960,7 +5096,7 @@ }, { "parameters": { - "content": "## Procesar mensajes\n\nDetecta si es un audio o texto", + "content": "## Procesar mensajes (anticipo)\n\nDetecta si es un audio o texto", "height": 352, "width": 1136, "color": 6 @@ -6006,51 +5142,6 @@ "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}" @@ -6058,8 +5149,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 2064, - 1872 + 2048, + 2624 ], "id": "7dbae3be-2ccf-4032-a409-a5ba48a5096a", "name": "Fecha periodo" @@ -6167,8 +5258,8 @@ "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ - 192, - 3184 + 176, + 3936 ], "id": "d442054d-b71d-4b03-8b63-5e28b12e6d31", "name": "Opciones fecha afuera periodo" @@ -6176,7 +5267,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -6198,15 +5289,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 1504, - 1872 + 1488, + 2624 ], "id": "d4979db7-4e2f-42d1-8b2a-882e0aeef049", "name": "Actualizar awaiting_fechaFuera", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -6235,8 +5326,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 1520, - 3056 + 1504, + 3808 ], "id": "c92f3b85-7857-479c-810f-ed129c7095c8", "name": "Insertar detalles de la factura al sheets1" @@ -6280,11 +5371,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 1712, - 3056 + 1696, + 3808 ], "id": "471d6dbd-c57d-4ee8-b6f3-1b22a317e2bb", - "name": "Confirmacion factura recibida2" + "name": "Confirmacion factura recibida2", + "disabled": true }, { "parameters": { @@ -6293,8 +5385,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 1344, - 3056 + 1328, + 3808 ], "id": "a237173b-9353-4063-a2c7-6f21b76d2ed8", "name": "Detalles de factura1" @@ -6316,8 +5408,8 @@ "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ - 832, - 3760 + 816, + 4512 ], "id": "ba190f10-167a-4961-91f1-819aed748457", "name": "Analyze audio1", @@ -6339,8 +5431,8 @@ "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ - 640, - 3760 + 624, + 4512 ], "id": "78456797-9b50-4385-a68f-0bf854720b3e", "name": "Convert to File3" @@ -6401,8 +5493,8 @@ "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ - 192, - 3856 + 176, + 4608 ], "id": "b0b10778-5dcf-48d7-815b-389794a71272", "name": "Audio o texto1" @@ -6433,8 +5525,8 @@ "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ - 1008, - 3760 + 992, + 4512 ], "id": "b3a9dfed-0d4b-4e21-bc58-5f961d51510f", "name": "Message a model2", @@ -6462,8 +5554,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - 1360, - 3856 + 1344, + 4608 ], "id": "7dd5a395-0983-439b-b8ad-1a216640bce9", "name": "Edit Fields9" @@ -6494,8 +5586,8 @@ "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ - 672, - 3952 + 656, + 4704 ], "id": "625bf77b-db79-4da3-b8ab-c16482398523", "name": "Message a model3", @@ -6537,16 +5629,17 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 464, - 3760 + 448, + 4512 ], "id": "97eaaed4-77d6-47ca-972c-3bf6da6f68cb", - "name": "Descargar audio1" + "name": "Descargar audio1", + "disabled": true }, { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -6568,15 +5661,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 464, - 3232 + 448, + 3984 ], "id": "314bcb45-82fd-4f9f-ad3f-1803706944cf", "name": "Actualizar awaiting_nuevaFechaPeriodo", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -6619,11 +5712,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 656, - 3232 + 640, + 3984 ], "id": "b11090e2-8c2c-4820-92b5-6f25edc9f8ee", - "name": "Pedir nueva fecha periodo" + "name": "Pedir nueva fecha periodo", + "disabled": true }, { "parameters": { @@ -6664,16 +5758,17 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 464, - 3584 + 448, + 4336 ], "id": "c0bd3237-e44b-4fb9-8f01-893ddc10f165", - "name": "Alerta opcion no valida1" + "name": "Alerta opcion no valida1", + "disabled": true }, { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -6695,22 +5790,22 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 656, - 3408 + 640, + 4160 ], "id": "3bef8c72-a52f-4fb9-b4fe-cfbffbb0b532", "name": "Actualizar report_open", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -6732,15 +5827,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 1888, - 1872 + 1872, + 2624 ], "id": "c3aa54bd-745e-4b48-9efa-e03b3f3eb929", "name": "Guardar factura temporalmente1", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -6751,8 +5846,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 1504, - 2048 + 1488, + 2800 ], "id": "6f90773a-38fa-4b53-8d23-7d56eb9e19dc", "name": "Detalles de factura2" @@ -6774,8 +5869,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - 464, - 3056 + 448, + 3808 ], "id": "02df5dc1-4ce4-4b18-b368-347269abd9bc", "name": "Edit Fields10" @@ -6787,8 +5882,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 2112, - 1696 + 2096, + 2448 ], "id": "456e9864-ce69-49d0-908a-741668f748b1", "name": "Binarios" @@ -6800,8 +5895,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 1712, - 1872 + 1696, + 2624 ], "id": "0a97a718-1eba-4269-a3b7-49af7ede87a2", "name": "Detalles de factura y binarios imagen" @@ -6825,8 +5920,8 @@ "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ - 1168, - 3056 + 1152, + 3808 ], "id": "964fbb71-b9c0-4e65-a9c3-e4fac1a117f1", "name": "Upload file1", @@ -6840,7 +5935,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -6862,15 +5957,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 1904, - 3056 + 1888, + 3808 ], "id": "b61cd0f1-435f-49d6-86b6-2f86dddaf09a", "name": "Borrar factura temporal", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -6881,8 +5976,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 640, - 3056 + 624, + 3808 ], "id": "e1e05aa1-ad22-4c76-8184-6f0ad2b37a09", "name": "Generar timestamp1" @@ -6898,8 +5993,8 @@ "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ - 992, - 3056 + 976, + 3808 ], "id": "b1f4cf97-4393-4a7d-b4ea-51713b7e6515", "name": "Convert to File4" @@ -6911,8 +6006,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 816, - 3056 + 800, + 3808 ], "id": "d82bdcc5-84c8-4f42-82c9-ccbb4b467efe", "name": "Binarios1" @@ -6920,7 +6015,7 @@ { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -6942,22 +6037,22 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 464, - 3408 + 448, + 4160 ], "id": "c2b56a96-499c-44b6-8e82-c876fcd0724d", "name": "Borrar factura temporal1", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -6979,22 +6074,22 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 2096, - 3056 + 2080, + 3808 ], "id": "76c49f9f-eac8-42af-a629-04aea5250f9f", "name": "Actualizar status a report_open3", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, { "parameters": { "operation": "update", - "tableId": "user_states", + "tableId": "liquidaciones_users", "filters": { "conditions": [ { @@ -7016,15 +6111,15 @@ "type": "n8n-nodes-base.supabase", "typeVersion": 1, "position": [ - 1920, - 3856 + 1904, + 4608 ], "id": "645c3d1e-2622-4de5-a6d6-6fb9ec78687c", "name": "Actualizar report_open1", "credentials": { "supabaseApi": { - "id": "yoWccgZ7JLKAGZPr", - "name": "Eidan reembolso - Supabase account" + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" } } }, @@ -7051,8 +6146,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 1536, - 3856 + 1520, + 4608 ], "id": "20dd69ef-164b-45dd-be04-54d8877bab7b", "name": "Insertar nuevo periodo al sheet", @@ -7066,17 +6161,17 @@ { "parameters": { "method": "POST", - "url": "https://jkqefbghutwzmznfgmck.supabase.co/rest/v1/rpc/merge_context", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/merge_context", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "apikey", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" }, { "name": "Authorization", - "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImprcWVmYmdodXR3em16bmZnbWNrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjcxNjI5OCwiZXhwIjoyMDkyMjkyMjk4fQ.DfFUD3DkcfWsXPsMiKgp81NTLd9pb13K4W3D63VxPjk" + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" } ] }, @@ -7088,8 +6183,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - 1728, - 3856 + 1712, + 4608 ], "id": "07c6e4d1-e68e-4466-beab-7239d81cdb1f", "name": "Insertar nuevo periodo en la bd" @@ -7111,8 +6206,8 @@ "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ - 2368, - 848 + 2352, + 1600 ], "id": "d65ef80f-512f-45bb-b4b3-ac735ae90a74", "name": "Analyze audio2", @@ -7134,8 +6229,8 @@ "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [ - 2176, - 848 + 2160, + 1600 ], "id": "4d310c8f-e30e-4d03-b581-9dc9172b843e", "name": "Convert to File5" @@ -7196,8 +6291,8 @@ "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ - 1728, - 944 + 1712, + 1696 ], "id": "bdf9f66a-2a17-45ea-9d7e-c2bfab3b53df", "name": "Audio o texto2" @@ -7228,8 +6323,8 @@ "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ - 2544, - 848 + 2528, + 1600 ], "id": "f9f8c1cf-8223-41df-aa29-4e05fd23e941", "name": "Message a model4", @@ -7257,8 +6352,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - 2896, - 944 + 2880, + 1696 ], "id": "6bb38dfb-5903-41a7-9b07-dd641f8515cf", "name": "Edit Fields11" @@ -7289,8 +6384,8 @@ "type": "@n8n/n8n-nodes-langchain.googleGemini", "typeVersion": 1.2, "position": [ - 2208, - 1040 + 2192, + 1792 ], "id": "149b4ff8-ba2a-4ece-9f68-6536f869aca3", "name": "Message a model5", @@ -7332,11 +6427,12 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 2000, - 848 + 1984, + 1600 ], "id": "8a09674d-fe34-44ee-b125-2f7538deeb1a", - "name": "Descargar audio2" + "name": "Descargar audio2", + "disabled": true }, { "parameters": { @@ -7359,8 +6455,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - -2400, - -304 + -3088, + -1168 ], "id": "c0f663e4-8f67-47a6-902b-f02b7c62d30c", "name": "Subir archivo", @@ -7380,8 +6476,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - -3008, - -416 + -3696, + -1280 ], "id": "9fe01190-a6b0-48b5-bff0-68740fe7c8dc", "name": "Obtener archivo", @@ -7414,8 +6510,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.4, "position": [ - -2400, - -512 + -3088, + -1376 ], "id": "91e04338-dd73-41fc-8557-5eb5815a9006", "name": "Actualizar archivo" @@ -7434,8 +6530,8 @@ "type": "n8n-nodes-base.n8n", "typeVersion": 1, "position": [ - -2752, - -512 + -3440, + -1376 ], "id": "97b1058d-9a9c-4179-beb0-7e44ae4bb4b0", "name": "Get a workflow1", @@ -7460,8 +6556,8 @@ "type": "n8n-nodes-base.n8n", "typeVersion": 1, "position": [ - -2752, - -304 + -3440, + -1168 ], "id": "9ee32ae6-1792-4fb7-8bd4-61ed84bc3ece", "name": "Get a workflow2", @@ -7495,8 +6591,8 @@ "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ - -3184, - -416 + -3872, + -1280 ], "id": "bbdb65bd-aebe-4e7f-91e1-e54190c50db1", "name": "Valores" @@ -7508,8 +6604,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - -2576, - -512 + -3264, + -1376 ], "id": "27182c76-5730-4623-b15e-80580f464b9c", "name": "Code in JavaScript2" @@ -7521,8 +6617,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - -2576, - -304 + -3264, + -1168 ], "id": "e1f4a452-0bd7-4ba9-ab2a-443d856a9e3d", "name": "Code in JavaScript4" @@ -7532,11 +6628,2258 @@ "type": "n8n-nodes-base.manualTrigger", "typeVersion": 1, "position": [ - -3392, - -416 + -4080, + -1280 ], "id": "a66245c9-5ff8-4f8d-bc47-c6f041111d07", "name": "When clicking ‘Execute workflow’" + }, + { + "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": [ + 1024, + 2800 + ], + "id": "c576804d-6c9a-4a55-a3b0-aee1b3020bb3", + "name": "Analyze an image", + "retryOnFail": true, + "waitBetweenTries": 5000, + "credentials": { + "googlePalmApi": { + "id": "tFqBJras00HUi1hA", + "name": "Eidan - Google Gemini(PaLM) Api account" + } + }, + "onError": "continueErrorOutput" + }, + { + "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).\n\nDebes realizar los siguientes pasos de forma estricta:\n1. Verificación obligatoria\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\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 la factura, 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": [ + 960, + 2544 + ], + "id": "b2c9feb9-026e-4de9-b2e1-85b6f8290cfe", + "name": "Analyze an image1 PRUEBA", + "retryOnFail": true, + "waitBetweenTries": 5000, + "credentials": { + "googlePalmApi": { + "id": "tFqBJras00HUi1hA", + "name": "Eidan - Google Gemini(PaLM) Api account" + } + }, + "onError": "continueErrorOutput" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "state", + "fieldValue": "awaiting_answerAnticipo" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + 880, + -384 + ], + "id": "212c1b12-4b90-47d4-aa17-936349e022b7", + "name": "Actualizar status a awaiting_answerAnticipo", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "state", + "fieldValue": "awaiting_answerReembolso" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + 880, + -176 + ], + "id": "6861f725-ed5d-4f68-95c9-3a2319eb20a1", + "name": "Actualizar status a awaiting_answerReembolso", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "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": [ + 992, + 640 + ], + "id": "b1fa234a-012e-4c71-85fd-ee1d5b9dbd05", + "name": "Analyze audio3", + "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": [ + 800, + 640 + ], + "id": "358f288a-a29b-47ef-aec2-deb661cc0c0c", + "name": "Convert to File6" + }, + { + "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": [ + 352, + 736 + ], + "id": "03b1fa3e-1cfc-45e5-8820-616207d89b5f", + "name": "Audio o texto3" + }, + { + "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- Motivo o destino del viaje\n- Cliente o proyecto\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 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": [ + 1168, + 640 + ], + "id": "46f220a0-5333-4742-a359-f9508da32780", + "name": "Message a model6", + "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": [ + 1520, + 736 + ], + "id": "ae74e5bc-5de5-4322-8a84-8669c7975d32", + "name": "Edit Fields12" + }, + { + "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- Motivo o destino del viaje\n- Cliente o proyecto\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 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": [ + 832, + 832 + ], + "id": "6b9ac520-cff0-4348-9908-38f51d418f20", + "name": "Message a model7", + "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": [ + 1712, + 736 + ], + "id": "2081a22e-0cda-47ad-90a8-d85b796ebbc2", + "name": "Detectar info faltante para contexto7" + }, + { + "parameters": { + "jsCode": "const camposFaltantes = $('Detectar info faltante para contexto7').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": [ + 2352, + 880 + ], + "id": "0a5f82da-6770-4e2a-9543-100f4c3dc94c", + "name": "Awaiting5" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 2528, + 880 + ], + "id": "cc7b275b-317d-44c7-9ec7-520f59d0e136", + "name": "Actualizar status a awaiting3", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "method": "POST", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_merge_context", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + }, + { + "name": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ \nperiodoInicio: $('Edit Fields12').item.json.content.parts[0].text.periodoInicio, \nperiodoFinalizacion: $('Edit Fields12').item.json.content.parts[0].text.periodoFinalizacion, \nmotivoDescripcion: $('Edit Fields12').item.json.content.parts[0].text.motivoDescripcion, \nruta: $('Edit Fields12').item.json.content.parts[0].text.ruta, \nclienteProyecto: $('Edit Fields12').item.json.content.parts[0].text.clienteProyecto,\nanticipoRecibido: parseFloat($('Edit Fields12').item.json.content.parts[0].text.anticipoRecibido)\n}) }}\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 2160, + 640 + ], + "id": "1e52f5d4-a6cd-4133-ac45-05d1c0923609", + "name": "Insertar contexto en la bd1" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Audio o texto3').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "pending_context", + "fieldValue": "={{ $json.campos_faltantes }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + 2160, + 880 + ], + "id": "d2541dc6-60a8-4166-be3f-0a12a117be0f", + "name": "Guardar valores faltantes de contexto1", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 624, + 640 + ], + "id": "f4df77c0-3cb6-46c7-bcd7-f6ebfb48f35b", + "name": "Descargar audio3" + }, + { + "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 Fields12').item.json.content.parts[0].text.periodoInicio }}\"]] },\n { \"range\": \"Liquidación!D11\", \"values\": [[\"{{ $('Edit Fields12').item.json.content.parts[0].text.periodoFinalizacion }}\"]] },\n { \"range\": \"Liquidación!D13\", \"values\": [[\"{{ $('Edit Fields12').item.json.content.parts[0].text.motivoDescripcion }}\"]] },\n { \"range\": \"Liquidación!D14\", \"values\": [[\"{{ $('Edit Fields12').item.json.content.parts[0].text.ruta }}\"]] },\n { \"range\": \"Liquidación!L6\", \"values\": [[\"{{ $('Edit Fields12').item.json.content.parts[0].text.clienteProyecto }}\"]] },\n { \"range\": \"Liquidación!R51\", \"values\": [[\"{{ $('Edit Fields12').item.json.content.parts[0].text.anticipoRecibido }}\"]] }\n ]\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 2352, + 640 + ], + "id": "99f1b973-a41b-4127-88ac-c48316aa3bbe", + "name": "Insertar contexto al sheet1", + "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": [ + 1872, + 736 + ], + "id": "b71b2888-923a-4e4a-b9c3-5bb4b66b8bd6", + "name": "Campo faltante?3" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 2528, + 640 + ], + "id": "c13b9f4e-8c1a-4625-87b2-3a223306873e", + "name": "Actualizar status a report_open4", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "content": "## Procesar mensajes (reembolso)\n\nDetecta si es un audio o texto", + "height": 352, + "width": 1136, + "color": 6 + }, + "type": "n8n-nodes-base.stickyNote", + "position": [ + 304, + 592 + ], + "typeVersion": 1, + "id": "d40eafa4-5e1b-4977-9a8b-5743ed4b9c9f", + "name": "Sticky Note18" + }, + { + "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": [ + 2128, + 560 + ], + "typeVersion": 1, + "id": "c21f2cd2-fb9a-47cd-b431-d5d6ae026fb1", + "name": "Sticky Note19" + }, + { + "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": [ + 1520, + -16 + ], + "id": "bfa118fc-08d8-4a34-aa85-1a2c1ee6976f", + "name": "Message a model8", + "credentials": { + "googlePalmApi": { + "id": "tFqBJras00HUi1hA", + "name": "Eidan - Google Gemini(PaLM) Api account" + } + } + }, + { + "parameters": { + "jsCode": "const msg = $input.first().json.messages?.[0];\nlet message_text = null;\n\nif (msg) {\n // Extraer el dato dependiendo del tipo de interacción\n if (msg.type === 'text') message_text = msg.text?.body;\n else if (msg.type === 'interactive') message_text = msg.interactive?.button_reply?.id || msg.interactive?.list_reply?.id;\n else if (msg.type === 'image') message_text = msg.image?.caption || null;\n}\n\nreturn [{\n json: {\n phone: msg?.from || null,\n message: message_text,\n has_media: msg?.type === 'image',\n media_id: msg?.type === 'image' ? msg.image?.id : null,\n button_answer: $input.first().json.messages?.[0]?.interactive?.button_reply?.id || null,\n list_answer: $input.first().json.messages?.[0]?.interactive?.list_reply?.id || null\n }\n}];" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + -4016, + -464 + ], + "id": "ca77d6d0-15ef-4a31-a2d6-fe8ad5c0f9d0", + "name": "Limpiador" + }, + { + "parameters": { + "url": "=https://glm.bamboohr.com/api/v1/employees/50467?fields=displayName,mobilePhone,workPhone,status,employeeNumber,supervisor,supervisorEmail,location,jobTitle,department,workEmail,hireDate,division,photoUploaded,photoUrl,birthday", + "authentication": "genericCredentialType", + "genericAuthType": "httpBasicAuth", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "accept", + "value": "application/json" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -3280, + 32 + ], + "id": "9daad65a-d50a-4aed-afae-1b151cd2bd0d", + "name": "Informacion del empleado1", + "retryOnFail": true, + "waitBetweenTries": 2000, + "credentials": { + "httpBasicAuth": { + "id": "vXrW3oJWVhNbzB07", + "name": "GLM Credential" + } + } + }, + { + "parameters": { + "tableId": "liquidaciones_users", + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "phone", + "fieldValue": "={{ $('Eliminar extension del numero').item.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": [ + -2608, + -384 + ], + "id": "7108c70b-9237-414c-b40e-739188698d7d", + "name": "Registrar telefono", + "alwaysOutputData": false, + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "operation": "get", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "keyValue": "={{ $('Eliminar extension del numero').item.json.phone }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -3008, + -464 + ], + "id": "406edede-d423-4123-9b22-a6e20a553cbc", + "name": "Obtener telefono", + "alwaysOutputData": true, + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "e414e5ff-8f7f-468a-870b-0d1fa945b489", + "leftValue": "", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + -2560, + -1488 + ], + "id": "dcb7cd66-e58b-4012-b1be-2183a954e0e9", + "name": "If" + }, + { + "parameters": { + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "template": "espanol_generic_yes_no|es", + "components": { + "component": [ + { + "type": "button", + "buttonParameters": { + "parameter": {} + } + } + ] + } + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + -1664, + 496 + ], + "id": "bd309fb8-b3c6-40d3-a13b-6bf657c25114", + "name": "Send template1", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "url": "https://graph.facebook.com/v23.0/2283524245752914/message_templates", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -2576, + -1344 + ], + "id": "1b3b6c2e-8cac-4e4c-ba04-f5c6ccd51478", + "name": "HTTP Request" + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/2283524245752914/message_templates", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"name\": \"ingles_generic_yes_no\",\n \"language\": \"en\",\n \"category\": \"UTILITY\",\n \"components\": [\n {\n \"type\": \"BODY\",\n \"text\": \"{{1}}\"\n },\n {\n \"type\": \"BUTTONS\",\n \"buttons\": [\n {\n \"type\": \"QUICK_REPLY\",\n \"text\": \"Yes\"\n },\n {\n \"type\": \"QUICK_REPLY\",\n \"text\": \"No\"\n }\n ]\n }\n ]\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -2576, + -1168 + ], + "id": "bef04f13-2acf-4bc5-872e-778b4e8ba180", + "name": "HTTP Request1" + }, + { + "parameters": { + "url": "https://graph.facebook.com/v23.0/2283524245752914/message_templates", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -2336, + -1328 + ], + "id": "e4711b95-4d42-4b2d-8891-31972c15b6ea", + "name": "HTTP Request2" + }, + { + "parameters": { + "method": "DELETE", + "url": "https://graph.facebook.com/v23.0/2283524245752914/message_templates?name=espanol_generic_yes_no", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "options": { + "timeout": 10000 + } + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -2336, + -1152 + ], + "id": "bbc47587-ed16-4b92-9761-0264a3a0fae3", + "name": "HTTP Request3" + }, + { + "parameters": { + "operation": "sendAndWait", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "message": "Estas seguro que quieres continuar?", + "responseType": "freeText", + "options": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + -1280, + 288 + ], + "id": "b98b06af-dc86-423f-bd2e-8c489bf2c990", + "name": "Send message and wait for response", + "webhookId": "39baf60b-3f56-4349-90aa-1b7ffd15548d", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + }, + "disabled": true + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¿Seguro que deseas continuar?\"\n },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"yes\",\n \"title\": \"Enviar\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"no\",\n \"title\": \"Editar\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1904, + 80 + ], + "id": "1d6608d6-32c2-44ba-90e6-b34f6d775679", + "name": "TEST" + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "Comandos disponibles:\n\n/inicio — crear reporte\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", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + -480, + -800 + ], + "id": "9d41e847-de54-48ca-b07b-d60a5242c7ce", + "name": "Mensaje ayuda", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=📋 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.", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + -640, + -848 + ], + "id": "ac13a87e-ceab-4c05-858e-52240b46cab7", + "name": "Mensaje estado", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "resource": "folder", + "operation": "deleteFolder", + "folderNoRootId": { + "__rl": true, + "mode": "list", + "value": "" + }, + "options": {} + }, + "type": "n8n-nodes-base.googleDrive", + "typeVersion": 3, + "position": [ + -944, + 32 + ], + "id": "b1cfda4f-fcc7-471e-9a6f-170dfe2d75fa", + "name": "Delete folder", + "credentials": { + "googleDriveOAuth2Api": { + "id": "gL2ZTwJb6xojauac", + "name": "Eidan - Google Drive account" + } + }, + "disabled": true + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "authentication": "predefinedCredentialType", + "nodeCredentialType": "httpBearerAuth", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¿Está seguro que quiere descartar el reporte?\"\n },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"yes\",\n \"title\": \"Sí\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"no\",\n \"title\": \"No\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1376, + 48 + ], + "id": "fdd8857f-3a43-4775-be84-83f05e6183b5", + "name": "Mensaje confirmacion cancelar", + "credentials": { + "httpBearerAuth": { + "id": "jC5wM1RXfA8Th6mo", + "name": "Eidan Liquidaciones WSP - Bearer Auth account" + } + } + }, + { + "parameters": { + "operation": "update" + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -1120, + 48 + ], + "id": "39ff45c0-ca54-41db-8483-6905d4843ea7", + "name": "Update a row", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + }, + "disabled": true + }, + { + "parameters": { + "content": "## Guardar id de la carpeta principal del reporte en la bd columna google_drive_report_folder_id", + "height": 208, + "width": 384 + }, + "type": "n8n-nodes-base.stickyNote", + "position": [ + -800, + -1424 + ], + "typeVersion": 1, + "id": "04d7b9e6-04c5-432e-818e-128424d590aa", + "name": "Sticky Note4" + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "authentication": "predefinedCredentialType", + "nodeCredentialType": "httpBearerAuth", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¿Está seguro que quiere crear un reporte?\"\n },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"yes\",\n \"title\": \"Sí\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"no\",\n \"title\": \"No\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1136, + -1888 + ], + "id": "b6302bad-d05a-4d71-a390-349c658ab04b", + "name": "Mensaje confirmacion crear reporte", + "credentials": { + "httpBearerAuth": { + "id": "jC5wM1RXfA8Th6mo", + "name": "Eidan Liquidaciones WSP - Bearer Auth account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "state", + "fieldValue": "awaiting_open_report_confirm" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -928, + -1888 + ], + "id": "190f1178-9391-4c09-b1ca-d96a6f7ff9f8", + "name": "Actualizar status a awaiting_open_report_confirm", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "loose", + "version": 3 + }, + "conditions": [ + { + "id": "ac86564e-1b34-49d4-be74-0685297a6f86", + "leftValue": "={{ [\"hey\", \"hola\"].includes($('Limpiador').item.json.message).toString() }}", + "rightValue": "=0", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + }, + "looseTypeValidation": true, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + -2448, + -672 + ], + "id": "5c9fec32-a119-4bc6-9c2c-4c142ae5c768", + "name": "Mensaje o comando" + }, + { + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "d5f2f59c-9ed1-4b11-ac3f-aa35710376c4", + "leftValue": "={{ $('Limpiador').item.json.list_answer == \"abrir_reporte\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "def3e19f-cd23-45a2-8add-c1e54a428405", + "leftValue": "={{ ($json.state == \"awaiting_open_report_confirm\") && $('Limpiador').item.json.button_answer == \"yes\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "b8db623f-4538-4225-baa5-76b5cff5b5c2", + "leftValue": "={{ ($json.state == \"awaiting_open_report_confirm\") && $('Limpiador').item.json.button_answer == \"no\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "56ea685f-796f-4e0f-bfed-e7a6343cb875", + "leftValue": "={{ $('Limpiador').item.json.list_answer == \"estado\" }}", + "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": "={{ $('Limpiador').item.json.list_answer == \"cancelar\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "725d409e-0496-47a4-b6fe-637c814089d9", + "leftValue": "={{ ($json.state == \"awaiting_open_report_confirm\") && $('Limpiador').item.json.button_answer == \"no\" }}", + "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": "={{ $('Limpiador').item.json.list_answer == \"cerrar\" }}", + "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 == \"awaiting_tipoReporte\") }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "cef3d83a-9e2a-4fd2-8bad-2c9ba891c9ae", + "leftValue": "={{ ($json.state == \"awaiting_answerAnticipo\") }}", + "rightValue": "awaiting_answerAnticipo", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "a5d28646-ae39-4a00-a494-1a18291766bf", + "leftValue": "={{ ($json.state == \"awaiting_answerReembolso\") }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "7277542a-9a91-420e-9d53-22356b8395f1", + "leftValue": "", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "0dfb7959-7106-4b8c-8afc-8c7a67d16cd5", + "leftValue": "", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.switch", + "typeVersion": 3.4, + "position": [ + -1904, + -480 + ], + "id": "b0b605aa-4e4e-43e9-9740-24e1d6389f91", + "name": "Switch2" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "state", + "fieldValue": "idle" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -1120, + -912 + ], + "id": "aa13bb42-11fe-4396-ac16-fedac6b12f0e", + "name": "Actualizar status a idle", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "e79e5ce8-ad25-48f0-b0e0-88131fe54a8a", + "leftValue": "", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + -928, + -736 + ], + "id": "cc876ee3-8304-47ef-8152-f27a5e77f5aa", + "name": "Tiene reporte abierto?" + }, + { + "parameters": { + "operation": "get", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -1120, + -736 + ], + "id": "6ed7f6bc-0a23-44ea-a0eb-2c778d24a9d1", + "name": "Obtener reporte1", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "e79e5ce8-ad25-48f0-b0e0-88131fe54a8a", + "leftValue": "={{ $json.report_id }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "notEmpty", + "singleValue": true + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + -1376, + -1184 + ], + "id": "d232a325-b1f9-4afa-9fcd-451daf041f86", + "name": "Tiene reporte abierto?1" + }, + { + "parameters": { + "operation": "get", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -1568, + -1184 + ], + "id": "183547fe-98fe-4570-b66b-44a2a2525559", + "name": "Obtener reporte2", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=⚠️ Ya tienes un reporte abierto.", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + -1200, + -1472 + ], + "id": "abf1bd05-d458-4af2-ab20-3d648154017c", + "name": "Avisar tiene reporte", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"list\",\n \"header\": {\n \"type\": \"text\",\n \"text\": \"Comandos\"\n },\n \"body\": {\n \"text\": \"Elige una opción de la lista.\"\n },\n \"footer\": {\n \"text\": \"Elija una acción\"\n },\n \"action\": {\n \"button\": \"Ver opciones\",\n \"sections\": [\n {\n \"title\": \"Acciones\",\n \"rows\": [\n { \"id\": \"ayuda\", \"title\": \"Ayuda\" },\n { \"id\": \"abrir_reporte\", \"title\": \"Abrir reporte\" },\n { \"id\": \"estado\", \"title\": \"Estado\" },\n { \"id\": \"cerrar\", \"title\": \"Cerrar\" },\n { \"id\": \"cancelar\", \"title\": \"Cancelar\" }\n ]\n }\n ]\n }\n}\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1904, + -912 + ], + "id": "5187eb3a-fc0e-4ce3-b226-5e64a8413567", + "name": "Enviar comandos" + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¿Seguro que deseas continuar?\"\n },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"yes\",\n \"title\": \"Enviar\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"no\",\n \"title\": \"Editar\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1328, + 352 + ], + "id": "e740657a-9a7f-4f46-9ec7-68a7e8ec30ec", + "name": "TEST1" + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "authentication": "predefinedCredentialType", + "nodeCredentialType": "httpBearerAuth", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¡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 },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"anticipo\",\n \"title\": \"Anticipo\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"reembolso\",\n \"title\": \"Reembolso\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 1952, + -1184 + ], + "id": "d2d809f6-e500-4e2c-98bb-dd146b1bba4e", + "name": "Pedir tipo de reporte", + "credentials": { + "httpBearerAuth": { + "id": "jC5wM1RXfA8Th6mo", + "name": "Eidan Liquidaciones WSP - Bearer Auth account" + } + } + }, + { + "parameters": { + "content": "## Preu", + "height": 208, + "width": 384 + }, + "type": "n8n-nodes-base.stickyNote", + "position": [ + -880, + -1936 + ], + "typeVersion": 1, + "id": "832027eb-63d5-4bf1-b1b5-03450dba0e2c", + "name": "Sticky Note9" + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "authentication": "predefinedCredentialType", + "nodeCredentialType": "httpBearerAuth", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¿Está seguro que quiere cancelar el reporte {{ $('Mensaje o comando').item.json.report_id }}?\"\n },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"anticipo\",\n \"title\": \"Anticipo\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"reembolso\",\n \"title\": \"Reembolso\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1120, + -336 + ], + "id": "367e1ebb-bca0-46be-9e03-d2c11af73bc2", + "name": "Confirmacion cancelar reporte", + "credentials": { + "httpBearerAuth": { + "id": "jC5wM1RXfA8Th6mo", + "name": "Eidan Liquidaciones WSP - Bearer Auth account" + } + } + }, + { + "parameters": { + "operation": "get", + "tableId": "empleados_glm", + "filters": { + "conditions": [ + { + "keyName": "country", + "keyValue": "=Trinidad and Tobago" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -3952, + -128 + ], + "id": "08945d44-2fdc-48dc-9734-eb1b0685e9c9", + "name": "Obtener empleado1", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "content": "## Obtener pais para cambiar lenguaje del bot", + "width": 304 + }, + "type": "n8n-nodes-base.stickyNote", + "position": [ + -4016, + -240 + ], + "typeVersion": 1, + "id": "5ed487fb-6af0-47c1-b06f-260d5cd33e38", + "name": "Sticky Note8" + }, + { + "parameters": { + "operation": "getAll", + "tableId": "empleados_glm", + "returnAll": true, + "filters": { + "conditions": [ + { + "keyName": "mobile_phone", + "condition": "fullText", + "searchFunction": "wfts", + "keyValue": "={{ $json.phone }}" + }, + { + "keyName": "work_phone", + "condition": "fullText", + "searchFunction": "wfts", + "keyValue": "={{ $json.phone }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -3680, + -464 + ], + "id": "b139b393-38ca-40c5-89a2-add7f5fca78d", + "name": "Obtener empleado", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"list\",\n \"header\": {\n \"type\": \"text\",\n \"text\": \"¡Ha sido registrado correctamente! 🎉\"\n },\n \"body\": {\n \"text\": \"Elige una opción de la lista.\"\n },\n \"action\": {\n \"button\": \"Ver opciones\",\n \"sections\": [\n {\n \"title\": \"Acciones\",\n \"rows\": [\n { \"id\": \"ayuda\", \"title\": \"Ayuda\" },\n { \"id\": \"abrir_reporte\", \"title\": \"Abrir reporte\" },\n { \"id\": \"estado\", \"title\": \"Estado\" },\n { \"id\": \"cerrar\", \"title\": \"Cerrar\" },\n { \"id\": \"cancelar\", \"title\": \"Cancelar\" }\n ]\n }\n ]\n }\n}\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -2400, + -384 + ], + "id": "ae4bd083-632f-440c-af59-64a8909d5183", + "name": "Enviar comandos1" + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=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)", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 1072, + -176 + ], + "id": "96a2c688-baa2-426b-ab87-cec321b7f7be", + "name": "Pedir info reembolso", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=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)", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 1072, + -384 + ], + "id": "cc569edf-6c62-4ca4-91bd-0fb89f3b3d96", + "name": "Pedir info anticipo", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=📋 *{{ $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, usa el comando cerrar para enviar al jefe.", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 1280, + 1600 + ], + "id": "71f68ca1-3a7d-448f-bfb9-78e164995e26", + "name": "Reporte abierto1", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "={{ $('Awaiting3').item.json.texto }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 1472, + 1792 + ], + "id": "8a8ba987-11c8-4e19-ae62-5c572786ae3f", + "name": "Enviar alerta falta info1", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=📋 *{{ $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, usa el comando cerrar para enviar al jefe.", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2688, + 80 + ], + "id": "f6f78a4f-ab5e-4731-84e8-6aee6bff263d", + "name": "Reporte abierto", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=📋 *{{ $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, usa el comando cerrar para enviar al jefe.", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2704, + 640 + ], + "id": "69036749-f4c4-47aa-bd7e-c17123440b60", + "name": "Reporte abierto4", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "={{ $('Awaiting2').item.json.texto }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2688, + 320 + ], + "id": "dabe4122-0a69-47f6-966e-eed4cbdc2cd1", + "name": "Enviar alerta falta info", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "={{ $('Awaiting5').item.json.texto }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2704, + 880 + ], + "id": "ef6f27ef-c6c2-4840-a5cb-eb4bc2ac3da1", + "name": "Enviar alerta falta info3", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=📸 *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?", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2944, + 2448 + ], + "id": "45d40589-d4e9-4c82-8b6c-75eec2aae521", + "name": "Confirmacion factura recibida", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=⚠️ 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", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2224, + 2624 + ], + "id": "25c21c2e-8818-4cc7-81fe-ab7c03d0b173", + "name": "Alerta factura fuera de periodo", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "={{ $('Awaiting').item.json.texto }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2416, + 2960 + ], + "id": "edcdbb93-ac62-4f22-8a66-3dd4a3522eba", + "name": "Alerta factura no es valida", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "={{ $('Awaiting').item.json.texto }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 1920, + 3504 + ], + "id": "3d483b93-4a34-442b-8393-fd595df83170", + "name": "Alerta factura no es valida1", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } } ], "connections": { @@ -7551,22 +8894,6 @@ ] ] }, - "Webhook": { - "main": [ - [ - { - "node": "Mi numero TESTING", - "type": "main", - "index": 0 - }, - { - "node": "Limpiar numero de telefono", - "type": "main", - "index": 0 - } - ] - ] - }, "Factura es valida?": { "main": [ [ @@ -7641,7 +8968,7 @@ "main": [ [ { - "node": "Analyze an image1", + "node": "Analyze an image1 PRUEBA", "type": "main", "index": 0 } @@ -7659,22 +8986,6 @@ ] ] }, - "Analyze an image1": { - "main": [ - [ - { - "node": "Edit Fields", - "type": "main", - "index": 0 - } - ] - ] - }, - "Send message and wait for response": { - "main": [ - [] - ] - }, "Buscar NCF duplicado": { "main": [ [ @@ -7706,31 +9017,14 @@ }, "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", + "node": "Mensaje o comando", "type": "main", "index": 0 } @@ -7739,20 +9033,9 @@ }, "Switch": { "main": [ - [ - { - "node": "Obtener reporte", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Tipo de reporte", - "type": "main", - "index": 0 - } - ], + [], + [], + [], [ { "node": "Audio o texto", @@ -7760,6 +9043,8 @@ "index": 0 } ], + [], + [], [ { "node": "Insertar ruta al sheet", @@ -7855,95 +9140,11 @@ [] ] }, - "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", + "node": "Obtener empleado", "type": "main", "index": 0 } @@ -7954,7 +9155,7 @@ "main": [ [ { - "node": "Get a row", + "node": "Obtener telefono", "type": "main", "index": 0 } @@ -7968,17 +9169,6 @@ ] ] }, - "Get a row": { - "main": [ - [ - { - "node": "Telefono registrado BD?", - "type": "main", - "index": 0 - } - ] - ] - }, "Numero esta registrado en GLM?": { "main": [ [ @@ -7999,13 +9189,7 @@ }, "Matchear numero de Whatsapp": { "main": [ - [ - { - "node": "Create a row", - "type": "main", - "index": 0 - } - ] + [] ] }, "Obtener reporte": { @@ -8024,7 +9208,7 @@ [], [ { - "node": "Crear reporte del id", + "node": "Mensaje confirmacion crear reporte", "type": "main", "index": 0 } @@ -8064,7 +9248,7 @@ ], [ { - "node": "Matchear numero de Whatsapp", + "node": "Registrar telefono", "type": "main", "index": 0 } @@ -8093,16 +9277,6 @@ ] ] }, - "Confirmacion factura recibida": { - "main": [ - [] - ] - }, - "Alerta factura no es valida": { - "main": [ - [] - ] - }, "Guardar factura temporalmente": { "main": [ [] @@ -8360,18 +9534,7 @@ "main": [ [ { - "node": "Pedir tipo reporte", - "type": "main", - "index": 0 - } - ] - ] - }, - "Pedir tipo reporte": { - "main": [ - [ - { - "node": "Obtener mes y año para el sheet", + "node": "Pedir tipo de reporte", "type": "main", "index": 0 } @@ -8382,7 +9545,7 @@ "main": [ [ { - "node": "Actualizar status a awaiting_answer", + "node": "Actualizar status a awaiting_answerAnticipo", "type": "main", "index": 0 } @@ -8418,7 +9581,7 @@ "main": [ [ { - "node": "Actualizar status a awaiting_answer1", + "node": "Actualizar status a awaiting_answerReembolso", "type": "main", "index": 0 } @@ -8655,17 +9818,6 @@ ] ] }, - "Informacion del empleado": { - "main": [ - [ - { - "node": "Wait1", - "type": "main", - "index": 0 - } - ] - ] - }, "Convert to File2": { "main": [ [ @@ -8688,50 +9840,6 @@ ] ] }, - "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": [ [ @@ -8997,48 +10105,13 @@ }, "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": { @@ -9054,13 +10127,7 @@ }, "Obtener info reporte": { "main": [ - [ - { - "node": "Comando cerrar", - "type": "main", - "index": 0 - } - ] + [] ] }, "Insertar moneda al contexto de reporte": { @@ -9322,11 +10389,6 @@ ] ] }, - "Alerta factura fuera de periodo": { - "main": [ - [] - ] - }, "Fecha periodo": { "main": [ [ @@ -9813,6 +10875,438 @@ } ] ] + }, + "Analyze an image1 PRUEBA": { + "main": [ + [ + { + "node": "Edit Fields", + "type": "main", + "index": 0 + } + ] + ] + }, + "Actualizar status a awaiting_answerAnticipo": { + "main": [ + [ + { + "node": "Pedir info anticipo", + "type": "main", + "index": 0 + } + ] + ] + }, + "Actualizar status a awaiting_answerReembolso": { + "main": [ + [ + { + "node": "Pedir info reembolso", + "type": "main", + "index": 0 + } + ] + ] + }, + "Analyze audio3": { + "main": [ + [ + { + "node": "Message a model6", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert to File6": { + "main": [ + [ + { + "node": "Analyze audio3", + "type": "main", + "index": 0 + } + ] + ] + }, + "Audio o texto3": { + "main": [ + [ + { + "node": "Descargar audio3", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Message a model7", + "type": "main", + "index": 0 + } + ] + ] + }, + "Message a model6": { + "main": [ + [ + { + "node": "Edit Fields12", + "type": "main", + "index": 0 + } + ] + ] + }, + "Edit Fields12": { + "main": [ + [ + { + "node": "Detectar info faltante para contexto7", + "type": "main", + "index": 0 + } + ] + ] + }, + "Message a model7": { + "main": [ + [ + { + "node": "Edit Fields12", + "type": "main", + "index": 0 + } + ] + ] + }, + "Detectar info faltante para contexto7": { + "main": [ + [ + { + "node": "Campo faltante?3", + "type": "main", + "index": 0 + } + ] + ] + }, + "Awaiting5": { + "main": [ + [ + { + "node": "Actualizar status a awaiting3", + "type": "main", + "index": 0 + } + ] + ] + }, + "Actualizar status a awaiting3": { + "main": [ + [ + { + "node": "Enviar alerta falta info3", + "type": "main", + "index": 0 + } + ] + ] + }, + "Insertar contexto en la bd1": { + "main": [ + [ + { + "node": "Insertar contexto al sheet1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Guardar valores faltantes de contexto1": { + "main": [ + [ + { + "node": "Awaiting5", + "type": "main", + "index": 0 + } + ] + ] + }, + "Descargar audio3": { + "main": [ + [ + { + "node": "Convert to File6", + "type": "main", + "index": 0 + } + ] + ] + }, + "Insertar contexto al sheet1": { + "main": [ + [ + { + "node": "Actualizar status a report_open4", + "type": "main", + "index": 0 + } + ] + ] + }, + "Campo faltante?3": { + "main": [ + [ + { + "node": "Insertar contexto en la bd1", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Guardar valores faltantes de contexto1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Actualizar status a report_open4": { + "main": [ + [ + { + "node": "Reporte abierto4", + "type": "main", + "index": 0 + } + ] + ] + }, + "WhatsApp Trigger": { + "main": [ + [ + { + "node": "Limpiador", + "type": "main", + "index": 0 + } + ] + ] + }, + "Limpiador": { + "main": [ + [ + { + "node": "Eliminar extension del numero", + "type": "main", + "index": 0 + } + ] + ] + }, + "Registrar telefono": { + "main": [ + [ + { + "node": "Enviar comandos1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Obtener telefono": { + "main": [ + [ + { + "node": "Telefono registrado BD?", + "type": "main", + "index": 0 + } + ] + ] + }, + "Send message and wait for response": { + "main": [ + [] + ] + }, + "Mensaje confirmacion crear reporte": { + "main": [ + [ + { + "node": "Actualizar status a awaiting_open_report_confirm", + "type": "main", + "index": 0 + } + ] + ] + }, + "Mensaje o comando": { + "main": [ + [ + { + "node": "Enviar comandos", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Switch2", + "type": "main", + "index": 0 + } + ] + ] + }, + "Switch2": { + "main": [ + [ + { + "node": "Obtener reporte", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Obtener reporte2", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Actualizar status a idle", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Obtener reporte1", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Confirmacion cancelar reporte", + "type": "main", + "index": 0 + } + ], + [], + [], + [ + { + "node": "Tipo de reporte", + "type": "main", + "index": 0 + } + ], + [], + [ + { + "node": "Audio o texto3", + "type": "main", + "index": 0 + } + ], + [], + [] + ] + }, + "Obtener reporte1": { + "main": [ + [ + { + "node": "Tiene reporte abierto?", + "type": "main", + "index": 0 + } + ] + ] + }, + "Obtener reporte2": { + "main": [ + [ + { + "node": "Tiene reporte abierto?1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Tiene reporte abierto?1": { + "main": [ + [ + { + "node": "Avisar tiene reporte", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Crear reporte del id", + "type": "main", + "index": 0 + } + ] + ] + }, + "Pedir tipo de reporte": { + "main": [ + [ + { + "node": "Obtener mes y año para el sheet", + "type": "main", + "index": 0 + } + ] + ] + }, + "Obtener empleado": { + "main": [ + [ + { + "node": "Numero esta registrado en GLM?", + "type": "main", + "index": 0 + } + ] + ] + }, + "Pedir info reembolso": { + "main": [ + [ + { + "node": "Insertar reembolso en la bd", + "type": "main", + "index": 0 + } + ] + ] + }, + "Pedir info anticipo": { + "main": [ + [ + { + "node": "Insertar anticipo en la bd", + "type": "main", + "index": 0 + } + ] + ] } }, "settings": { @@ -9832,148 +11326,36 @@ "templateCredsSetupCompleted": true }, "pinData": { - "Webhook": [ + "WhatsApp Trigger": [ { "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" + "messaging_product": "whatsapp", + "metadata": { + "display_phone_number": "18495127683", + "phone_number_id": "1204134409445693" }, - "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" + "contacts": [ + { + "profile": { + "name": "Eidan Then Elizo" }, - "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" + "wa_id": "18097159076", + "user_id": "DO.968971116188561" + } + ], + "messages": [ + { + "from": "18097159076", + "from_user_id": "DO.968971116188561", + "id": "wamid.HBgLMTgwOTcxNTkwNzYVAgASGBYzRUIwQjM5NUFCOUI0OEY2RjM4NDFEAA==", + "timestamp": "1785331408", + "text": { + "body": "Fecha es de 1 a 15 de mayo 2026, motivo viaje a Guatemala - visita GLM, cliente general" }, - "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" + "type": "text" + } + ], + "field": "messages" }, "pairedItem": { "item": 0 @@ -9981,10 +11363,10 @@ } ] }, - "versionId": "4ede5eec-57d9-4a2f-ae6b-8f6572f8c341", - "activeVersionId": null, - "versionCounter": 2543, - "triggerCount": 3, + "versionId": "646c5df8-703a-475c-befd-f99799e12a28", + "activeVersionId": "e2b74b23-6ad1-495a-a6dc-f185e94dd7b4", + "versionCounter": 3921, + "triggerCount": 1, "shared": [ { "updatedAt": "2026-05-28T13:53:39.519Z", @@ -10005,6 +11387,11373 @@ } ], "tags": [], - "activeVersion": null + "activeVersion": { + "updatedAt": "2026-07-29T13:23:14.000Z", + "createdAt": "2026-07-28T22:06:09.578Z", + "versionId": "e2b74b23-6ad1-495a-a6dc-f185e94dd7b4", + "workflowId": "eM8ZZafSC9M8GYd4", + "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": [ + 2416, + 2448 + ], + "id": "7ccd0408-1cc5-44d1-8466-56fb0b0f0b58", + "name": "Upload file", + "credentials": { + "googleDriveOAuth2Api": { + "id": "gL2ZTwJb6xojauac", + "name": "Eidan - Google Drive account" + } + } + }, + { + "parameters": { + "content": "## Trigger\n\nRecibe el mensaje enviado al bot", + "height": 256, + "width": 256 + }, + "type": "n8n-nodes-base.stickyNote", + "position": [ + -4368, + -576 + ], + "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": [ + 160, + 2368 + ], + "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": [ + 1280, + 2544 + ], + "id": "6f236c15-ff30-4ecf-9a24-596b020a58c8", + "name": "Factura es valida?" + }, + { + "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": [ + -3664, + -32 + ], + "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": [ + 176, + 2544 + ], + "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": [ + 608, + 2544 + ], + "id": "e6bb63d2-fa54-43ba-a27e-0954a92c21c7", + "name": "Descargar imagen de whatsapp", + "disabled": true + }, + { + "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": [ + 1120, + 2544 + ], + "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": [ + 800, + 2544 + ], + "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": [ + 2256, + 2448 + ], + "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": [ + 336, + 2688 + ], + "id": "3257977e-d001-4cde-8074-fe816716097f", + "name": "Alerta no es imagen", + "disabled": true + }, + { + "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": [ + 2384, + 2336 + ], + "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": [ + 2048, + 2384 + ], + "typeVersion": 1, + "id": "54fa0afe-8f9d-4d73-8b9f-8b3cb4c9ed61", + "name": "Sticky Note6" + }, + { + "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", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + }, + "disabled": true + }, + { + "parameters": { + "updates": [ + "messages" + ], + "options": {} + }, + "type": "n8n-nodes-base.whatsAppTrigger", + "typeVersion": 1, + "position": [ + -4272, + -464 + ], + "id": "04830804-459a-49fa-97ba-1c864641583c", + "name": "WhatsApp Trigger", + "webhookId": "11875011-47ee-4be7-81d2-f58384918645", + "credentials": { + "whatsAppTriggerApi": { + "id": "6UhrcQx21RbAmGPV", + "name": "Eidan - WhatsApp OAuth account" + } + } + }, + { + "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", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + }, + "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": [ + 1488, + 2448 + ], + "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'].toString() }}", + "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": [ + 1696, + 2448 + ], + "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": [ + 1920, + 2272 + ], + "id": "321c0e69-d2cb-49d0-a3bb-f2df98e5f9dd", + "name": "Alerta factura duplicada", + "disabled": true + }, + { + "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": [ + 1440, + 2256 + ], + "typeVersion": 1, + "id": "b1aea034-8775-44b1-b054-14606a6f9b5d", + "name": "Sticky Note Duplicados" + }, + { + "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": [ + -3456, + -144 + ], + "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": [ + -3360, + -352 + ], + "id": "d190a852-6785-4e69-afcb-094f821bfb7e", + "name": "Alerta numero no registrado", + "disabled": true + }, + { + "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": [ + -4064, + -576 + ], + "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": [ + -3104, + -352 + ], + "id": "0bacaa6f-5d3d-4941-b7d5-6bc30851feaa", + "name": "Alerta empleado no activo", + "disabled": true + }, + { + "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": [ + -1312, + -2016 + ], + "id": "cc1bf3fc-fbe6-4896-b569-254b9f9eb3a5", + "name": "Empleado tiene reporte abierto?" + }, + { + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "2fe4c704-a5e0-4483-a3e0-670f8183a597", + "leftValue": "={{ $json.state }}", + "rightValue": "awaiting_open_report_confirm", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "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": "f44e2174-0d46-4d47-a42c-80021cdcf444", + "leftValue": "={{ $json.state }}", + "rightValue": "awaiting_answerAnticipo", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "1b7f8895-8a5c-44d9-a0ed-47128209c844", + "leftValue": "={{ $json.state }}", + "rightValue": "awaiting_answerReembolso", + "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, + 464 + ], + "id": "c86e3729-6827-4580-bb09-93cfff9e1eb2", + "name": "Switch" + }, + { + "parameters": { + "operation": "get", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "keyValue": "={{ $json.phone }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -2608, + -544 + ], + "id": "07c3dcfd-9d6c-483b-865d-918fc83237aa", + "name": "Obtener status", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "jsCode": "return $input.all().map(item => {\n let phoneNumber = item.json.phone;\n\n if (phoneNumber) {\n phoneNumber = phoneNumber.replace(/\\D/g, \"\");\n phoneNumber = phoneNumber.slice(-10);\n }\n\n return {\n json: {\n phone: phoneNumber,\n message: $input.first().json.message,\n has_media: $input.first().json.has_media,\n media_id: $input.first().json.media_id\n }\n };\n});" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + -3856, + -464 + ], + "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": [ + -3248, + -464 + ], + "id": "5410d5da-e9b1-40d6-b5f5-45175169ac1c", + "name": "El empleado esta activo?" + }, + { + "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": [ + -3504, + -464 + ], + "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.phone;\n\n// Datos del nodo con los teléfonos del empleado\nconst mobilePhone = $('Obtener empleado').first().json.mobilePhone;\nconst workPhone = $('Obtener empleado').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": [ + -1760, + 272 + ], + "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": [ + 912, + 2736 + ], + "typeVersion": 1, + "id": "1e8f158c-88d9-4042-9cad-0df090c37cc4", + "name": "Sticky Note3" + }, + { + "parameters": { + "operation": "get", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "keyValue": "={{ $json.phone }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -1488, + -2016 + ], + "id": "ed081e87-5075-40e8-b982-14ee734f11bd", + "name": "Obtener reporte", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "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": [ + -1120, + -1184 + ], + "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: $('Tiene reporte abierto?1').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": [ + 2320, + -1184 + ], + "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": [ + -2832, + -464 + ], + "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": [ + 2512, + -1184 + ], + "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": [ + 2752, + 2448 + ], + "id": "9e3c13b9-3eb3-40ac-ba96-2bf093a8a828", + "name": "Insertar detalles de la factura al sheets" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 1696, + 2800 + ], + "id": "a8ce782d-4f4f-4d20-8b4c-c147d841671b", + "name": "Guardar factura temporalmente", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 176, + 1568 + ], + "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": [ + 176, + 1760 + ], + "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": [ + 176, + 1200 + ], + "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": [ + 176, + 2144 + ], + "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": [ + 432, + 2544 + ], + "id": "0ad99326-cf8b-44b4-9932-ed4b0a9f01b4", + "name": "Reaccionar", + "disabled": true + }, + { + "parameters": { + "resource": "folder", + "name": "={{ $('Tiene reporte abierto?1').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": [ + -432, + -1088 + ], + "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": [ + 560, + -1088 + ], + "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": [ + -592, + -1184 + ], + "id": "2d233a2a-3f97-4412-8024-7ec0431fccd7", + "name": "Existe carpeta X pais?" + }, + { + "parameters": { + "resource": "fileFolder", + "queryString": "={{ $('Tiene reporte abierto?1').item.json.country }}", + "returnAll": true, + "filter": { + "includeTrashed": false + }, + "options": {} + }, + "type": "n8n-nodes-base.googleDrive", + "typeVersion": 3, + "position": [ + -768, + -1184 + ], + "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": [ + -944, + -1184 + ], + "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": [ + 400, + -1184 + ], + "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": [ + 208, + -1184 + ], + "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": [ + -288, + -1184 + ], + "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": [ + -96, + -1184 + ], + "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": [ + 64, + -1088 + ], + "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": [ + 720, + -1184 + ], + "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": [ + 928, + -1184 + ], + "id": "08c93234-8b7e-4e53-8ccd-106e62defa16", + "name": "Existe carpeta X reporte?" + }, + { + "parameters": { + "resource": "folder", + "name": "={{ $('Crear reporte del id').item.json.reporteID + '-' + $('Tiene reporte abierto?1').item.json.name.split(' ')[0] + ($('Tiene reporte abierto?1').item.json.name.split(' ')[1] ? $('Tiene reporte abierto?1').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": [ + 1088, + -1088 + ], + "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 + '-' + $('Tiene reporte abierto?1').item.json.name.split(' ')[0] + ($('Tiene reporte abierto?1').item.json.name.split(' ')[1] ? $('Tiene reporte abierto?1').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": [ + 1424, + -1184 + ], + "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": [ + 2128, + -1184 + ], + "id": "ee2533a7-f4cb-4467-955c-3d2d2d6e6e9e", + "name": "Obtener mes y año para el sheet" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Tiene reporte abierto?1').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "state", + "fieldValue": "awaiting_tipoReporte" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + 1584, + -1184 + ], + "id": "5d5e0dfa-cbdd-4e23-acbf-f3a298e5ca8b", + "name": "Actualizar status a awaiting_tipoReporte", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 1760, + -1184 + ], + "id": "ff06051a-cc26-4e44-a471-1d9dc15305c7", + "name": "Solo primer nombre" + }, + { + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "leftValue": "={{ $('Limpiador').item.json.button_answer }}", + "rightValue": "=anticipo", + "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": "={{ $('Limpiador').item.json.button_answer }}", + "rightValue": "=reembolso", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "c45748cc-d1ba-47c3-a5ac-e990bc3fbddc", + "leftValue": "={{ ![\"reembolso\", \"anticipo\"].includes($('Limpiador').item.json.message) }}", + "rightValue": "", + "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": [ + 176, + 1952 + ], + "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": [ + 1264, + -1184 + ], + "id": "3a8ef3e9-471d-41ae-b247-c9900c379c0d", + "name": "Crear folder facturas", + "credentials": { + "googleDriveOAuth2Api": { + "id": "gL2ZTwJb6xojauac", + "name": "Eidan - Google Drive account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Eliminar extension del numero').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 }}" + }, + { + "fieldId": "google_drive_report_folder_id", + "fieldValue": "={{ $('Crear carpeta reporte').item.json.id }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + 2912, + -1184 + ], + "id": "c3d504e3-1d35-4589-967b-952c843d49ef", + "name": "Insertar reporte id, sheet id y factura folder id", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 384, + 1568 + ], + "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": [ + 384, + 1952 + ], + "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": [ + 384, + 1760 + ], + "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": [ + 384, + 1200 + ], + "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": [ + 384, + 2144 + ], + "id": "bf0a2f32-2127-46f3-b04f-5a3ceddb8772", + "name": "Insertar cliente/proyecto en la bd" + }, + { + "parameters": { + "method": "POST", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_merge_context", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + }, + { + "name": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"user_phone\": \"{{ $('Eliminar extension del numero').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": [ + 2704, + -1184 + ], + "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": [ + 176, + 1376 + ], + "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": [ + 384, + 1376 + ], + "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": [ + 1920, + 2448 + ], + "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.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": [ + 2576, + 2448 + ], + "id": "7d781acd-292f-4cbc-bfc7-c85ab7793778", + "name": "Detalles de factura" + }, + { + "parameters": { + "method": "POST", + "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $('Es imagen?').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!D12\", \"values\": [[\"{{ $json.valores[6] }}\"]] }\n \n ]\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 2752, + 2640 + ], + "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": "liquidaciones_users", + "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": [ + 2032, + 2960 + ], + "id": "45ebdf41-ede9-4aa1-9cc9-15a75b27b1f8", + "name": "Guardar valores faltantes", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 1696, + 2960 + ], + "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": [ + 1856, + 2960 + ], + "id": "f05feb15-6907-48bd-b1c9-03f34a2d3cec", + "name": "Awaiting" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 2224, + 2960 + ], + "id": "bc3027d0-ab38-4585-bedb-ac7f494d50a7", + "name": "Actualizar awaiting", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 176, + 3040 + ], + "id": "0bdea5f8-fae3-4848-aa1d-520335b6ef44", + "name": "Insertar total de la factura", + "credentials": { + "googleOAuth2Api": { + "id": "0HsSRUm82KPsWdiJ", + "name": "Eidan - Google account" + } + } + }, + { + "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": { + "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- 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\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": "En 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\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": "liquidaciones_users", + "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": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "method": "POST", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_merge_context", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + }, + { + "name": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + } + ] + }, + "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": "liquidaciones_users", + "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": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": "liquidaciones_users", + "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": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 1120, + 1792 + ], + "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": [ + 560, + 1200 + ], + "id": "ea962bf1-5e08-4284-903e-a10e9e16416f", + "name": "Detectar info faltante para contexto1" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 1120, + 1600 + ], + "id": "accd45b1-0639-463f-8bf4-a49a97a14d9f", + "name": "Actualizar status a report_open2", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 560, + 1376 + ], + "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": [ + 560, + 1568 + ], + "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": [ + 560, + 1760 + ], + "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": [ + 560, + 1952 + ], + "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": [ + 864, + 1680 + ], + "id": "ca6c5b47-961b-4429-9093-6dc0ee1681ef", + "name": "Campo faltante?1" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 1280, + 1792 + ], + "id": "92d093b1-bd57-4c9e-bf70-bee52a47a1d2", + "name": "Actualizar status a awaiting1", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 560, + 2144 + ], + "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": [ + { + "id": "d5f2f59c-9ed1-4b11-ac3f-aa35710376c4", + "leftValue": "={{ ($json.state == \"idle\") && $('Limpiador').item.json.message == \"/inicio\" || $('Limpiador').item.json.message == \"hola\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "leftValue": "={{ ($json.state == \"idle\" || $json.state == \"report_open\") && $('Limpiador').item.json.message == \"/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\") && $('Limpiador').item.json.message == \"/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\") && $('Limpiador').item.json.message == \"/cerrar\" }}", + "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\") && $('Limpiador').item.json.message == \"/cancelar\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "def3e19f-cd23-45a2-8add-c1e54a428405", + "leftValue": "={{ ($json.state == \"awaiting_open_report_confirm\") && $('Limpiador').item.json.button_answer }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "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($('Limpiador').item.json.message) }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.switch", + "typeVersion": 3.4, + "position": [ + -1856, + -1344 + ], + "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": "=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": [ + -2160, + -1936 + ], + "id": "ce37f7a7-4e2f-4d8c-8f1d-10090452d27e", + "name": "Comando ayuda", + "disabled": true + }, + { + "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": [ + -2304, + -1760 + ], + "id": "9d0701a3-8d00-4107-9f20-e1c7fb609432", + "name": "Comando estado", + "disabled": true + }, + { + "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": [ + -1120, + -544 + ], + "id": "8321f172-d435-45d9-8acd-7994c2cdad80", + "name": "Obtener info reporte", + "disabled": true + }, + { + "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": [ + -928, + -544 + ], + "id": "f385286e-8ff1-47f7-8500-eabc583d062f", + "name": "Comando cerrar", + "disabled": true + }, + { + "parameters": { + "method": "POST", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_append_invoice", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + }, + { + "name": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"p_report_id\": {{ JSON.stringify($('Es imagen?').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": [ + 2944, + 2640 + ], + "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": [ + -304, + -528 + ], + "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": [ + -1008, + -96 + ], + "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": [ + -720, + -624 + ], + "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": [ + -720, + -448 + ], + "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": [ + -512, + -448 + ], + "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": [ + -512, + -624 + ], + "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": [ + -528, + -48 + ], + "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": [ + -2304, + -1584 + ], + "id": "30b9c533-e8b1-4b9f-9f8a-b4ff28f2aa25", + "name": "Comando cancelar", + "disabled": true + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "invoices", + "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": [ + 512, + 3040 + ], + "id": "a1b7e539-6efd-487b-9324-514810f518ff", + "name": "Insertar total", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 352, + 3040 + ], + "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": [ + 720, + 3360 + ], + "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": [ + 1056, + 3360 + ], + "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": [ + 880, + 3360 + ], + "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": [ + 1264, + 3488 + ], + "id": "75bfa968-99c2-45e7-8ca4-b0f81bc5b5d5", + "name": "Awaiting4" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 1424, + 3488 + ], + "id": "6fd8aeb5-5e9e-4dd2-8f49-9cde6995bfae", + "name": "Actualizar status a awaiting2", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 1616, + 3488 + ], + "id": "44844aa3-0184-4524-a50c-ca2d7c07d528", + "name": "Enviar alerta falta info2", + "disabled": true + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 1264, + 3312 + ], + "id": "2328807e-c3fb-47f9-961b-dd31c118b0a7", + "name": "Actualizar status a report_open", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 352, + 3248 + ], + "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": [ + 176, + 3248 + ], + "id": "292bc28f-d4c3-4d15-b9e3-aac8e13478b1", + "name": "Insertar proveedor de la factura", + "credentials": { + "googleOAuth2Api": { + "id": "0HsSRUm82KPsWdiJ", + "name": "Eidan - Google account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "invoices", + "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": [ + 512, + 3248 + ], + "id": "bbd87c71-795b-48b9-b3ba-8861e0f1ffcc", + "name": "Insertar proveedor", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 352, + 3440 + ], + "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": [ + 352, + 3616 + ], + "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": [ + 176, + 3440 + ], + "id": "37e6deb8-d892-4d4d-83a8-16efb4b4c8be", + "name": "Insertar rnc de la factura", + "credentials": { + "googleOAuth2Api": { + "id": "0HsSRUm82KPsWdiJ", + "name": "Eidan - Google account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "invoices", + "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": [ + 512, + 3440 + ], + "id": "ad7ff633-df1f-4d92-b0e0-d8ab3404b628", + "name": "Insertar rnc", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 176, + 3616 + ], + "id": "4e0c335d-0af1-4db6-a6bd-b8cb4d1ea071", + "name": "Insertar fecha de la factura", + "credentials": { + "googleOAuth2Api": { + "id": "0HsSRUm82KPsWdiJ", + "name": "Eidan - Google account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "invoices", + "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": [ + 512, + 3616 + ], + "id": "03b8ba19-34ea-4759-97e1-d4f32b9421db", + "name": "Insertar fecha", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 1616, + 3312 + ], + "id": "f0da2da8-d6cc-4370-b785-31f72f3f84c1", + "name": "Confirmacion factura recibida1", + "disabled": true + }, + { + "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": [ + 1424, + 3312 + ], + "id": "d7f84785-197d-4055-a569-7670159ab266", + "name": "Edit Fields8" + }, + { + "parameters": { + "content": "## Botones de confirmacion si quiere editar" + }, + "type": "n8n-nodes-base.stickyNote", + "position": [ + 1744, + 3312 + ], + "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": [ + 1968, + 3328 + ], + "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": [ + 144, + 2960 + ], + "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": [ + 160, + 1072 + ], + "typeVersion": 1, + "id": "4d302623-74b3-4084-add4-af4e12c4f5b6", + "name": "Sticky Note13" + }, + { + "parameters": { + "method": "POST", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_merge_context", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + }, + { + "name": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"user_phone\": \"{{ $('Tipo de reporte').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://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_merge_context", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + }, + { + "name": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"user_phone\": \"{{ $('Tipo de reporte').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": [ + -1152, + -1344 + ], + "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": { + "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": [ + 2048, + 2624 + ], + "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": [ + 176, + 3936 + ], + "id": "d442054d-b71d-4b03-8b63-5e28b12e6d31", + "name": "Opciones fecha afuera periodo" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 1488, + 2624 + ], + "id": "d4979db7-4e2f-42d1-8b2a-882e0aeef049", + "name": "Actualizar awaiting_fechaFuera", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 1504, + 3808 + ], + "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": [ + 1696, + 3808 + ], + "id": "471d6dbd-c57d-4ee8-b6f3-1b22a317e2bb", + "name": "Confirmacion factura recibida2", + "disabled": true + }, + { + "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": [ + 1328, + 3808 + ], + "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": [ + 816, + 4512 + ], + "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": [ + 624, + 4512 + ], + "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": [ + 176, + 4608 + ], + "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": [ + 992, + 4512 + ], + "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": [ + 1344, + 4608 + ], + "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": [ + 656, + 4704 + ], + "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": [ + 448, + 4512 + ], + "id": "97eaaed4-77d6-47ca-972c-3bf6da6f68cb", + "name": "Descargar audio1", + "disabled": true + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 448, + 3984 + ], + "id": "314bcb45-82fd-4f9f-ad3f-1803706944cf", + "name": "Actualizar awaiting_nuevaFechaPeriodo", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 640, + 3984 + ], + "id": "b11090e2-8c2c-4820-92b5-6f25edc9f8ee", + "name": "Pedir nueva fecha periodo", + "disabled": true + }, + { + "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": [ + 448, + 4336 + ], + "id": "c0bd3237-e44b-4fb9-8f01-893ddc10f165", + "name": "Alerta opcion no valida1", + "disabled": true + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 640, + 4160 + ], + "id": "3bef8c72-a52f-4fb9-b4fe-cfbffbb0b532", + "name": "Actualizar report_open", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 1872, + 2624 + ], + "id": "c3aa54bd-745e-4b48-9efa-e03b3f3eb929", + "name": "Guardar factura temporalmente1", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 1488, + 2800 + ], + "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": [ + 448, + 3808 + ], + "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": [ + 2096, + 2448 + ], + "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": [ + 1696, + 2624 + ], + "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": [ + 1152, + 3808 + ], + "id": "964fbb71-b9c0-4e65-a9c3-e4fac1a117f1", + "name": "Upload file1", + "credentials": { + "googleDriveOAuth2Api": { + "id": "gL2ZTwJb6xojauac", + "name": "Eidan - Google Drive account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 1888, + 3808 + ], + "id": "b61cd0f1-435f-49d6-86b6-2f86dddaf09a", + "name": "Borrar factura temporal", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 624, + 3808 + ], + "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": [ + 976, + 3808 + ], + "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": [ + 800, + 3808 + ], + "id": "d82bdcc5-84c8-4f42-82c9-ccbb4b467efe", + "name": "Binarios1" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 448, + 4160 + ], + "id": "c2b56a96-499c-44b6-8e82-c876fcd0724d", + "name": "Borrar factura temporal1", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 2080, + 3808 + ], + "id": "76c49f9f-eac8-42af-a629-04aea5250f9f", + "name": "Actualizar status a report_open3", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 1904, + 4608 + ], + "id": "645c3d1e-2622-4de5-a6d6-6fb9ec78687c", + "name": "Actualizar report_open1", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 1520, + 4608 + ], + "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://dbit.digitalcompass.agency/rest/v1/rpc/merge_context", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + }, + { + "name": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + } + ] + }, + "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": [ + 1712, + 4608 + ], + "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": [ + 2352, + 1600 + ], + "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": [ + 2160, + 1600 + ], + "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": [ + 1712, + 1696 + ], + "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": [ + 2528, + 1600 + ], + "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": [ + 2880, + 1696 + ], + "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": [ + 2192, + 1792 + ], + "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": [ + 1984, + 1600 + ], + "id": "8a09674d-fe34-44ee-b125-2f7538deeb1a", + "name": "Descargar audio2", + "disabled": true + }, + { + "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": [ + -3088, + -1168 + ], + "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": [ + -3696, + -1280 + ], + "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": [ + -3088, + -1376 + ], + "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": [ + -3440, + -1376 + ], + "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": [ + -3440, + -1168 + ], + "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": [ + -3872, + -1280 + ], + "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": [ + -3264, + -1376 + ], + "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": [ + -3264, + -1168 + ], + "id": "e1f4a452-0bd7-4ba9-ab2a-443d856a9e3d", + "name": "Code in JavaScript4" + }, + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [ + -4080, + -1280 + ], + "id": "a66245c9-5ff8-4f8d-bc47-c6f041111d07", + "name": "When clicking ‘Execute workflow’" + }, + { + "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": [ + 1024, + 2800 + ], + "id": "c576804d-6c9a-4a55-a3b0-aee1b3020bb3", + "name": "Analyze an image", + "retryOnFail": true, + "waitBetweenTries": 5000, + "credentials": { + "googlePalmApi": { + "id": "tFqBJras00HUi1hA", + "name": "Eidan - Google Gemini(PaLM) Api account" + } + }, + "onError": "continueErrorOutput" + }, + { + "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).\n\nDebes realizar los siguientes pasos de forma estricta:\n1. Verificación obligatoria\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\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 la factura, 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": [ + 960, + 2544 + ], + "id": "b2c9feb9-026e-4de9-b2e1-85b6f8290cfe", + "name": "Analyze an image1 PRUEBA", + "retryOnFail": true, + "waitBetweenTries": 5000, + "credentials": { + "googlePalmApi": { + "id": "tFqBJras00HUi1hA", + "name": "Eidan - Google Gemini(PaLM) Api account" + } + }, + "onError": "continueErrorOutput" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "state", + "fieldValue": "awaiting_answerAnticipo" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + 880, + -384 + ], + "id": "212c1b12-4b90-47d4-aa17-936349e022b7", + "name": "Actualizar status a awaiting_answerAnticipo", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "state", + "fieldValue": "awaiting_answerReembolso" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + 880, + -176 + ], + "id": "6861f725-ed5d-4f68-95c9-3a2319eb20a1", + "name": "Actualizar status a awaiting_answerReembolso", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "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": [ + 992, + 640 + ], + "id": "b1fa234a-012e-4c71-85fd-ee1d5b9dbd05", + "name": "Analyze audio3", + "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": [ + 800, + 640 + ], + "id": "358f288a-a29b-47ef-aec2-deb661cc0c0c", + "name": "Convert to File6" + }, + { + "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": [ + 352, + 736 + ], + "id": "03b1fa3e-1cfc-45e5-8820-616207d89b5f", + "name": "Audio o texto3" + }, + { + "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- Motivo o destino del viaje\n- Cliente o proyecto\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 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": [ + 1168, + 640 + ], + "id": "46f220a0-5333-4742-a359-f9508da32780", + "name": "Message a model6", + "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": [ + 1520, + 736 + ], + "id": "ae74e5bc-5de5-4322-8a84-8669c7975d32", + "name": "Edit Fields12" + }, + { + "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- Motivo o destino del viaje\n- Cliente o proyecto\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 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": [ + 832, + 832 + ], + "id": "6b9ac520-cff0-4348-9908-38f51d418f20", + "name": "Message a model7", + "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": [ + 1712, + 736 + ], + "id": "2081a22e-0cda-47ad-90a8-d85b796ebbc2", + "name": "Detectar info faltante para contexto7" + }, + { + "parameters": { + "jsCode": "const camposFaltantes = $('Detectar info faltante para contexto7').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": [ + 2352, + 880 + ], + "id": "0a5f82da-6770-4e2a-9543-100f4c3dc94c", + "name": "Awaiting5" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 2528, + 880 + ], + "id": "cc7b275b-317d-44c7-9ec7-520f59d0e136", + "name": "Actualizar status a awaiting3", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "method": "POST", + "url": "https://dbit.digitalcompass.agency/rest/v1/rpc/liquidaciones_merge_context", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + }, + { + "name": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"user_phone\": \"{{ $('Switch').item.json.phone }}\",\n \"new_data\": {{ JSON.stringify({ \nperiodoInicio: $('Edit Fields12').item.json.content.parts[0].text.periodoInicio, \nperiodoFinalizacion: $('Edit Fields12').item.json.content.parts[0].text.periodoFinalizacion, \nmotivoDescripcion: $('Edit Fields12').item.json.content.parts[0].text.motivoDescripcion, \nruta: $('Edit Fields12').item.json.content.parts[0].text.ruta, \nclienteProyecto: $('Edit Fields12').item.json.content.parts[0].text.clienteProyecto,\nanticipoRecibido: parseFloat($('Edit Fields12').item.json.content.parts[0].text.anticipoRecibido)\n}) }}\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 2160, + 640 + ], + "id": "1e52f5d4-a6cd-4133-ac45-05d1c0923609", + "name": "Insertar contexto en la bd1" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Audio o texto3').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "pending_context", + "fieldValue": "={{ $json.campos_faltantes }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + 2160, + 880 + ], + "id": "d2541dc6-60a8-4166-be3f-0a12a117be0f", + "name": "Guardar valores faltantes de contexto1", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - 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": [ + 624, + 640 + ], + "id": "f4df77c0-3cb6-46c7-bcd7-f6ebfb48f35b", + "name": "Descargar audio3" + }, + { + "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 Fields12').item.json.content.parts[0].text.periodoInicio }}\"]] },\n { \"range\": \"Liquidación!D11\", \"values\": [[\"{{ $('Edit Fields12').item.json.content.parts[0].text.periodoFinalizacion }}\"]] },\n { \"range\": \"Liquidación!D13\", \"values\": [[\"{{ $('Edit Fields12').item.json.content.parts[0].text.motivoDescripcion }}\"]] },\n { \"range\": \"Liquidación!D14\", \"values\": [[\"{{ $('Edit Fields12').item.json.content.parts[0].text.ruta }}\"]] },\n { \"range\": \"Liquidación!L6\", \"values\": [[\"{{ $('Edit Fields12').item.json.content.parts[0].text.clienteProyecto }}\"]] },\n { \"range\": \"Liquidación!R51\", \"values\": [[\"{{ $('Edit Fields12').item.json.content.parts[0].text.anticipoRecibido }}\"]] }\n ]\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 2352, + 640 + ], + "id": "99f1b973-a41b-4127-88ac-c48316aa3bbe", + "name": "Insertar contexto al sheet1", + "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": [ + 1872, + 736 + ], + "id": "b71b2888-923a-4e4a-b9c3-5bb4b66b8bd6", + "name": "Campo faltante?3" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "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": [ + 2528, + 640 + ], + "id": "c13b9f4e-8c1a-4625-87b2-3a223306873e", + "name": "Actualizar status a report_open4", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "content": "## Procesar mensajes\n\nDetecta si es un audio o texto", + "height": 352, + "width": 1136, + "color": 6 + }, + "type": "n8n-nodes-base.stickyNote", + "position": [ + 304, + 592 + ], + "typeVersion": 1, + "id": "d40eafa4-5e1b-4977-9a8b-5743ed4b9c9f", + "name": "Sticky Note18" + }, + { + "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": [ + 2128, + 560 + ], + "typeVersion": 1, + "id": "c21f2cd2-fb9a-47cd-b431-d5d6ae026fb1", + "name": "Sticky Note19" + }, + { + "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": [ + 1520, + -16 + ], + "id": "bfa118fc-08d8-4a34-aa85-1a2c1ee6976f", + "name": "Message a model8", + "credentials": { + "googlePalmApi": { + "id": "tFqBJras00HUi1hA", + "name": "Eidan - Google Gemini(PaLM) Api account" + } + } + }, + { + "parameters": { + "jsCode": "const msg = $input.first().json.messages?.[0];\nlet message_text = null;\n\nif (msg) {\n // Extraer el dato dependiendo del tipo de interacción\n if (msg.type === 'text') message_text = msg.text?.body;\n else if (msg.type === 'interactive') message_text = msg.interactive?.button_reply?.id || msg.interactive?.list_reply?.id;\n else if (msg.type === 'image') message_text = msg.image?.caption || null;\n}\n\nreturn [{\n json: {\n phone: msg?.from || null,\n message: message_text,\n has_media: msg?.type === 'image',\n media_id: msg?.type === 'image' ? msg.image?.id : null,\n button_answer: $input.first().json.messages?.[0]?.interactive?.button_reply?.id || null,\n list_answer: $input.first().json.messages?.[0]?.interactive?.list_reply?.id || null\n }\n}];" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + -4016, + -464 + ], + "id": "ca77d6d0-15ef-4a31-a2d6-fe8ad5c0f9d0", + "name": "Limpiador" + }, + { + "parameters": { + "url": "=https://glm.bamboohr.com/api/v1/employees/50467?fields=displayName,mobilePhone,workPhone,status,employeeNumber,supervisor,supervisorEmail,location,jobTitle,department,workEmail,hireDate,division,photoUploaded,photoUrl,birthday", + "authentication": "genericCredentialType", + "genericAuthType": "httpBasicAuth", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "accept", + "value": "application/json" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -3280, + 32 + ], + "id": "9daad65a-d50a-4aed-afae-1b151cd2bd0d", + "name": "Informacion del empleado1", + "retryOnFail": true, + "waitBetweenTries": 2000, + "credentials": { + "httpBasicAuth": { + "id": "vXrW3oJWVhNbzB07", + "name": "GLM Credential" + } + } + }, + { + "parameters": { + "tableId": "liquidaciones_users", + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "phone", + "fieldValue": "={{ $('Eliminar extension del numero').item.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": [ + -2608, + -384 + ], + "id": "7108c70b-9237-414c-b40e-739188698d7d", + "name": "Registrar telefono", + "alwaysOutputData": false, + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "operation": "get", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "keyValue": "={{ $('Eliminar extension del numero').item.json.phone }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -3008, + -464 + ], + "id": "406edede-d423-4123-9b22-a6e20a553cbc", + "name": "Obtener telefono", + "alwaysOutputData": true, + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "e414e5ff-8f7f-468a-870b-0d1fa945b489", + "leftValue": "", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + -2560, + -1488 + ], + "id": "dcb7cd66-e58b-4012-b1be-2183a954e0e9", + "name": "If" + }, + { + "parameters": { + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "template": "espanol_generic_yes_no|es", + "components": { + "component": [ + { + "type": "button", + "buttonParameters": { + "parameter": {} + } + } + ] + } + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + -1664, + 496 + ], + "id": "bd309fb8-b3c6-40d3-a13b-6bf657c25114", + "name": "Send template1", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "url": "https://graph.facebook.com/v23.0/2283524245752914/message_templates", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -2576, + -1344 + ], + "id": "1b3b6c2e-8cac-4e4c-ba04-f5c6ccd51478", + "name": "HTTP Request" + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/2283524245752914/message_templates", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"name\": \"ingles_generic_yes_no\",\n \"language\": \"en\",\n \"category\": \"UTILITY\",\n \"components\": [\n {\n \"type\": \"BODY\",\n \"text\": \"{{1}}\"\n },\n {\n \"type\": \"BUTTONS\",\n \"buttons\": [\n {\n \"type\": \"QUICK_REPLY\",\n \"text\": \"Yes\"\n },\n {\n \"type\": \"QUICK_REPLY\",\n \"text\": \"No\"\n }\n ]\n }\n ]\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -2576, + -1168 + ], + "id": "bef04f13-2acf-4bc5-872e-778b4e8ba180", + "name": "HTTP Request1" + }, + { + "parameters": { + "url": "https://graph.facebook.com/v23.0/2283524245752914/message_templates", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -2336, + -1328 + ], + "id": "e4711b95-4d42-4b2d-8891-31972c15b6ea", + "name": "HTTP Request2" + }, + { + "parameters": { + "method": "DELETE", + "url": "https://graph.facebook.com/v23.0/2283524245752914/message_templates?name=espanol_generic_yes_no", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "options": { + "timeout": 10000 + } + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -2336, + -1152 + ], + "id": "bbc47587-ed16-4b92-9761-0264a3a0fae3", + "name": "HTTP Request3" + }, + { + "parameters": { + "operation": "sendAndWait", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "message": "Estas seguro que quieres continuar?", + "responseType": "freeText", + "options": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + -1280, + 288 + ], + "id": "b98b06af-dc86-423f-bd2e-8c489bf2c990", + "name": "Send message and wait for response", + "webhookId": "39baf60b-3f56-4349-90aa-1b7ffd15548d", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + }, + "disabled": true + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¿Seguro que deseas continuar?\"\n },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"yes\",\n \"title\": \"Enviar\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"no\",\n \"title\": \"Editar\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1904, + 80 + ], + "id": "1d6608d6-32c2-44ba-90e6-b34f6d775679", + "name": "TEST" + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "Comandos disponibles:\n\n/inicio — crear reporte\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", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + -480, + -800 + ], + "id": "9d41e847-de54-48ca-b07b-d60a5242c7ce", + "name": "Mensaje ayuda", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=📋 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.", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + -640, + -848 + ], + "id": "ac13a87e-ceab-4c05-858e-52240b46cab7", + "name": "Mensaje estado", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "resource": "folder", + "operation": "deleteFolder", + "folderNoRootId": { + "__rl": true, + "mode": "list", + "value": "" + }, + "options": {} + }, + "type": "n8n-nodes-base.googleDrive", + "typeVersion": 3, + "position": [ + -944, + 32 + ], + "id": "b1cfda4f-fcc7-471e-9a6f-170dfe2d75fa", + "name": "Delete folder", + "credentials": { + "googleDriveOAuth2Api": { + "id": "gL2ZTwJb6xojauac", + "name": "Eidan - Google Drive account" + } + }, + "disabled": true + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "authentication": "predefinedCredentialType", + "nodeCredentialType": "httpBearerAuth", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¿Está seguro que quiere descartar el reporte?\"\n },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"yes\",\n \"title\": \"Sí\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"no\",\n \"title\": \"No\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1376, + 48 + ], + "id": "fdd8857f-3a43-4775-be84-83f05e6183b5", + "name": "Mensaje confirmacion cancelar", + "credentials": { + "httpBearerAuth": { + "id": "jC5wM1RXfA8Th6mo", + "name": "Eidan Liquidaciones WSP - Bearer Auth account" + } + } + }, + { + "parameters": { + "operation": "update" + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -1120, + 48 + ], + "id": "39ff45c0-ca54-41db-8483-6905d4843ea7", + "name": "Update a row", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + }, + "disabled": true + }, + { + "parameters": { + "content": "## Guardar id de la carpeta principal del reporte en la bd columna google_drive_report_folder_id", + "height": 208, + "width": 384 + }, + "type": "n8n-nodes-base.stickyNote", + "position": [ + -800, + -1424 + ], + "typeVersion": 1, + "id": "04d7b9e6-04c5-432e-818e-128424d590aa", + "name": "Sticky Note4" + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "authentication": "predefinedCredentialType", + "nodeCredentialType": "httpBearerAuth", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¿Está seguro que quiere crear un reporte?\"\n },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"yes\",\n \"title\": \"Sí\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"no\",\n \"title\": \"No\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1136, + -1888 + ], + "id": "b6302bad-d05a-4d71-a390-349c658ab04b", + "name": "Mensaje confirmacion crear reporte", + "credentials": { + "httpBearerAuth": { + "id": "jC5wM1RXfA8Th6mo", + "name": "Eidan Liquidaciones WSP - Bearer Auth account" + } + } + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "state", + "fieldValue": "awaiting_open_report_confirm" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -928, + -1888 + ], + "id": "190f1178-9391-4c09-b1ca-d96a6f7ff9f8", + "name": "Actualizar status a awaiting_open_report_confirm", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "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": [ + -656, + 320 + ], + "id": "c435db57-2785-4e21-b32f-54fb9b2783b6", + "name": "Confirmar crear reporte SI/NO" + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "loose", + "version": 3 + }, + "conditions": [ + { + "id": "ac86564e-1b34-49d4-be74-0685297a6f86", + "leftValue": "={{ [\"hey\", \"hola\"].includes($('Limpiador').item.json.message).toString() }}", + "rightValue": "=0", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + }, + "looseTypeValidation": true, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + -2448, + -672 + ], + "id": "5c9fec32-a119-4bc6-9c2c-4c142ae5c768", + "name": "Mensaje o comando" + }, + { + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "d5f2f59c-9ed1-4b11-ac3f-aa35710376c4", + "leftValue": "={{ $('Limpiador').item.json.list_answer == \"abrir_reporte\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "def3e19f-cd23-45a2-8add-c1e54a428405", + "leftValue": "={{ ($json.state == \"awaiting_open_report_confirm\") && $('Limpiador').item.json.button_answer == \"yes\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "b8db623f-4538-4225-baa5-76b5cff5b5c2", + "leftValue": "={{ ($json.state == \"awaiting_open_report_confirm\") && $('Limpiador').item.json.button_answer == \"no\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "56ea685f-796f-4e0f-bfed-e7a6343cb875", + "leftValue": "={{ $('Limpiador').item.json.list_answer == \"estado\" }}", + "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": "={{ $('Limpiador').item.json.list_answer == \"cancelar\" }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "725d409e-0496-47a4-b6fe-637c814089d9", + "leftValue": "={{ ($json.state == \"awaiting_open_report_confirm\") && $('Limpiador').item.json.button_answer == \"no\" }}", + "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": "={{ $('Limpiador').item.json.list_answer == \"cerrar\" }}", + "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 == \"awaiting_tipoReporte\") }}", + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "cef3d83a-9e2a-4fd2-8bad-2c9ba891c9ae", + "leftValue": "={{ ($json.state == \"awaiting_answerReembolso\") }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "a5d28646-ae39-4a00-a494-1a18291766bf", + "leftValue": "", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "7277542a-9a91-420e-9d53-22356b8395f1", + "leftValue": "", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "0dfb7959-7106-4b8c-8afc-8c7a67d16cd5", + "leftValue": "", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.switch", + "typeVersion": 3.4, + "position": [ + -1904, + -480 + ], + "id": "b0b605aa-4e4e-43e9-9740-24e1d6389f91", + "name": "Switch2" + }, + { + "parameters": { + "operation": "update", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "condition": "eq", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + }, + "fieldsUi": { + "fieldValues": [ + { + "fieldId": "state", + "fieldValue": "idle" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -1120, + -912 + ], + "id": "aa13bb42-11fe-4396-ac16-fedac6b12f0e", + "name": "Actualizar status a idle", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "e79e5ce8-ad25-48f0-b0e0-88131fe54a8a", + "leftValue": "", + "rightValue": "", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + -928, + -736 + ], + "id": "cc876ee3-8304-47ef-8152-f27a5e77f5aa", + "name": "Tiene reporte abierto?" + }, + { + "parameters": { + "operation": "get", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -1120, + -736 + ], + "id": "6ed7f6bc-0a23-44ea-a0eb-2c778d24a9d1", + "name": "Obtener reporte1", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "e79e5ce8-ad25-48f0-b0e0-88131fe54a8a", + "leftValue": "={{ $json.report_id }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "notEmpty", + "singleValue": true + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + -1376, + -1184 + ], + "id": "d232a325-b1f9-4afa-9fcd-451daf041f86", + "name": "Tiene reporte abierto?1" + }, + { + "parameters": { + "operation": "get", + "tableId": "liquidaciones_users", + "filters": { + "conditions": [ + { + "keyName": "phone", + "keyValue": "={{ $('Obtener status').item.json.phone }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -1568, + -1184 + ], + "id": "183547fe-98fe-4570-b66b-44a2a2525559", + "name": "Obtener reporte2", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=⚠️ Ya tienes un reporte abierto.", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + -1200, + -1472 + ], + "id": "abf1bd05-d458-4af2-ab20-3d648154017c", + "name": "Avisar tiene reporte", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"list\",\n \"header\": {\n \"type\": \"text\",\n \"text\": \"Comandos\"\n },\n \"body\": {\n \"text\": \"Elige una opción de la lista.\"\n },\n \"footer\": {\n \"text\": \"Elija una acción\"\n },\n \"action\": {\n \"button\": \"Ver opciones\",\n \"sections\": [\n {\n \"title\": \"Acciones\",\n \"rows\": [\n { \"id\": \"ayuda\", \"title\": \"Ayuda\" },\n { \"id\": \"abrir_reporte\", \"title\": \"Abrir reporte\" },\n { \"id\": \"estado\", \"title\": \"Estado\" },\n { \"id\": \"cerrar\", \"title\": \"Cerrar\" },\n { \"id\": \"cancelar\", \"title\": \"Cancelar\" }\n ]\n }\n ]\n }\n}\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1904, + -912 + ], + "id": "5187eb3a-fc0e-4ce3-b226-5e64a8413567", + "name": "Enviar comandos" + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¿Seguro que deseas continuar?\"\n },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"yes\",\n \"title\": \"Enviar\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"no\",\n \"title\": \"Editar\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1328, + 352 + ], + "id": "e740657a-9a7f-4f46-9ec7-68a7e8ec30ec", + "name": "TEST1" + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "authentication": "predefinedCredentialType", + "nodeCredentialType": "httpBearerAuth", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¡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 },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"anticipo\",\n \"title\": \"Anticipo\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"reembolso\",\n \"title\": \"Reembolso\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 1952, + -1184 + ], + "id": "d2d809f6-e500-4e2c-98bb-dd146b1bba4e", + "name": "Pedir tipo de reporte", + "credentials": { + "httpBearerAuth": { + "id": "jC5wM1RXfA8Th6mo", + "name": "Eidan Liquidaciones WSP - Bearer Auth account" + } + } + }, + { + "parameters": { + "content": "## Preu", + "height": 208, + "width": 384 + }, + "type": "n8n-nodes-base.stickyNote", + "position": [ + -880, + -1936 + ], + "typeVersion": 1, + "id": "832027eb-63d5-4bf1-b1b5-03450dba0e2c", + "name": "Sticky Note9" + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "authentication": "predefinedCredentialType", + "nodeCredentialType": "httpBearerAuth", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"button\",\n \"body\": {\n \"text\": \"¿Está seguro que quiere cancelar el reporte {{ $('Mensaje o comando').item.json.report_id }}?\"\n },\n \"action\": {\n \"buttons\": [\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"anticipo\",\n \"title\": \"Anticipo\"\n }\n },\n {\n \"type\": \"reply\",\n \"reply\": {\n \"id\": \"reembolso\",\n \"title\": \"Reembolso\"\n }\n }\n ]\n }\n }\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -1120, + -336 + ], + "id": "367e1ebb-bca0-46be-9e03-d2c11af73bc2", + "name": "Confirmacion cancelar reporte", + "credentials": { + "httpBearerAuth": { + "id": "jC5wM1RXfA8Th6mo", + "name": "Eidan Liquidaciones WSP - Bearer Auth account" + } + } + }, + { + "parameters": { + "operation": "get", + "tableId": "empleados_glm", + "filters": { + "conditions": [ + { + "keyName": "country", + "keyValue": "=Trinidad and Tobago" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -3952, + -128 + ], + "id": "08945d44-2fdc-48dc-9734-eb1b0685e9c9", + "name": "Obtener empleado1", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "content": "## Obtener pais para cambiar lenguaje del bot", + "width": 304 + }, + "type": "n8n-nodes-base.stickyNote", + "position": [ + -4016, + -240 + ], + "typeVersion": 1, + "id": "5ed487fb-6af0-47c1-b06f-260d5cd33e38", + "name": "Sticky Note8" + }, + { + "parameters": { + "operation": "getAll", + "tableId": "empleados_glm", + "returnAll": true, + "filters": { + "conditions": [ + { + "keyName": "mobile_phone", + "condition": "fullText", + "searchFunction": "wfts", + "keyValue": "={{ $json.phone }}" + }, + { + "keyName": "work_phone", + "condition": "fullText", + "searchFunction": "wfts", + "keyValue": "={{ $json.phone }}" + } + ] + } + }, + "type": "n8n-nodes-base.supabase", + "typeVersion": 1, + "position": [ + -3680, + -464 + ], + "id": "b139b393-38ca-40c5-89a2-add7f5fca78d", + "name": "Obtener empleado", + "credentials": { + "supabaseApi": { + "id": "2PlsR6rpK7rQTIEn", + "name": "Sofia test - Supabase account" + } + } + }, + { + "parameters": { + "method": "POST", + "url": "https://graph.facebook.com/v23.0/1204134409445693/messages", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "Bearer EABBfEGaZA0ZBcBR5fjtqcJLtXswCaqNMoGP77Qgl1FyPUOoe2CELlNWe2Tl98DxuPIhAOc4xuutsJ7DFOUNt2cvnDF8sQpfzZCgHpC7HHR9KDEVYEZASkv3nl3sScmHmqtAwNzmVyhk0JqVLuZBTLKLEHm1ptlajX3bCYW2mh52hEoiVFeK33Hi3YZCXrGFTAPCAZDZD" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"to\": \"{{ $('Eliminar extension del numero').item.json.phone }}\",\n \"type\": \"interactive\",\n \"interactive\": {\n \"type\": \"list\",\n \"header\": {\n \"type\": \"text\",\n \"text\": \"¡Ha sido registrado correctamente! 🎉\"\n },\n \"body\": {\n \"text\": \"Elige una opción de la lista.\"\n },\n \"action\": {\n \"button\": \"Ver opciones\",\n \"sections\": [\n {\n \"title\": \"Acciones\",\n \"rows\": [\n { \"id\": \"ayuda\", \"title\": \"Ayuda\" },\n { \"id\": \"abrir_reporte\", \"title\": \"Abrir reporte\" },\n { \"id\": \"estado\", \"title\": \"Estado\" },\n { \"id\": \"cerrar\", \"title\": \"Cerrar\" },\n { \"id\": \"cancelar\", \"title\": \"Cancelar\" }\n ]\n }\n ]\n }\n}\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -2400, + -384 + ], + "id": "ae4bd083-632f-440c-af59-64a8909d5183", + "name": "Enviar comandos1" + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=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)", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 1072, + -176 + ], + "id": "96a2c688-baa2-426b-ab87-cec321b7f7be", + "name": "Pedir info reembolso", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=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)", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 1072, + -384 + ], + "id": "cc569edf-6c62-4ca4-91bd-0fb89f3b3d96", + "name": "Pedir info anticipo", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=📋 *{{ $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, usa el comando cerrar para enviar al jefe.", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 1280, + 1600 + ], + "id": "71f68ca1-3a7d-448f-bfb9-78e164995e26", + "name": "Reporte abierto1", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "={{ $('Awaiting3').item.json.texto }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 1472, + 1792 + ], + "id": "8a8ba987-11c8-4e19-ae62-5c572786ae3f", + "name": "Enviar alerta falta info1", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=📋 *{{ $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, usa el comando cerrar para enviar al jefe.", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2688, + 80 + ], + "id": "f6f78a4f-ab5e-4731-84e8-6aee6bff263d", + "name": "Reporte abierto", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=📋 *{{ $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, usa el comando cerrar para enviar al jefe.", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2704, + 640 + ], + "id": "69036749-f4c4-47aa-bd7e-c17123440b60", + "name": "Reporte abierto4", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "={{ $('Awaiting2').item.json.texto }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2688, + 320 + ], + "id": "dabe4122-0a69-47f6-966e-eed4cbdc2cd1", + "name": "Enviar alerta falta info", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "={{ $('Awaiting5').item.json.texto }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2704, + 880 + ], + "id": "ef6f27ef-c6c2-4840-a5cb-eb4bc2ac3da1", + "name": "Enviar alerta falta info3", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=📸 *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?", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2944, + 2448 + ], + "id": "45d40589-d4e9-4c82-8b6c-75eec2aae521", + "name": "Confirmacion factura recibida", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "=⚠️ 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", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2224, + 2624 + ], + "id": "25c21c2e-8818-4cc7-81fe-ab7c03d0b173", + "name": "Alerta factura fuera de periodo", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "={{ $('Awaiting').item.json.texto }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 2416, + 2960 + ], + "id": "edcdbb93-ac62-4f22-8a66-3dd4a3522eba", + "name": "Alerta factura no es valida", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + }, + { + "parameters": { + "operation": "send", + "phoneNumberId": "1204134409445693", + "recipientPhoneNumber": "={{ $('Eliminar extension del numero').item.json.phone }}", + "textBody": "={{ $('Awaiting').item.json.texto }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.whatsApp", + "typeVersion": 1.1, + "position": [ + 1920, + 3504 + ], + "id": "3d483b93-4a34-442b-8393-fd595df83170", + "name": "Alerta factura no es valida1", + "webhookId": "86e97579-6297-423a-87b1-e642cd3c6319", + "credentials": { + "whatsAppApi": { + "id": "5v9NbbS4YvCfoO2C", + "name": "Eidan - WhatsApp account" + } + } + } + ], + "connections": { + "Upload file": { + "main": [ + [ + { + "node": "Detalles de factura", + "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 PRUEBA", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert to File1": { + "main": [ + [ + { + "node": "Upload file", + "type": "main", + "index": 0 + } + ] + ] + }, + "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": [ + [] + ] + }, + "Obtener status": { + "main": [ + [ + { + "node": "Mensaje o comando", + "type": "main", + "index": 0 + } + ] + ] + }, + "Switch": { + "main": [ + [ + { + "node": "Confirmar crear reporte SI/NO", + "type": "main", + "index": 0 + } + ], + [], + [ + { + "node": "Tipo de reporte", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Audio o texto", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Audio o texto3", + "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 + } + ], + [], + [] + ] + }, + "Eliminar extension del numero": { + "main": [ + [ + { + "node": "Obtener empleado", + "type": "main", + "index": 0 + } + ] + ] + }, + "El empleado esta activo?": { + "main": [ + [ + { + "node": "Obtener telefono", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Alerta empleado no activo", + "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": [ + [] + ] + }, + "Obtener reporte": { + "main": [ + [ + { + "node": "Empleado tiene reporte abierto?", + "type": "main", + "index": 0 + } + ] + ] + }, + "Empleado tiene reporte abierto?": { + "main": [ + [], + [ + { + "node": "Mensaje confirmacion crear reporte", + "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": "Registrar telefono", + "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 + } + ] + ] + }, + "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 de reporte", + "type": "main", + "index": 0 + } + ] + ] + }, + "Insertar anticipo al sheet": { + "main": [ + [ + { + "node": "Actualizar status a awaiting_answerAnticipo", + "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_answerReembolso", + "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 + } + ] + ] + }, + "Convert to File2": { + "main": [ + [ + { + "node": "Analyze audio", + "type": "main", + "index": 0 + } + ] + ] + }, + "Analyze audio": { + "main": [ + [ + { + "node": "Message a model", + "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": [ + [], + [], + [], + [], + [], + [], + [] + ] + }, + "Actualizar status a report_open2": { + "main": [ + [ + { + "node": "Reporte abierto1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Obtener info reporte": { + "main": [ + [] + ] + }, + "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 + } + ] + ] + }, + "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 + } + ] + ] + }, + "Analyze an image1 PRUEBA": { + "main": [ + [ + { + "node": "Edit Fields", + "type": "main", + "index": 0 + } + ] + ] + }, + "Actualizar status a awaiting_answerAnticipo": { + "main": [ + [ + { + "node": "Pedir info anticipo", + "type": "main", + "index": 0 + } + ] + ] + }, + "Actualizar status a awaiting_answerReembolso": { + "main": [ + [ + { + "node": "Pedir info reembolso", + "type": "main", + "index": 0 + } + ] + ] + }, + "Analyze audio3": { + "main": [ + [ + { + "node": "Message a model6", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert to File6": { + "main": [ + [ + { + "node": "Analyze audio3", + "type": "main", + "index": 0 + } + ] + ] + }, + "Audio o texto3": { + "main": [ + [ + { + "node": "Descargar audio3", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Message a model7", + "type": "main", + "index": 0 + } + ] + ] + }, + "Message a model6": { + "main": [ + [ + { + "node": "Edit Fields12", + "type": "main", + "index": 0 + } + ] + ] + }, + "Edit Fields12": { + "main": [ + [ + { + "node": "Detectar info faltante para contexto7", + "type": "main", + "index": 0 + } + ] + ] + }, + "Message a model7": { + "main": [ + [ + { + "node": "Edit Fields12", + "type": "main", + "index": 0 + } + ] + ] + }, + "Detectar info faltante para contexto7": { + "main": [ + [ + { + "node": "Campo faltante?3", + "type": "main", + "index": 0 + } + ] + ] + }, + "Awaiting5": { + "main": [ + [ + { + "node": "Actualizar status a awaiting3", + "type": "main", + "index": 0 + } + ] + ] + }, + "Actualizar status a awaiting3": { + "main": [ + [ + { + "node": "Enviar alerta falta info3", + "type": "main", + "index": 0 + } + ] + ] + }, + "Insertar contexto en la bd1": { + "main": [ + [ + { + "node": "Insertar contexto al sheet1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Guardar valores faltantes de contexto1": { + "main": [ + [ + { + "node": "Awaiting5", + "type": "main", + "index": 0 + } + ] + ] + }, + "Descargar audio3": { + "main": [ + [ + { + "node": "Convert to File6", + "type": "main", + "index": 0 + } + ] + ] + }, + "Insertar contexto al sheet1": { + "main": [ + [ + { + "node": "Actualizar status a report_open4", + "type": "main", + "index": 0 + } + ] + ] + }, + "Campo faltante?3": { + "main": [ + [ + { + "node": "Insertar contexto en la bd1", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Guardar valores faltantes de contexto1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Actualizar status a report_open4": { + "main": [ + [ + { + "node": "Reporte abierto4", + "type": "main", + "index": 0 + } + ] + ] + }, + "WhatsApp Trigger": { + "main": [ + [ + { + "node": "Limpiador", + "type": "main", + "index": 0 + } + ] + ] + }, + "Limpiador": { + "main": [ + [ + { + "node": "Eliminar extension del numero", + "type": "main", + "index": 0 + } + ] + ] + }, + "Registrar telefono": { + "main": [ + [ + { + "node": "Enviar comandos1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Obtener telefono": { + "main": [ + [ + { + "node": "Telefono registrado BD?", + "type": "main", + "index": 0 + } + ] + ] + }, + "Send message and wait for response": { + "main": [ + [] + ] + }, + "Mensaje confirmacion crear reporte": { + "main": [ + [ + { + "node": "Actualizar status a awaiting_open_report_confirm", + "type": "main", + "index": 0 + } + ] + ] + }, + "Mensaje o comando": { + "main": [ + [ + { + "node": "Enviar comandos", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Switch2", + "type": "main", + "index": 0 + } + ] + ] + }, + "Switch2": { + "main": [ + [ + { + "node": "Obtener reporte", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Obtener reporte2", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Actualizar status a idle", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Obtener reporte1", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Confirmacion cancelar reporte", + "type": "main", + "index": 0 + } + ], + [], + [], + [ + { + "node": "Tipo de reporte", + "type": "main", + "index": 0 + } + ], + [], + [], + [], + [] + ] + }, + "Obtener reporte1": { + "main": [ + [ + { + "node": "Tiene reporte abierto?", + "type": "main", + "index": 0 + } + ] + ] + }, + "Obtener reporte2": { + "main": [ + [ + { + "node": "Tiene reporte abierto?1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Tiene reporte abierto?1": { + "main": [ + [ + { + "node": "Avisar tiene reporte", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Crear reporte del id", + "type": "main", + "index": 0 + } + ] + ] + }, + "Pedir tipo de reporte": { + "main": [ + [ + { + "node": "Obtener mes y año para el sheet", + "type": "main", + "index": 0 + } + ] + ] + }, + "Obtener empleado": { + "main": [ + [ + { + "node": "Numero esta registrado en GLM?", + "type": "main", + "index": 0 + } + ] + ] + }, + "Pedir info reembolso": { + "main": [ + [ + { + "node": "Insertar reembolso en la bd", + "type": "main", + "index": 0 + } + ] + ] + }, + "Pedir info anticipo": { + "main": [ + [ + { + "node": "Insertar anticipo en la bd", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "authors": "Eidan Then", + "name": "Version e2b74b23", + "description": "", + "autosaved": true, + "workflowPublishHistory": [ + { + "createdAt": "2026-07-29T13:23:14.185Z", + "id": 3608, + "workflowId": "eM8ZZafSC9M8GYd4", + "versionId": "e2b74b23-6ad1-495a-a6dc-f185e94dd7b4", + "event": "activated", + "userId": "de14e7e5-491b-4983-abb2-f88af42e92fd" + } + ] + } } } \ No newline at end of file