{
  "name": "Chatbot Evolution e Instagram",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
      "typeVersion": 1,
      "position": [
        -1580,
        360
      ],
      "id": "e261690e-6562-4c6c-aa9b-aaf9c70932e2",
      "name": "Auto-fixing Output Parser"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"response\": {\n    \"part_1\": \"Responde con la primera parte de la respuesta.\",\n    \"part_2\": \"Responde con la segunda parte de la respuesta.\",\n    \"part_3\": \"Responde con la tercera parte de la respuesta (opcional).\",\n    \"part_4\": \"Responde con la cuarta parte de la respuesta (opcional).\",\n    \"part_5\": \"Responde con la quinta parte de la respuesta (opcional).\"\n  }\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        -1420,
        560
      ],
      "id": "6fd67007-6612-4f37-b180-52e5969fef8e",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Respuesta a formatear:\n{{ $json.mensaje }}",
        "hasOutputParser": true,
        "messages": {
          "messageValues": [
            {
              "message": "=# Tarea  \nTu función principal consiste en crear un JSON que contenga las diferentes partes importantes  del mensaje que vayas a recibir   \nNotas :  \n## debes seguir la siguiente estructura de JSON:  \n{\n  \"response\": {\n    \"part_1\": \"Responde con la primera parte de la respuesta.\",\n    \"part_2\": \"Responde con la segunda parte de la respuesta.\",\n    \"part_3\": \"Responde con la tercera parte de la respuesta (opcional).\",\n    \"part_4\": \"Responde con la cuarta parte de la respuesta (opcional).\",\n    \"part_5\": \"Responde con la quinta parte de la respuesta (opcional).\"\n  }\n}\n## debes dividir los mensajes de una manera que suene bien,  me explico debes analizar que tan largo es el mensaje que recibes y en base en eso dividir el mensaje en las partes que sean necesarias, por ejemplo si el mensaje es breve divídelo en 1 o 2 partes y si el mensaje es extenso divídelo en 3 o 4 partes   \n## las partes que dividas deben tener sentido, no dividas las partes por hacerlo, piensa 2 veces antes de hacerlo"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.5,
      "position": [
        -1680,
        140
      ],
      "id": "21a2da68-0d33-4b5a-95d2-801846f4a3f9",
      "name": "Format Chain",
      "retryOnFail": true,
      "maxTries": 5,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "8d46d583-b82d-4d85-a0b8-2c30006082a0",
              "leftValue": "={{ $('Format Chain').item.json.output.response.part_2 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -760,
        340
      ],
      "id": "492c71cd-2819-4c89-80d4-7ce53a3cdf5d",
      "name": "If"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "3c7eb0e9-13ee-40d6-9738-057a02ac1306",
              "leftValue": "={{ $('Format Chain').item.json.output.response.part_3 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -80,
        340
      ],
      "id": "f29957c2-4682-4309-b4ea-0f1f4242b7a5",
      "name": "If1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "10bc21c7-e460-458f-b0cb-d9e37e9bde8a",
              "leftValue": "={{ $('Format Chain').item.json.output.response.part_4 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        580,
        340
      ],
      "id": "01004ea5-fbbd-45a3-b8e2-b7444387d4ac",
      "name": "If2"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "3c7eb0e9-13ee-40d6-9738-057a02ac1306",
              "leftValue": "= {{ $('Format Chain').item.json.output.response.part_5 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            },
            {
              "id": "3bbae988-08d6-4635-b579-fc947cd8e502",
              "leftValue": "={{ $('Format Chain').item.json.output.response.part_5 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1220,
        340
      ],
      "id": "7bf78408-c319-4f7f-b47c-4432adbdd25d",
      "name": "If3"
    },
    {
      "parameters": {
        "operation": "get",
        "propertyName": "message",
        "key": "={{ $('Edit Fields').item.json.Whatsapp_number }}",
        "options": {}
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -4620,
        260
      ],
      "id": "82de33d2-9853-470b-92a0-a8da54d97604",
      "name": "Redis6",
      "credentials": {
        "redis": {
          "id": "rpGirTVg49kQ1uoJ",
          "name": "Redis account"
        }
      }
    },
    {
      "parameters": {
        "operation": "push",
        "list": "={{ $json.Whatsapp_number }}",
        "messageData": "={{ $json.mensaje }}"
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -5060,
        260
      ],
      "id": "04ab1784-8f0b-43b2-89c1-0728365dc8e9",
      "name": "Redis7",
      "credentials": {
        "redis": {
          "id": "rpGirTVg49kQ1uoJ",
          "name": "Redis account"
        }
      }
    },
    {
      "parameters": {
        "amount": 20
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -4840,
        260
      ],
      "id": "2549edad-0d5c-4d55-85e8-73cd2a8f2b3d",
      "name": "Wait6",
      "webhookId": "a8d5702b-2fe2-4f23-bad7-8bf42fe80ee8"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "8a313a41-eadc-4ada-bc2a-feff79845de9",
              "leftValue": "={{ $json.message[0] }}",
              "rightValue": "={{ $('Edit Fields').item.json.mensaje }}",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -4400,
        260
      ],
      "id": "6847610b-5469-4500-ab7d-f08414e4e08f",
      "name": "If6"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d5f82380-4858-4361-908e-98e45c98f092",
              "name": "response",
              "value": "={{ $('Redis6').item.json.message.slice().reverse() }}",
              "type": "string"
            },
            {
              "id": "b3db797c-6f2b-4232-8e0c-021bc8e299ca",
              "name": "phone",
              "value": "={{ $('Edit Fields').item.json.Whatsapp_number }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -4180,
        160
      ],
      "id": "c2d50aa7-fe9e-49be-859c-a3485da816c6",
      "name": "Edit Fields2"
    },
    {
      "parameters": {
        "operation": "delete",
        "key": "={{ $('Edit Fields').item.json.Whatsapp_number }}"
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -3960,
        360
      ],
      "id": "34315a17-b430-4ae4-ace5-6e96644910e9",
      "name": "Redis9",
      "credentials": {
        "redis": {
          "id": "rpGirTVg49kQ1uoJ",
          "name": "Redis account"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -1700,
        360
      ],
      "id": "338d1b03-aad3-473d-bf4a-331da8d0bf60",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -1540,
        560
      ],
      "id": "341bdbc5-2f04-40ba-80a9-f058ff2f8097",
      "name": "OpenAI Chat Model2",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Edit Fields2').item.json.phone }}",
        "tableName": "=public.n8n_chat_historial_bot",
        "contextWindowLength": 20
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        -2880,
        340
      ],
      "id": "94cc37e1-06d3-489b-8c3e-29f5ca00c9c2",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "id": "EtwXhnSPkcUg9ZFC",
          "name": "Postgres Supabase"
        }
      }
    },
    {
      "parameters": {
        "content": "## Enviamos varios mensajes de un respuesta",
        "height": 680,
        "width": 3680,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2020,
        0
      ],
      "typeVersion": 1,
      "id": "836a1538-cd95-4768-b895-4b88ec429011",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Recopilamos mensajes en (x) intervalo de tiempo",
        "height": 680,
        "width": 1740,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -5440,
        0
      ],
      "typeVersion": 1,
      "id": "12192e8b-f263-45ad-a180-94a9c5426715",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## ¿Audio, texto o imagen?",
        "height": 1080,
        "width": 1860,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -7330,
        -220
      ],
      "typeVersion": 1,
      "id": "20163740-b8aa-430f-8296-675c1113d04b",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=contexto: {{ $json.mensaje_usuario }}\nmensaje_del_cliente: {{ $('Merge').item.json.response }}\ntelefono_del_cliente: {{ $('Edit Fields2').item.json.phone }}\ndia actual: {{ $now }}\ndia de la semana: {{ $now.format('cccc') }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=## 🧠 Prompt para Agente de n8n: Comunidad IA Masters Automations + SolutechIA (con Supabase)\n\n---\n\n### 1. Tu Rol y Contexto\n\n**Rol:** Eres un Agente de Atención de la comunidad IA Masters Automations y embajador informativo de SolutechIA.  \n**Contexto:** Ayudarás a los usuarios que escriben por WhatsApp o mensajes directos, brindándoles información clara, precisa y motivadora sobre la comunidad y los servicios de SolutechIA.\n\nTu objetivo principal es:\n\n- Si tienen dudas sobre **la comunidad IA Masters Automations**, responder con claridad y entusiasmo, explicar beneficios, resolver dudas y **ofrecer siempre la prueba gratuita de 7 días** como la mejor forma de comenzar.  \n  ➕ *No hay permanencia, pueden irse cuando quieran. Si no les gusta, no tienen que pagar nada.*\n\n- Si preguntan sobre **servicios de automatización o desarrollos personalizados**, redirígelos a la web de SolutechIA para que dejen sus datos y agenden una reunión con nosotros.  \n  ➕ *Este CRM (Wixyn, potenciado con GoHighLevel) es ideal para empresas que quieren escalar y automatizar sus procesos.*\n\nTambién tienes acceso a una **base de datos vectorizada en Supabase** que contiene toda la información de la comunidad y SolutechIA. Debes consultarla antes de responder para asegurar la máxima precisión.\n\n---\n\n## 🌐 Páginas importantes\n\n- 📋 Solicitar presupuesto (automatizaciones para empresas): https://solutech.iamastersacademy.com/formulario  \n- 🧠 Web de SolutechIA: https://solutechia.es/  \n- 📦 CRM afiliados Wixyn: https://solutechia.es/crm  \n- 🧑‍🎓 Comunidad Skool IA Masters Automations: https://www.skool.com/ia-masters-automations/about\n\n---\n\n### 2. Responsabilidades y Tareas Clave\n\n- ✅ Consultar siempre la base de datos vectorizada en Supabase antes de responder.\n- ✅ Responder preguntas sobre la comunidad: niveles, beneficios, clases, cursos, automatizaciones, herramientas y funcionamiento general.\n- ✅ Redirigir correctamente:\n  - 👉 A SolutechIA si quieren automatizar su empresa.\n  - 👉 A Skool si quieren unirse a la comunidad (recuerda: 7 días gratis, sin permanencia).\n- ✅ Aclarar que usamos las 3 herramientas líderes en el mercado No-Code: **Make**, **N8N** y **GoHighLevel**.\n- ✅ Mencionar que damos **clases en directo** mostrando casos reales de empresas con automatizaciones internas.\n- ✅ Informar que existe una **bolsa de trabajo interna**, tanto para ofrecer como para solicitar automatizaciones.\n\n---\n\n### 3. Expectativa de Entrada\n\nEjemplos de preguntas que recibirás:\n\n- “¿Qué es SolutechIA?”\n- “¿Cómo accedo a la comunidad?”\n- “¿Tenéis clases sobre N8N?”\n- “¿Qué CRM usáis?”\n- “¿Esto es un bot?”\n\n---\n\n### 4. Herramientas Disponibles\n\n- ✅ Base de datos vectorizada en Supabase con embeddings de clases, documentos y respuestas.\n- ❌ No usas herramientas externas ni consultas sitios web públicos directamente.\n\n---\n\n### 5. Estilo y Tono de Conversación\n\n- Usa un tono **entusiasta, motivador, informal y cercano**.\n- Responde con claridad y energía, como si fueras parte del equipo humano.\n- Usa frases naturales y alegres, ejemplo:\n  > Súper buena pregunta! 😄 Mira, te explico cómo funciona 👇\n\n- Si preguntan si eres un bot, responde con humor, por ejemplo:\n  > Obvio que soy un bot! 😅 Automatizar es lo nuestro, no íbamos a escribir todo esto a mano... Pero que sepas que revisamos estas conversaciones con humanos para mejorar y asegurar que todo va bien.  \n  > De hecho, si quieres aprender a crear este bot, lo enseñamos dentro de la comunidad! 🤖✨\n\n---\n\n### 6. Formato y Salida Esperada\n\n- ✅ Optimiza para WhatsApp y mensajes directos.\n- ✅ Usa **mínimo 6 emojis** por mensaje (cuando aplique).\n- ✅ Incluye enlaces clicables cuando sea necesario.\n- ✅ Usa estructura tipo conversación, breve y clara.\n- ✅ No cierres con preguntas innecesarias.  \n  ➤ El objetivo no es alargar la charla, sino **resolver y redirigir**.\n\n---\n\n### 7. Consulta de Datos\n\n> 🔎 Antes de generar la respuesta, busca en la base de datos vectorizada de Supabase el fragmento más relevante.  \n> Responde en base a ese contenido. Si no encuentras nada útil, responde con la información general que contiene este prompt.\n\n---\n\n### 8. Instrucciones de Calidad y Validación\n\nCada respuesta debe:\n\n- ✅ Resolver la intención con precisión y empatía.\n- ✅ Incluir mínimo 6 emojis.\n- ✅ Contener enlaces relevantes (si aplica).\n- ✅ Ser clara, estructurada y cercana.\n- ✅ Redirigir correctamente según el caso.\n- ❌ No incluir precios ni condiciones económicas.\n- ❌ No forzar el cierre con preguntas de interacción.\n- ❌ No repetir información innecesaria.\n\n---\n\n### ❌ Prohibiciones\n\n- ❌ No improvises respuestas si no tienes datos.\n- ❌ No menciones precios, tarifas, ni promociones específicas.\n- ❌ No descripciones incompletas sobre niveles o servicios.\n\n\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        -2860,
        120
      ],
      "id": "4995c78e-cb3f-4067-a9db-21dfeb7339cc",
      "name": "AI Agent",
      "alwaysOutputData": true,
      "retryOnFail": true
    },
    {
      "parameters": {
        "content": "## 🧙‍♂️ El agente IA hace su magia",
        "height": 680,
        "width": 1540,
        "color": 2
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3640,
        0
      ],
      "typeVersion": 1,
      "id": "f0929e13-7152-4037-a20d-7cc94728d752",
      "name": "Sticky Note4"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -4180,
        360
      ],
      "id": "27163a5d-8e6a-442a-8462-53396e105417",
      "name": "No Operation, do nothing1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "7fe51594-8d61-45b4-a123-ed0c66d6f5c5",
              "name": "mensaje",
              "value": "={{ $json.message_content }}",
              "type": "string"
            },
            {
              "id": "3e61bb2b-a508-48c2-b55c-5d4f9a404cfb",
              "name": "Whatsapp_number",
              "value": "={{ $json.Whatsapp_number }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -5280,
        260
      ],
      "id": "71025dd9-0acb-4c90-b958-ad80e3d691e3",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"mensaje_respuesta\": { \"type\": \"string\" }\n  },\n  \"required\": [\"mensaje_respuesta\"]\n}\n"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        -2360,
        340
      ],
      "id": "d8a2c2e5-e830-42ae-8a6f-121861b8e720",
      "name": "Structured Output Parser1"
    },
    {
      "parameters": {
        "jsCode": "const minutes = $json.minutes_since_last_message;\nlet mensaje = '';\n\nif (minutes > 60) {\n  mensaje = `Hace ${Math.floor(minutes / 60)} horas que el usuario no escribía.`;\n} else if (minutes > 5) {\n  mensaje = `El usuario vuelve luego de ${minutes} minutos.`;\n} else {\n  mensaje = `El usuario continúa la conversación activa.`;\n}\n\nreturn [\n  {\n    json: {\n      mensaje_usuario: mensaje\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -3220,
        120
      ],
      "id": "69321954-cc6a-4d36-95e4-e306b6cfdf1a",
      "name": "Code"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "0c562218-3c6e-4775-b07d-18de456a5c19",
              "leftValue": "={{ $json.Conversacion }}",
              "rightValue": "",
              "operator": {
                "type": "dateTime",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -3440,
        120
      ],
      "id": "e82ed9c7-2586-4e88-a21a-35c732c5bc26",
      "name": "If9"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        -3660,
        120
      ],
      "id": "d2760e7d-b1f5-4d1a-8c36-2c632117cadd",
      "name": "Merge"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "764724e1-bf14-459b-bb97-70b999718c99",
              "name": "mensaje_usuario",
              "value": "Nueva conversación",
              "type": "string"
            },
            {
              "id": "5dc57e7c-35f5-4a74-b3ce-05c3b4a33854",
              "name": "ID",
              "value": "={{ $json.phone }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3220,
        320
      ],
      "id": "7152d471-10fa-4986-82f5-f34bcf51bd2a",
      "name": "Edit Fields3"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "gpt-4.1"
        },
        "options": {
          "temperature": 0.4
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -3000,
        340
      ],
      "id": "d3be2c1f-1b76-478f-a4c8-99de2a7bbaf7",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {
        "description": "=## 🧠 Prompt para el nodo Think (modo validador)\n\nTu función es actuar como una capa de pensamiento lógico y crítica antes de enviar la respuesta del agente. Siempre debes tomarte tu tiempo para razonar.\n\n- ❌ Nunca se puede inventar un precio.\n- ❌ No se puede suponer que un producto o servicio\n- ❌ No se puede decir \"te hago descuento\", \"te dejo en tanto\".\n\n---\n\n### ✅ Validar que:\n\n- La respuesta conteste con claridad, calidez y precisión a la intención del cliente.\n- Tenga mínimo **6 emojis bien distribuidos** (saludo, desarrollo, cierre).\n- No repita datos innecesarios.\n- Sea coherente con lo que el cliente pidió.\n- Mantenga el tono afectuoso y profesional característico del agente.\n\n---\n\n### 📤 Formato de salida (obligatorio):\n\nDevuelve siempre un JSON con esta estructura y nada más:\n\n{\n  \"valido\": true,\n  \"comentario\": \"Explicación breve del por qué es válido o qué debe corregirse.\"\n}\n\n📌 Si detectas cualquier error (tono, contenido, coherencia, emojis insuficientes, promesas indebidas, ingredientes no confirmados), devuelve `\"valido\": false` y explica por qué brevemente.\n\n🚫 No devuelvas el mensaje validado. No repitas el contenido. Solo responde con el JSON indicado.\n"
      },
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "typeVersion": 1,
      "position": [
        -2760,
        340
      ],
      "id": "5a2b4a00-0c47-4955-a76a-4f02f13e31e7",
      "name": "Think1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ee4fc3a6-bb0f-4e90-902f-7ffee4447e3c",
              "name": "mensaje",
              "value": "={{ $('AI Agent').item.json.output.mensaje_respuesta }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1920,
        140
      ],
      "id": "e9b60a52-82b2-4d18-924e-a621cb9285e1",
      "name": "Edit Fields10"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "747854b9-edf9-444a-9ef2-0ecab0d25b80",
              "leftValue": "={{ Object.keys($json.output).length > 0 }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -2260,
        120
      ],
      "id": "110661be-15c6-4e04-b5fc-53c0e9115517",
      "name": "If18"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "chatbot-evolution",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -7220,
        400
      ],
      "id": "f9ec24ca-26d6-40d9-a73f-7149d3e88332",
      "name": "Webhook",
      "webhookId": "f66502d1-43f5-4649-8d70-d1dffbf4c6d3"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "imagedata64",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        -6120,
        300
      ],
      "id": "e611db06-3c39-4d8e-8f63-77899612634c",
      "name": "Convert to File"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "audio64",
        "options": {
          "fileName": "=file-{{ $now.format('yyyy-MM-dd:dd_HHMMSS') }}.ogg"
        }
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        -6120,
        100
      ],
      "id": "e6f3014e-c798-4fee-befe-27ed0364b5bc",
      "name": "Convert to File1"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "stickerdata64",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        -6120,
        500
      ],
      "id": "49c64fc9-577e-4f9b-a6af-600704e96446",
      "name": "Convert to File2"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "7600cd39-f566-4fa5-a7e0-b29e05b392bd",
              "leftValue": "={{ $json.body.event }}",
              "rightValue": "messages.upsert",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            },
            {
              "id": "fc25c837-936f-44a3-bfe4-d3dd70eceb2a",
              "leftValue": "={{ $json.body.data.key.fromMe }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -7000,
        400
      ],
      "id": "5b1d5d3f-e366-4927-8ee8-63aef4f2f20b",
      "name": "If19"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b1373777-68c4-4d3e-8eae-c77269e2163d",
              "name": "Whatsapp_number",
              "value": "={{ $json.body.data.key.remoteJid }}",
              "type": "string"
            },
            {
              "id": "b3a441af-a709-4998-98ed-887fa21983cd",
              "name": "Whastapp_name",
              "value": "={{ $json.body.data.pushName }}",
              "type": "string"
            },
            {
              "id": "c5600e5f-cfd4-466c-baf9-dc42ea14edb1",
              "name": "message_id",
              "value": "={{ $json.body.data.key.id }}",
              "type": "string"
            },
            {
              "id": "135da444-8b73-4671-abaf-22e1825ede87",
              "name": "message_type",
              "value": "={{ !!$json.body.data.message.conversation && 'Texto' ||\n   !!$json.body.data.message.audioMessage && 'audio' ||\n   !!$json.body.data.message.imageMessage && 'image' ||\n   !!$json.body.data.message.stickerMessage && 'sticker' }}",
              "type": "string"
            },
            {
              "id": "2797e7c1-0128-4d92-9a62-167b97a8a832",
              "name": "message_receivedDate",
              "value": "={{ DateTime.fromSeconds($json.body.data.messageTimestamp).toISO() }}",
              "type": "string"
            },
            {
              "id": "b10b61c5-c8fa-414a-93fe-c8c0fa35aa7a",
              "name": "apikey",
              "value": "={{ $json.body.apikey }}",
              "type": "string"
            },
            {
              "id": "7a9960cb-1f18-4c42-835d-4be20219affb",
              "name": "instancia",
              "value": "={{ $json.body.instance }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -6780,
        300
      ],
      "id": "530250fe-0a0f-4b90-adfd-3a5c79a962de",
      "name": "Edit Fields13"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message_type }}",
                    "rightValue": "Texto",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Texto"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "077cd860-da61-4973-b37d-2c34d2cf9de9",
                    "leftValue": "={{ $json.message_type }}",
                    "rightValue": "audio",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Audio"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "97b51420-cf22-4718-8256-bd2bd0a3c6e6",
                    "leftValue": "={{ $json.message_type }}",
                    "rightValue": "image",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Image"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "e46a4113-4b7f-4e4c-a44f-0047f86f6f13",
                    "leftValue": "={{ $json.message_type }}",
                    "rightValue": "sticker",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Sticker"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -6560,
        258
      ],
      "id": "cad20a75-a68d-4910-8334-a589e5c5ef54",
      "name": "Switch1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e40758b7-c873-4f70-b434-ba759e533d83",
              "name": "mesagge_content",
              "value": "={{ $('Webhook').item.json.body.data.message.conversation }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -6340,
        -100
      ],
      "id": "ac3e1ab6-b1dd-43e0-808a-fac249d17b8b",
      "name": "Edit Fields14"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0b0e4dd0-d46b-4651-ae91-d13f9e626a5b",
              "name": "Whatsapp_number",
              "value": "={{ $json.Whatsapp_number }}",
              "type": "string"
            },
            {
              "id": "1a27c534-a2c5-400d-88de-d070cd2dd552",
              "name": "Whatsapp_name",
              "value": "={{ $json.Whastapp_name }}",
              "type": "string"
            },
            {
              "id": "910c9e55-ce6b-4af3-b1b4-6768d110765f",
              "name": "message_id",
              "value": "={{ $json.message_id }}",
              "type": "string"
            },
            {
              "id": "099559f5-b30d-44df-a483-c0becb52a129",
              "name": "message_content",
              "value": "={{ $json.mesagge_content }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -5680,
        -100
      ],
      "id": "00fab5b8-011d-4004-8471-519f8758c52a",
      "name": "Edit Fields15"
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -5900,
        100
      ],
      "id": "655a6838-862d-4222-9616-26a8d36966c7",
      "name": "OpenAI3",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "18b52fda-d39d-4a0d-8b4b-dae73d818de1",
              "name": "imagedata64",
              "value": "={{ $('Webhook').item.json.body.data.message.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -6340,
        300
      ],
      "id": "40829556-b289-42f4-8b16-61e9cc0951cd",
      "name": "Edit Fields16"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6c0c61ff-4a2d-436c-ac64-35e63c0a7aa4",
              "name": "audio64",
              "value": "={{ $('Webhook').item.json.body.data.message.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -6340,
        100
      ],
      "id": "b61c161c-c8dc-470f-9b86-fe0688327f16",
      "name": "Edit Fields17"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0b0e4dd0-d46b-4651-ae91-d13f9e626a5b",
              "name": "Whatsapp_number",
              "value": "={{ $('Edit Fields13').item.json.Whatsapp_number }}",
              "type": "string"
            },
            {
              "id": "1a27c534-a2c5-400d-88de-d070cd2dd552",
              "name": "Whatsapp_name",
              "value": "={{ $('Edit Fields13').item.json.Whastapp_name }}",
              "type": "string"
            },
            {
              "id": "910c9e55-ce6b-4af3-b1b4-6768d110765f",
              "name": "message_id",
              "value": "={{ $('Edit Fields13').item.json.message_id }}",
              "type": "string"
            },
            {
              "id": "099559f5-b30d-44df-a483-c0becb52a129",
              "name": "message_content",
              "value": "={{ $json.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -5680,
        100
      ],
      "id": "0c49d15e-5fc3-4ff6-bc8d-02117b6bdd79",
      "name": "Edit Fields18"
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "text": "Eres un asistente virtual, analisa esta imagen. Tu respuesta debe comenzar con: \"Imagen enviada ____\"",
        "inputType": "base64",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -5900,
        300
      ],
      "id": "f567a78c-3bed-4eb6-aaa6-6dea55352577",
      "name": "OpenAI5",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0b0e4dd0-d46b-4651-ae91-d13f9e626a5b",
              "name": "Whatsapp_number",
              "value": "={{ $('Edit Fields13').item.json.Whatsapp_number }}",
              "type": "string"
            },
            {
              "id": "1a27c534-a2c5-400d-88de-d070cd2dd552",
              "name": "Whatsapp_name",
              "value": "={{ $('Edit Fields13').item.json.Whastapp_name }}",
              "type": "string"
            },
            {
              "id": "910c9e55-ce6b-4af3-b1b4-6768d110765f",
              "name": "message_id",
              "value": "={{ $('Edit Fields13').item.json.message_id }}",
              "type": "string"
            },
            {
              "id": "099559f5-b30d-44df-a483-c0becb52a129",
              "name": "message_content",
              "value": "={{ $json.content }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -5680,
        300
      ],
      "id": "27cf21d3-c34e-4454-941f-6b89c4d0e5c4",
      "name": "Edit Fields19"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "18b52fda-d39d-4a0d-8b4b-dae73d818de1",
              "name": "stickerdata64",
              "value": "={{ $('Webhook').item.json.body.data.message.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -6340,
        500
      ],
      "id": "b72c083e-ce8d-4ed6-9812-988b422e45fc",
      "name": "Edit Fields20"
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "text": "Eres un asistente virtual, analisa esta imagen. Tu respuesta debe comenzar con: \"Sticker enviado ____\"",
        "inputType": "base64",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -5900,
        500
      ],
      "id": "eb778350-0baf-44c4-8230-8e366245404b",
      "name": "OpenAI6",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0b0e4dd0-d46b-4651-ae91-d13f9e626a5b",
              "name": "Whatsapp_number",
              "value": "={{ $('Edit Fields13').item.json.Whatsapp_number }}",
              "type": "string"
            },
            {
              "id": "1a27c534-a2c5-400d-88de-d070cd2dd552",
              "name": "Whatsapp_name",
              "value": "={{ $('Edit Fields13').item.json.Whastapp_name }}",
              "type": "string"
            },
            {
              "id": "910c9e55-ce6b-4af3-b1b4-6768d110765f",
              "name": "message_id",
              "value": "={{ $('Edit Fields13').item.json.message_id }}",
              "type": "string"
            },
            {
              "id": "099559f5-b30d-44df-a483-c0becb52a129",
              "name": "message_content",
              "value": "={{ $json.content }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -5680,
        500
      ],
      "id": "0a9ad686-546a-4121-ae60-af488ace5fde",
      "name": "Edit Fields21"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -6780,
        500
      ],
      "id": "dab53a73-d47b-4945-a1b9-0643003f0a1e",
      "name": "No Operation, do nothing5"
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "{{ $json.instancia }}",
        "remoteJid": "={{ $json.Whatsapp_number }}",
        "messageText": "🛑🤖 Lo siento, pero no reconozco este tipo de mensaje. ¿Puedes intentarlo de otra manera? 💬😊",
        "options_message": {
          "delay": 3000
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        -6340,
        700
      ],
      "id": "53f31886-7f2d-4ea1-a2cd-7b1262821be2",
      "name": "Evolution API2",
      "credentials": {
        "evolutionApi": {
          "id": "YKZfBUO2WVeDoamM",
          "name": "Evolution account"
        }
      }
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "={{ $('Webhook').item.json.body.instance }}",
        "remoteJid": "={{ $('Webhook').item.json.body.data.key.remoteJid }}",
        "messageText": "={{ JSON.stringify($('Format Chain').item.json.output.response.part_2).slice(1, -1) }}",
        "options_message": {
          "delay": "={{ $('Format Chain').item.json.output.response.part_2.length * 30 }}",
          "linkPreview": true
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        -540,
        140
      ],
      "id": "c5477580-22d9-498f-92ed-c3eb31e7b5aa",
      "name": "Evolution API1",
      "credentials": {
        "evolutionApi": {
          "id": "YKZfBUO2WVeDoamM",
          "name": "Evolution account"
        }
      }
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "={{ $('Webhook').item.json.body.instance }}",
        "remoteJid": "={{ $('Webhook').item.json.body.data.key.remoteJid }}",
        "messageText": "={{ JSON.stringify($('Format Chain').item.json.output.response.part_3).slice(1, -1) }}",
        "options_message": {
          "delay": "={{ $('Format Chain').item.json.output.response.part_3.length * 30 }}",
          "linkPreview": true
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        120,
        140
      ],
      "id": "15c7bfb4-a98c-4af7-8e36-df61fb1a6ac9",
      "name": "Evolution API3",
      "credentials": {
        "evolutionApi": {
          "id": "YKZfBUO2WVeDoamM",
          "name": "Evolution account"
        }
      }
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "={{ $('Webhook').item.json.body.instance }}",
        "remoteJid": "={{ $('Webhook').item.json.body.data.key.remoteJid }}",
        "messageText": "={{ JSON.stringify($('Format Chain').item.json.output.response.part_4).slice(1, -1) }}",
        "options_message": {
          "delay": "={{ $('Format Chain').item.json.output.response.part_4.length * 30 }}",
          "linkPreview": true
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        780,
        140
      ],
      "id": "17bbb582-1623-4dde-b90b-dafa45ab76ac",
      "name": "Evolution API4",
      "credentials": {
        "evolutionApi": {
          "id": "YKZfBUO2WVeDoamM",
          "name": "Evolution account"
        }
      }
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "={{ $('Webhook').item.json.body.instance }}",
        "remoteJid": "={{ $('Webhook').item.json.body.data.key.remoteJid }}",
        "messageText": "={{ JSON.stringify($('Format Chain').item.json.output.response.part_5).slice(1, -1) }}",
        "options_message": {
          "delay": "={{ $('Format Chain').item.json.output.response.part_5.length * 30 }}",
          "linkPreview": true
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        1440,
        140
      ],
      "id": "e128f77f-1ea3-4515-bfa6-29c216a6360d",
      "name": "Evolution API5",
      "credentials": {
        "evolutionApi": {
          "id": "YKZfBUO2WVeDoamM",
          "name": "Evolution account"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {
          "googleFileConversion": {
            "conversion": {
              "docsToFormat": "application/pdf"
            }
          }
        }
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -6640,
        -700
      ],
      "id": "8b46a342-3ca4-45c6-a1d6-1a50459ef12f",
      "name": "Google Drive",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "yx8PCEmFbAGzomzP",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "operation": "pdf",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        -6420,
        -700
      ],
      "id": "efd366f1-71e4-4fc7-b7b4-615a538ac6af",
      "name": "Extract from File1"
    },
    {
      "parameters": {
        "jsCode": "// ✅ 1) Obtener el texto desde la variable de entrada.\n// Si no existe, usamos un string vacío para evitar errores.\nconst text = $json.text || '';\n\n// ✅ 2) Dividir el texto en frases completas.\n// Usamos una expresión regular que detecta puntos, interrogaciones o exclamaciones seguidos de espacios.\n// Esto nos da una lista de frases del texto.\nconst sentences = text.split(/(?<=[.?!])\\s+/);\n\n// ✅ 3) Preparar las variables\nconst chunks = [];         // Aquí guardaremos los bloques finales\nlet currentChunk = [];     // Este array irá acumulando frases\n\n// ✅ 4) Recorremos cada frase del texto\nfor (let i = 0; i < sentences.length; i++) {\n  currentChunk.push(sentences[i]); // Añadimos la frase actual al bloque\n\n  // Si ya tenemos 3 frases o más de 500 caracteres, guardamos este bloque\n  if (currentChunk.length >= 3 || currentChunk.join(\" \").length > 500) {\n    chunks.push({\n      chunk: currentChunk.join(\" \") // Unimos las frases en un solo texto\n    });\n    currentChunk = []; // Empezamos un nuevo bloque\n  }\n}\n\n// ✅ 5) Si queda algún fragmento pendiente al final, también lo añadimos\nif (currentChunk.length) {\n  chunks.push({\n    chunk: currentChunk.join(\" \")\n  });\n}\n\n// ✅ 6) Devolver los bloques (chunks) en el formato que espera n8n\n// Cada uno debe ir dentro de un objeto { json: ... }\nreturn chunks.map(c => ({ json: c }));\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -6200,
        -700
      ],
      "id": "d758c36d-5af9-4ca3-b68a-5ff9c22fa2cc",
      "name": "Semantic Chunker"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -5880,
        -700
      ],
      "id": "fd7f359b-aa4f-4491-9e64-b0d4c2afca2c",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://aasupabaseaa.vps.rubikmarketing.com.co/rest/v1/documents",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "supabaseApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Prefer",
              "value": "return=representation"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"content\": \"{{ $('Code1').item.json.chunk.replaceAll('\"') }}\",\n  \"metadata\": {\"source\": \"{{ $('Google Drive1').first().json.name }}\",\n\"id_file\": \"{{ $('Google Drive1').first().json.id }}\",\n\"pages\": \"{{ $('Extract from File1').first().json.numpages }}\"},\n  \"embedding\": {{ JSON.stringify($json.data[0].embedding) }}\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -5220,
        -700
      ],
      "id": "dcced372-9b07-4b07-8e11-caaeab3529eb",
      "name": "HTTP Request2",
      "credentials": {
        "supabaseApi": {
          "id": "5GKOb3OoOKDID5ub",
          "name": "Supabase Servidor"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/embeddings",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "input",
              "value": "={{ $json.chunk }}"
            },
            {
              "name": "model",
              "value": "text-embedding-3-small"
            },
            {
              "name": "encoding_format",
              "value": "float"
            },
            {
              "name": "dimensions",
              "value": "={{1536}}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -5440,
        -700
      ],
      "id": "34d07ef2-43d9-4237-bf7f-8d13685700eb",
      "name": "HTTP Request",
      "credentials": {
        "httpHeaderAuth": {
          "id": "OUmTgApnCeXe5Iz1",
          "name": "Apify"
        },
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {
        "content": "## SEMANTICA SIN SECCIONES EN METADATA (VELOCIDAD MEDIA)",
        "height": 480,
        "width": 2300
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -7360,
        -880
      ],
      "id": "78658254-c99e-421f-a747-037ed870e651",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "jsCode": "// ✅ 1) Creamos una función para limpiar el texto de un chunk\n// Esta función se asegura de que el texto esté limpio, legible y sin caracteres raros\nconst cleanText = (text) => {\n  if (typeof text !== 'string') return ''; // Si no es un texto válido, devolvemos una cadena vacía\n\n  return text\n    .replace(/[\\n\\r\\t]+/g, ' ')              // Elimina saltos de línea, retornos de carro y tabulaciones\n    .replace(/[“”«»‘’]/g, '\"')               // Sustituye comillas raras por comillas normales dobles (\")\n    .replace(/[–—]/g, '-')                   // Reemplaza guiones largos o extraños por guiones estándar\n    .replace(/[•·]/g, '-')                   // Reemplaza bullets por guiones\n    .replace(/\\s{2,}/g, ' ')                 // Reduce múltiples espacios a un solo espacio\n    .trim();                                 // Elimina espacios al principio y al final del texto\n};\n\n// ✅ 2) Recorremos cada item del flujo (normalmente cada uno es un fragmento o \"chunk\")\nreturn items.map(item => {\n  // Limpiamos el campo `chunk` usando la función anterior\n  item.json.chunk = cleanText(item.json.chunk);\n\n  // Devolvemos el item modificado\n  return item;\n});\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -5660,
        -700
      ],
      "id": "f737f1f3-fafb-4030-8f0c-2a57d664e490",
      "name": "Code1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -7300,
        -700
      ],
      "id": "b30bbb88-25e8-4dcd-bf61-f3ef37fcd7b6",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "resource": "fileFolder",
        "returnAll": true,
        "filter": {
          "driveId": {
            "mode": "list",
            "value": "My Drive"
          },
          "folderId": {
            "__rl": true,
            "value": "1Jf8FaKdtLLWXrDqzwKThdxYa2i7p66kc",
            "mode": "list",
            "cachedResultName": "RAG COMUNIDAD y EMPRESA",
            "cachedResultUrl": "https://drive.google.com/drive/folders/1Jf8FaKdtLLWXrDqzwKThdxYa2i7p66kc"
          },
          "whatToSearch": "files"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -7080,
        -700
      ],
      "id": "63acf720-1f53-4523-8ad2-cc1cdef0bf05",
      "name": "Google Drive1",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "yx8PCEmFbAGzomzP",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "operation": "move",
        "fileId": {
          "__rl": true,
          "value": "={{ $('Google Drive1').first().json.id }}",
          "mode": "id"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "1UWud5Q7RVhToeJD4uH0XPjkDLNK7de-E",
          "mode": "list",
          "cachedResultName": "Subidos",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1UWud5Q7RVhToeJD4uH0XPjkDLNK7de-E"
        }
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -5680,
        -880
      ],
      "id": "f883c7c1-2cd3-4110-935c-517a0e64b4d3",
      "name": "Google Drive2",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "yx8PCEmFbAGzomzP",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        -6860,
        -700
      ],
      "id": "63631b35-2c2a-4e81-97ee-d61b708503df",
      "name": "Limit"
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "Documents",
        "toolDescription": "Utiliza esta herramienta para obtener información sobre la comunidad y la empresa",
        "tableName": {
          "__rl": true,
          "value": "documents",
          "mode": "list",
          "cachedResultName": "documents"
        },
        "topK": 10,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.2,
      "position": [
        -2640,
        340
      ],
      "id": "4f4055ef-9411-4cd5-8739-6b658ed3c0f5",
      "name": "Supabase Vector Store",
      "credentials": {
        "supabaseApi": {
          "id": "5GKOb3OoOKDID5ub",
          "name": "Supabase Servidor"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        -2560,
        540
      ],
      "id": "d46bf75d-f6ab-49fc-af29-c832a9162c42",
      "name": "Embeddings OpenAI",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -980,
        140
      ],
      "id": "82455038-1c63-4418-a77a-b069f019fab6",
      "name": "Wait",
      "webhookId": "992212ae-d4a9-4049-af10-6c86113b1f56"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -320,
        140
      ],
      "id": "29ef3170-f7b1-46bb-824a-24660ad33b9f",
      "name": "Wait1",
      "webhookId": "ef189584-a9c1-4bca-bb04-496f31402f9c"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        340,
        140
      ],
      "id": "4d71a673-f958-4a88-9a3b-03fc4577723a",
      "name": "Wait2",
      "webhookId": "088389c0-84d8-407e-b5db-a8c887f8d00b"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1000,
        140
      ],
      "id": "721cc649-1063-43c0-9637-fc49d259525e",
      "name": "Wait3",
      "webhookId": "ca523310-0444-4d09-8bc0-b4615b2887f4"
    },
    {
      "parameters": {
        "content": "## Instagram",
        "height": 700,
        "width": 3620,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2020,
        1240
      ],
      "id": "dfefcbd2-1023-41e9-b7a9-d30600eb6951",
      "name": "Sticky Note6"
    },
    {
      "parameters": {
        "multipleMethods": true,
        "httpMethod": [
          "POST",
          "GET"
        ],
        "path": "mensaje-recibido",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -6440,
        1540
      ],
      "id": "c1556dca-0a93-4686-914c-fc20199d1ba4",
      "name": "Disparador Instagram",
      "webhookId": "cc6546da-6f16-4546-ada3-e2c83b208997",
      "disabled": true
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{ $json.query['hub.challenge'] }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        -6180,
        1640
      ],
      "id": "7d8cff71-8fb8-4996-956f-19b4e2428029",
      "name": "Responder webhook – Instagram (GET)"
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "\"EVENT_RECEIVED\"",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        -6180,
        1460
      ],
      "id": "bcfb08a5-246f-41fb-94d8-5aade330135a",
      "name": "Responder webhook – Instagram (POST)"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "26a3553a-f37b-4f46-9a84-3f1661a5d152",
              "name": "trigger",
              "value": "instagram",
              "type": "string"
            },
            {
              "id": "11ae4f49-44ec-4416-a8d2-49a15fdf1e63",
              "name": "texto",
              "value": "={{ $json.body.mensaje }}",
              "type": "string"
            },
            {
              "id": "679e091e-d9dd-4cc3-b5a1-97f3790e09d0",
              "name": "channelId",
              "value": "={{ $json.body.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -5620,
        1440
      ],
      "id": "74961c51-38a0-410f-a44e-a08f70a79a6b",
      "name": "Editar campos – Instagram"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "7dee1826-e2b5-44ea-9c0f-a0adb5bc740c",
              "leftValue": "={{ $json.body.entry[0].messaging[0].message?.is_echo }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -5960,
        1460
      ],
      "id": "f03a52fd-67f7-4bf8-b698-e3cac82f9a5a",
      "name": "Si no es echo – Instagram"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.instagram.com/v23.0/me/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"recipient\":{\n    \"id\":\"{{ $('Edit Fields5').item.json.ID }}\"\n  },\n  \"message\":{\n    \"text\":\"{{ $json.output.response.part_1 }}\"\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1180,
        1380
      ],
      "id": "329640a8-153a-4eed-a1a8-1f495b0930e9",
      "name": "Instagram Graph API",
      "credentials": {
        "httpHeaderAuth": {
          "id": "fJrS7XDHAN3wAhrj",
          "name": "Agente Ventas Instagram"
        }
      }
    },
    {
      "parameters": {
        "content": "## INSTAGRAM",
        "height": 520,
        "width": 1000,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -6480,
        1360
      ],
      "typeVersion": 1,
      "id": "c8a891c1-818a-43bf-995d-dda438b82698",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "operation": "get",
        "propertyName": "message",
        "key": "={{ $json.channelId }}",
        "options": {}
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -4880,
        1460
      ],
      "id": "4c07748e-06d4-408e-a6e2-a280f1afd61c",
      "name": "Redis",
      "credentials": {
        "redis": {
          "id": "rpGirTVg49kQ1uoJ",
          "name": "Redis account"
        }
      }
    },
    {
      "parameters": {
        "operation": "push",
        "list": "={{ $json.channelId }}",
        "messageData": "={{ $json.texto }}"
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -5360,
        1460
      ],
      "id": "ccce3673-eaef-4013-8b24-66172c5fb69f",
      "name": "Redis8",
      "credentials": {
        "redis": {
          "id": "rpGirTVg49kQ1uoJ",
          "name": "Redis account"
        }
      }
    },
    {
      "parameters": {
        "amount": 20
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -5100,
        1460
      ],
      "id": "2b3c1a0b-209a-434b-9da9-4e9fdc57c825",
      "name": "Wait7",
      "webhookId": "a8d5702b-2fe2-4f23-bad7-8bf42fe80ee8"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "8a313a41-eadc-4ada-bc2a-feff79845de9",
              "leftValue": "={{ $json.message[0] }}",
              "rightValue": "={{ $('Editar campos – Instagram').item.json.texto }}",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -4660,
        1460
      ],
      "id": "013f71a6-5ac4-4c14-98cc-5e28a27edee4",
      "name": "If7"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d5f82380-4858-4361-908e-98e45c98f092",
              "name": "response",
              "value": "={{ $('Redis').item.json.message.slice().reverse() }}",
              "type": "string"
            },
            {
              "id": "b3db797c-6f2b-4232-8e0c-021bc8e299ca",
              "name": "ID",
              "value": "={{ $('Wait7').item.json.channelId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -4440,
        1360
      ],
      "id": "1c6c5f9f-d907-4e2f-8100-63fed16c732b",
      "name": "Edit Fields4"
    },
    {
      "parameters": {
        "operation": "delete",
        "key": "={{ $('Wait7').item.json.channelId }}"
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -4220,
        1560
      ],
      "id": "f67d5183-f336-480d-8259-b8d95bb3a1a6",
      "name": "Redis10",
      "credentials": {
        "redis": {
          "id": "rpGirTVg49kQ1uoJ",
          "name": "Redis account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -4440,
        1560
      ],
      "id": "82778725-63cf-4c8a-9379-a54972c39a06",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        -4000,
        1360
      ],
      "id": "6078c5fa-4af0-4f33-8e57-1d64401119df",
      "name": "Merge1"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
      "typeVersion": 1,
      "position": [
        -1640,
        1600
      ],
      "id": "8a724ac8-9b6c-4b6c-b292-9ea59d14465b",
      "name": "Auto-fixing Output Parser1"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"response\": {\n    \"part_1\": \"Responde con la primera parte de la respuesta.\",\n    \"part_2\": \"Responde con la segunda parte de la respuesta.\",\n    \"part_3\": \"Responde con la tercera parte de la respuesta (opcional).\",\n    \"part_4\": \"Responde con la cuarta parte de la respuesta (opcional).\",\n    \"part_5\": \"Responde con la quinta parte de la respuesta (opcional).\"\n  }\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        -1480,
        1800
      ],
      "id": "19a51ce9-a12a-4784-a9ba-2954f921519b",
      "name": "Structured Output Parser2"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Respuesta a formatear:\n{{ $json.mensaje }}",
        "hasOutputParser": true,
        "messages": {
          "messageValues": [
            {
              "message": "=# Tarea  \nTu función principal consiste en crear un JSON que contenga las diferentes partes importantes  del mensaje que vayas a recibir   \nNotas :  \n## debes seguir la siguiente estructura de JSON:  \n{\n  \"response\": {\n    \"part_1\": \"Responde con la primera parte de la respuesta.\",\n    \"part_2\": \"Responde con la segunda parte de la respuesta.\",\n    \"part_3\": \"Responde con la tercera parte de la respuesta (opcional).\",\n    \"part_4\": \"Responde con la cuarta parte de la respuesta (opcional).\",\n    \"part_5\": \"Responde con la quinta parte de la respuesta (opcional).\"\n  }\n}\n## debes dividir los mensajes de una manera que suene bien,  me explico debes analizar que tan largo es el mensaje que recibes y en base en eso dividir el mensaje en las partes que sean necesarias, por ejemplo si el mensaje es breve divídelo en 1 o 2 partes y si el mensaje es extenso divídelo en 3 o 4 partes   \n## las partes que dividas deben tener sentido, no dividas las partes por hacerlo, piensa 2 veces antes de hacerlo"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.5,
      "position": [
        -1740,
        1380
      ],
      "id": "d249a136-9f5a-4042-a75a-cb1d49e5058a",
      "name": "Format Chain1",
      "retryOnFail": true,
      "maxTries": 5,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -1760,
        1600
      ],
      "id": "bf4c700c-289b-4c1a-96af-1edfc57f4bbb",
      "name": "OpenAI Chat Model3",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -1600,
        1800
      ],
      "id": "a03f643a-3845-4ad1-80e2-c24d124e3c7b",
      "name": "OpenAI Chat Model4",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{$('If10').item.json.ID}}",
        "tableName": "=n8n_chat_histories_comercial",
        "contextWindowLength": 20
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        -3060,
        1620
      ],
      "id": "4015d2a9-415b-46d2-abe4-6331c571af63",
      "name": "Postgres Chat Memory1",
      "credentials": {
        "postgres": {
          "id": "EtwXhnSPkcUg9ZFC",
          "name": "Postgres Supabase"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=contexto: {{ $json.mensaje_usuario }}\nmensaje_del_cliente: {{ $('Merge1').item.json.response }}\nID_cliente: {{ $json.ID }}\ndia actual: {{ $now }}\ndia de la semana: {{ $now.format('cccc') }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=## 🧠 Prompt para Agente de n8n: Comunidad IA Masters Automations + SolutechIA (con Supabase)\n\n---\n\n### 1. Tu Rol y Contexto\n\n**Rol:** Eres un Agente de Atención de la comunidad IA Masters Automations y embajador informativo de SolutechIA.  \n**Contexto:** Ayudarás a los usuarios que escriben por WhatsApp o mensajes directos, brindándoles información clara y motivadora sobre la comunidad y los servicios de SolutechIA. El objetivo principal es que si tienen dudas sobre la comunidad les respondas y siempre les invites a probarla ya que tienen 7 dias gratis de prueba. Y si contactan porque necesitan o quieren automatizar su negocio o empresa, es decir contrarar el servicio, el objetivo es que nos dejen la información en la pagina web para agendar una reunion con nosotros.\n\nAdemás, tienes acceso a una **base de datos vectorizada alojada en Supabase**, que contiene toda la información actualizada sobre la comunidad IA Masters Automations y los servicios/productos de SolutechIA. Consulta esta base para responder con precisión cada pregunta.\n\n---\n\n### 2. Responsabilidades y Tareas Clave\n\n- ✅ Consulta la base de datos vectorizada antes de generar una respuesta para asegurar que la información sea precisa y actualizada.\n- Si el usuario pregunta sobre **SolutechIA**, explica qué servicios ofrece, cómo acceder al CRM, solicitar presupuesto o agendar una reunión, y comparte los enlaces necesarios.\n- Si el usuario pregunta sobre la **comunidad IA Masters Automations**, explica los niveles, beneficios, clases, cursos y automatizaciones disponibles. También puedes guiarlo para comenzar, recomendar contenido o resolver dudas comunes sobre el funcionamiento de la comunidad.\n- Si la pregunta no es clara, responde con una actitud amigable y pide más detalles para poder ayudar mejor.\n\n---\n\n### 3. Expectativa de Entrada\n\nRecibirás solicitudes escritas en lenguaje natural, como:\n\n- “¿Qué es SolutechIA?”\n- “¿Cómo puedo acceder al contenido exclusivo de la comunidad?”\n- “¿Qué beneficios tiene el nivel Camaleón Verde?”\n- “¿Tienen clases para aprender N8N?”\n\n---\n\n### 4. Herramientas Disponibles\n\n- ✅ Base de datos vectorizada en Supabase con embeddings de documentos, clases, niveles y recursos.\n- ❌ No usas herramientas externas ni consultas webs públicas directamente.\n\n---\n\n### 5. Estilo y Tono de Conversación\n\nUsa un tono **motivador, entusiasta, informal y cercano**.  \nHaz que el usuario se sienta acompañado por una comunidad proactiva.  \nEjemplo:  \n> ¡Súper buena pregunta! 💡 Te cuento todo lo que necesitas saber sobre ese nivel y cómo empezar 👉 [enlace]\n\n---\n\n### 6. Formato y Salida Esperada\n\n- Optimiza para WhatsApp y DMs.\n- Usa emojis para dar energía y cercanía.\n- Incluye enlaces clicables cuando corresponda.\n- Mantén una estructura conversacional.\n- Si la solicitud es ambigua, pide más detalles antes de recomendar algo específico.\n\n---\n\n### 7. Consulta de Datos\n\nAntes de responder, si es necesario, haz lo siguiente:\n\n> 🔎 **Consulta la base de datos vectorizada de Supabase**. Busca el fragmento de texto más relevante al mensaje del usuario.  \n> Asegúrate de que la respuesta esté basada en los resultados recuperados. Si no hay un match claro, responde con base en los datos integrados de este prompt.\n\n---\n\n### 8. Instrucciones de Calidad y Validación\n\n- La respuesta debe:\n  - ✅ Resolver la intención con precisión y empatía\n  - ✅ Tener mínimo 6 emojis\n  - ✅ Incluir enlaces cuando aplique\n  - ✅ Usar estructura fluida tipo conversación\n  - ✅ Consultar Supabase si es posible\n  - ❌ No repetir información innecesaria\n  - ❌ No dar precios ni condiciones económicas\n\n---\n\n### ❌ Prohibiciones\n\n- ❌ Nunca mencionar precios.\n- ❌ Nunca improvisar si no hay datos.\n- ❌ Nunca asumir qué incluye una suscripción sin confirmación.\n\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        -3080,
        1400
      ],
      "id": "d6cf8393-e2f9-4b6f-98a4-468904993be9",
      "name": "AI Agent1",
      "alwaysOutputData": true,
      "retryOnFail": true
    },
    {
      "parameters": {
        "content": "## 🧙‍♂️ El agente IA hace su magia",
        "height": 680,
        "width": 1540,
        "color": 2
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3640,
        1260
      ],
      "typeVersion": 1,
      "id": "9e8878ac-4426-4b36-aa43-63678f24836e",
      "name": "Sticky Note7"
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"mensaje_respuesta\": { \"type\": \"string\" },\n    \"producto_detectado\": { \"type\": \"string\" },\n    \"agente_destino\": { \"type\": \"string\" },\n    \"cliente_nombre\": { \"type\": \"string\" },\n    \"producto_solicitado\": { \"type\": \"string\" },\n    \"precio_total\": { \"type\": \"string\" },\n    \"direccion_confirmada\": { \"type\": \"string\" },\n    \"ciudad_confirmada\": { \"type\": \"string\" },\n    \"departamento_confirmado\": { \"type\": \"string\" },\n    \"medio_pago_seleccionado\": { \"type\": \"string\" },\n    \"tipo_conversacion\": { \"type\": \"string\" },\n    \"prefiere_voz\": { \"type\": \"string\" },\n    \"url_imagen\": { \"type\": \"string\" },\n    \"imagen\": { \"type\": \"boolean\" },\n    \"cliente_compro_en_esta_conversacion\": { \"type\": \"boolean\" }\n  },\n  \"required\": [\n    \"mensaje_respuesta\",\n    \"producto_detectado\",\n    \"agente_destino\",\n    \"cliente_nombre\",\n    \"producto_solicitado\",\n    \"precio_total\",\n    \"direccion_confirmada\",\n    \"ciudad_confirmada\",\n    \"departamento_confirmado\",\n    \"medio_pago_seleccionado\",\n    \"tipo_conversacion\",\n    \"prefiere_voz\",\n    \"url_imagen\",\n    \"imagen\",\n    \"cliente_compro_en_esta_conversacion\"\n  ]\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        -2420,
        1620
      ],
      "id": "4473c81d-af40-4b3e-a5f0-17f0291f1ce3",
      "name": "Structured Output Parser3"
    },
    {
      "parameters": {
        "jsCode": "const minutes = $json.minutes_since_last_message;\nlet mensaje = '';\n\nif (minutes > 60) {\n  mensaje = `Hace ${Math.floor(minutes / 60)} horas que el usuario no escribía.`;\n} else if (minutes > 5) {\n  mensaje = `El usuario vuelve luego de ${minutes} minutos.`;\n} else {\n  mensaje = `El usuario continúa la conversación activa.`;\n}\n\nreturn [\n  {\n    json: {\n      mensaje_usuario: mensaje\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -3400,
        1400
      ],
      "id": "93716931-811e-4387-abd5-72315cea2af7",
      "name": "Code2"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "0c562218-3c6e-4775-b07d-18de456a5c19",
              "leftValue": "={{!!$json.creado}}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -3620,
        1400
      ],
      "id": "cc33a04d-5940-4bcb-acf3-d3688c4ede7b",
      "name": "If10"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "764724e1-bf14-459b-bb97-70b999718c99",
              "name": "mensaje_usuario",
              "value": "Nueva conversación",
              "type": "string"
            },
            {
              "id": "5dc57e7c-35f5-4a74-b3ce-05c3b4a33854",
              "name": "ID",
              "value": "={{ $('Wait7').item.json.channelId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3400,
        1600
      ],
      "id": "d3129bb4-72ad-48cb-af07-47e7814c128f",
      "name": "Edit Fields5"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "gpt-4.1"
        },
        "options": {
          "temperature": 0.4
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -3180,
        1620
      ],
      "id": "4fba73c0-728e-40fb-8bd0-a27aa7157ea0",
      "name": "OpenAI Chat Model5",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {
        "description": "=## 🧠 Prompt para el nodo Think (modo validador)\n\nTu función es actuar como una capa de pensamiento lógico y crítica antes de enviar la respuesta del agente. Siempre debes tomarte tu tiempo para razonar.\n\n- ❌ Nunca se puede inventar un precio.\n- ❌ No se puede suponer que un producto o servicio\n- ❌ No se puede decir \"te hago descuento\", \"te dejo en tanto\".\n\n---\n\n### ✅ Validar que:\n\n- La respuesta conteste con claridad, calidez y precisión a la intención del cliente.\n- Tenga mínimo **6 emojis bien distribuidos** (saludo, desarrollo, cierre).\n- No repita datos innecesarios.\n- Sea coherente con lo que el cliente pidió.\n- Mantenga el tono afectuoso y profesional característico del agente.\n\n---\n\n### 📤 Formato de salida (obligatorio):\n\nDevuelve siempre un JSON con esta estructura y nada más:\n\n{\n  \"valido\": true,\n  \"comentario\": \"Explicación breve del por qué es válido o qué debe corregirse.\"\n}\n\n📌 Si detectas cualquier error (tono, contenido, coherencia, emojis insuficientes, promesas indebidas, ingredientes no confirmados), devuelve `\"valido\": false` y explica por qué brevemente.\n\n🚫 No devuelvas el mensaje validado. No repitas el contenido. Solo responde con el JSON indicado.\n"
      },
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "typeVersion": 1,
      "position": [
        -2940,
        1620
      ],
      "id": "acd91474-2f36-4bf2-b8cd-5f9a91580e04",
      "name": "Think"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ee4fc3a6-bb0f-4e90-902f-7ffee4447e3c",
              "name": "mensaje",
              "value": "={{ $('AI Agent1').item.json.output.mensaje_respuesta }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2020,
        1380
      ],
      "id": "6bd1ca0f-0de8-4309-ae2a-6bc79f5cb68c",
      "name": "Edit Fields11"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "747854b9-edf9-444a-9ef2-0ecab0d25b80",
              "leftValue": "={{ Object.keys($json.output).length > 0 }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -2620,
        1400
      ],
      "id": "0a9aa83f-a522-499c-96a2-b54898ca3a8d",
      "name": "If20"
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "Documents",
        "toolDescription": "Utiliza esta herramienta para obtener información sobre la comunidad y la empresa",
        "tableName": {
          "__rl": true,
          "value": "documents",
          "mode": "list",
          "cachedResultName": "documents"
        },
        "topK": 10,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.2,
      "position": [
        -2800,
        1620
      ],
      "id": "13621e7a-bc3d-45da-b0f9-8116a419f0ab",
      "name": "Supabase Vector Store1",
      "credentials": {
        "supabaseApi": {
          "id": "5GKOb3OoOKDID5ub",
          "name": "Supabase Servidor"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        -2740,
        1780
      ],
      "id": "43577157-dda0-4459-b964-b67e17e88756",
      "name": "Embeddings OpenAI1",
      "credentials": {
        "openAiApi": {
          "id": "jI96AY0ncv2lfYaq",
          "name": "N8N Servidor"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -960,
        1380
      ],
      "id": "be097954-4983-4cbf-b73e-6f65675111bd",
      "name": "Wait4",
      "webhookId": "c548b611-3b60-4191-b212-c6d0ce14e71e"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "34ff5c50-b6e6-4ecb-bbee-c0d49f0eb56c",
              "leftValue": "={{ $json.output.response.part_2 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -740,
        1520
      ],
      "id": "1149a746-44e3-491e-8b36-0b6f6ab46ce1",
      "name": "If4"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.instagram.com/v23.0/me/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"recipient\":{\n    \"id\":\"{{ $('Edit Fields5').item.json.ID }}\"\n  },\n  \"message\":{\n    \"text\":\"{{ $json.output.response.part_2 }}\"\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -540,
        1380
      ],
      "id": "96c4b4e5-5c85-4f64-848d-b35765e11183",
      "name": "Instagram Graph API1",
      "credentials": {
        "httpHeaderAuth": {
          "id": "fJrS7XDHAN3wAhrj",
          "name": "Agente Ventas Instagram"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -320,
        1380
      ],
      "id": "101c45b7-0e62-48eb-b87f-21bfb23b6d8e",
      "name": "Wait5",
      "webhookId": "3241480b-0115-4f93-91f3-8c9e31e91059"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "34ff5c50-b6e6-4ecb-bbee-c0d49f0eb56c",
              "leftValue": "={{ $json.output.response.part_3 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -120,
        1540
      ],
      "id": "bb1be7d9-b2bc-47e2-b737-5ba035cccd8c",
      "name": "If8"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.instagram.com/v23.0/me/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"recipient\":{\n    \"id\":\"{{ $('Edit Fields5').item.json.ID }}\"\n  },\n  \"message\":{\n    \"text\":\"{{ $json.output.response.part_3 }}\"\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        80,
        1380
      ],
      "id": "82163b29-cf4d-4c94-91e7-7cf48c10ce08",
      "name": "Instagram Graph API2",
      "credentials": {
        "httpHeaderAuth": {
          "id": "fJrS7XDHAN3wAhrj",
          "name": "Agente Ventas Instagram"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        300,
        1380
      ],
      "id": "a500f6fd-d35c-45a6-ab7d-fb7d920892de",
      "name": "Wait8",
      "webhookId": "3241480b-0115-4f93-91f3-8c9e31e91059"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "34ff5c50-b6e6-4ecb-bbee-c0d49f0eb56c",
              "leftValue": "={{ $json.output.response.part_4 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        440,
        1540
      ],
      "id": "f4637228-b332-4d82-9d3d-09c8ac842644",
      "name": "If11"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.instagram.com/v23.0/me/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"recipient\":{\n    \"id\":\"{{ $('Edit Fields5').item.json.ID }}\"\n  },\n  \"message\":{\n    \"text\":\"{{ $json.output.response.part_4 }}\"\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        620,
        1400
      ],
      "id": "ef59e854-17bd-4280-82f0-16c876d9f5a2",
      "name": "Instagram Graph API3",
      "credentials": {
        "httpHeaderAuth": {
          "id": "fJrS7XDHAN3wAhrj",
          "name": "Agente Ventas Instagram"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        840,
        1400
      ],
      "id": "0d20a5ca-6014-45bc-9458-6bfffa2d7414",
      "name": "Wait9",
      "webhookId": "3241480b-0115-4f93-91f3-8c9e31e91059"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "34ff5c50-b6e6-4ecb-bbee-c0d49f0eb56c",
              "leftValue": "={{ $json.output.response.part_5 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1020,
        1560
      ],
      "id": "4b9cf5ec-01b1-4381-8945-0267b59d00eb",
      "name": "If12"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.instagram.com/v23.0/me/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"recipient\":{\n    \"id\":\"{{ $('Edit Fields5').item.json.ID }}\"\n  },\n  \"message\":{\n    \"text\":\"{{ $json.output.response.part_5 }}\"\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1200,
        1420
      ],
      "id": "654b4699-d1ab-4c92-a1f9-7fb450367d0c",
      "name": "Instagram Graph API4",
      "credentials": {
        "httpHeaderAuth": {
          "id": "fJrS7XDHAN3wAhrj",
          "name": "Agente Ventas Instagram"
        }
      }
    },
    {
      "parameters": {
        "content": "## Recopilamos mensajes en (x) intervalo de tiempo",
        "height": 680,
        "width": 1740,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -5440,
        1260
      ],
      "typeVersion": 1,
      "id": "f4cf4612-33a3-424c-9815-f57bc34fda3a",
      "name": "Sticky Note8"
    },
    {
      "parameters": {
        "operation": "select",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "n8n_chat_historial_bot",
          "mode": "list",
          "cachedResultName": "n8n_chat_historial_bot"
        },
        "limit": 1,
        "where": {
          "values": [
            {
              "column": "session_id",
              "value": "={{ $json.phone }}"
            }
          ]
        },
        "sort": {
          "values": [
            {
              "column": "id",
              "direction": "DESC"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        -3960,
        160
      ],
      "id": "ffb1805f-cfca-4118-94f4-73d7626ed06e",
      "name": "Postgres",
      "credentials": {
        "postgres": {
          "id": "EtwXhnSPkcUg9ZFC",
          "name": "Postgres Supabase"
        }
      }
    },
    {
      "parameters": {
        "operation": "select",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "n8n_chat_historial_bot",
          "mode": "list",
          "cachedResultName": "n8n_chat_historial_bot"
        },
        "limit": 1,
        "where": {
          "values": [
            {
              "column": "session_id",
              "value": "={{ $('Wait7').item.json.channelId }}"
            }
          ]
        },
        "sort": {
          "values": [
            {
              "column": "id",
              "direction": "DESC"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        -4220,
        1340
      ],
      "id": "68147fab-e251-49bd-9a5f-45f2bdccd501",
      "name": "Postgres1",
      "credentials": {
        "postgres": {
          "id": "EtwXhnSPkcUg9ZFC",
          "name": "Postgres Supabase"
        }
      }
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "={{ $('Webhook').item.json.body.instance }}",
        "remoteJid": "={{ $('Webhook').item.json.body.data.key.remoteJid }}",
        "messageText": "={{ $json.output.response.part_1 }}",
        "options_message": {
          "linkPreview": true
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        -1200,
        140
      ],
      "id": "32620d33-4b7e-489c-ac7c-75f3d0242505",
      "name": "Enviar texto",
      "credentials": {
        "evolutionApi": {
          "id": "YKZfBUO2WVeDoamM",
          "name": "Evolution account"
        }
      }
    }
  ],
  "pinData": {
    "Disparador Instagram": [
      {
        "json": {
          "headers": {
            "host": "aawebhookaa.vps.rubikmarketing.com.co",
            "user-agent": "axios/0.21.4",
            "content-length": "188",
            "accept": "application/json, text/plain, */*",
            "content-type": "application/json",
            "x-forwarded-for": "34.10.70.101",
            "x-forwarded-host": "aawebhookaa.vps.rubikmarketing.com.co",
            "x-forwarded-port": "443",
            "x-forwarded-proto": "https",
            "x-forwarded-server": "f75c220e25da",
            "x-real-ip": "34.10.70.101",
            "accept-encoding": "gzip"
          },
          "params": {},
          "query": {},
          "body": {
            "id": "LaTc08h0QMiiA6ZB0jjr",
            "name": "Angel Aparicio Aparicio",
            "email": "angel.aparicio92@gmail.com",
            "phone": "722 41 82 42",
            "mensaje": "Hey, que me puedes decir de la academia?",
            "adjunto": []
          },
          "webhookUrl": "https://aawebhookaa.vps.rubikmarketing.com.co/webhook/mensaje-recibido",
          "executionMode": "production"
        }
      }
    ],
    "Format Chain1": [
      {
        "json": {
          "output": {
            "response": {
              "part_1": "¡Genial que preguntes por la academia! 🤩🚀 Te cuento: IA Masters Automations es una comunidad donde aprenderás a dominar las automatizaciones con inteligencia artificial desde cero, con acceso a cursos, talleres en vivo, recursos exclusivos y un montón de trucos para optimizar tus procesos 💡🤖.",
              "part_2": "Desde el primer día tienes acceso a automatizaciones listas para usar, masterclasses grabadas, talleres de co-creación y tips súper útiles 🎓✨. Además, al participar, tu camaleón va cambiando de color y desbloqueas nuevos beneficios y cursos especiales 🦎🎯.",
              "part_3": "¡Y lo mejor! Puedes probar la comunidad GRATIS por 7 días para que explores todo el contenido y vivas la experiencia sin compromiso 😍🙌.",
              "part_4": "¿Te gustaría que te pase el enlace para registrarte y empezar ya? 😉"
            }
          }
        }
      }
    ],
    "Webhook": [
      {
        "json": {
          "headers": {
            "host": "aawebhookaa.vps.rubikmarketing.com.co",
            "user-agent": "axios/1.7.9",
            "content-length": "931",
            "accept-encoding": "gzip, compress, deflate, br",
            "content-type": "application/json",
            "x-forwarded-for": "172.18.0.1",
            "x-forwarded-host": "aawebhookaa.vps.rubikmarketing.com.co",
            "x-forwarded-port": "443",
            "x-forwarded-proto": "https",
            "x-forwarded-server": "f75c220e25da",
            "x-real-ip": "172.18.0.1"
          },
          "params": {},
          "query": {},
          "body": {
            "event": "messages.upsert",
            "instance": "Prueba",
            "data": {
              "key": {
                "remoteJid": "34722418242@s.whatsapp.net",
                "fromMe": false,
                "id": "3A1EEC8714BBFA57D00F"
              },
              "pushName": "AA",
              "status": "DELIVERY_ACK",
              "message": {
                "conversation": "Cuanto costaria una automatizacion?",
                "messageContextInfo": {
                  "deviceListMetadata": {
                    "senderKeyHash": "mxtlgDL+5PEgeg==",
                    "senderTimestamp": "1750862621",
                    "recipientKeyHash": "BBTIsqr6T8Sy0A==",
                    "recipientTimestamp": "1750088861"
                  },
                  "deviceListMetadataVersion": 2,
                  "messageSecret": "DGXdU4v41ya334yGOM9FRPCRYwqC4PX2fHh9r0VRuVc="
                }
              },
              "messageType": "conversation",
              "messageTimestamp": 1751318011,
              "instanceId": "0e656b40-9922-4ca5-8387-45641679d455",
              "source": "ios"
            },
            "destination": "https://aawebhookaa.vps.rubikmarketing.com.co/webhook/chatbot-evolution",
            "date_time": "2025-06-30T18:13:31.383Z",
            "sender": "34722324719@s.whatsapp.net",
            "server_url": "https://aaevolutionaa.vps.rubikmarketing.com.co",
            "apikey": "F04C6F68FF89-42FB-90F4-F427B7FD1C8C"
          },
          "webhookUrl": "https://aawebhookaa.vps.rubikmarketing.com.co/webhook/chatbot-evolution",
          "executionMode": "production"
        }
      }
    ]
  },
  "connections": {
    "Auto-fixing Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Format Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Auto-fixing Output Parser",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Format Chain": {
      "main": [
        [
          {
            "node": "Enviar texto",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Evolution API1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Evolution API3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "Evolution API4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If3": {
      "main": [
        [
          {
            "node": "Evolution API5",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Redis6": {
      "main": [
        [
          {
            "node": "If6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis7": {
      "main": [
        [
          {
            "node": "Wait6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait6": {
      "main": [
        [
          {
            "node": "Redis6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If6": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "Redis9",
            "type": "main",
            "index": 0
          },
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis9": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Format Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Auto-fixing Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "If18",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Redis7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If9": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "If9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields3": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Think1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields10": {
      "main": [
        [
          {
            "node": "Format Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If18": {
      "main": [
        [
          {
            "node": "Edit Fields10",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "If19",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "OpenAI5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File1": {
      "main": [
        [
          {
            "node": "OpenAI3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File2": {
      "main": [
        [
          {
            "node": "OpenAI6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If19": {
      "main": [
        [
          {
            "node": "Edit Fields13",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields13": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Edit Fields14",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields17",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields16",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields20",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Evolution API2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields14": {
      "main": [
        [
          {
            "node": "Edit Fields15",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI3": {
      "main": [
        [
          {
            "node": "Edit Fields18",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields16": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields17": {
      "main": [
        [
          {
            "node": "Convert to File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI5": {
      "main": [
        [
          {
            "node": "Edit Fields19",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields20": {
      "main": [
        [
          {
            "node": "Convert to File2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI6": {
      "main": [
        [
          {
            "node": "Edit Fields21",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields15": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields18": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields19": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields21": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evolution API1": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evolution API3": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evolution API4": {
      "main": [
        [
          {
            "node": "Wait3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Extract from File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Semantic Chunker": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Google Drive2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request2": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive1": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File1": {
      "main": [
        [
          {
            "node": "Semantic Chunker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait3": {
      "main": [
        [
          {
            "node": "If3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Disparador Instagram": {
      "main": [
        [
          {
            "node": "Responder webhook – Instagram (POST)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Responder webhook – Instagram (GET)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Responder webhook – Instagram (POST)": {
      "main": [
        [
          {
            "node": "Si no es echo – Instagram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Si no es echo – Instagram": {
      "main": [
        [
          {
            "node": "Editar campos – Instagram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis": {
      "main": [
        [
          {
            "node": "If7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis8": {
      "main": [
        [
          {
            "node": "Wait7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait7": {
      "main": [
        [
          {
            "node": "Redis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If7": {
      "main": [
        [
          {
            "node": "Edit Fields4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields4": {
      "main": [
        [
          {
            "node": "Redis10",
            "type": "main",
            "index": 0
          },
          {
            "node": "Postgres1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis10": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Editar campos – Instagram": {
      "main": [
        [
          {
            "node": "Redis8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "If10",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Auto-fixing Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "Format Chain1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser2": {
      "ai_outputParser": [
        [
          {
            "node": "Auto-fixing Output Parser1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Format Chain1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "Auto-fixing Output Parser1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory1": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "If20",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser3": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Code2": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If10": {
      "main": [
        [
          {
            "node": "Code2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields5": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model5": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Think": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields11": {
      "main": [
        [
          {
            "node": "Format Chain1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If20": {
      "main": [
        [
          {
            "node": "Edit Fields11",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Format Chain1": {
      "main": [
        [
          {
            "node": "Instagram Graph API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram Graph API": {
      "main": [
        [
          {
            "node": "Wait4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait4": {
      "main": [
        [
          {
            "node": "If4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If4": {
      "main": [
        [
          {
            "node": "Instagram Graph API1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram Graph API1": {
      "main": [
        [
          {
            "node": "Wait5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait5": {
      "main": [
        [
          {
            "node": "If8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram Graph API2": {
      "main": [
        [
          {
            "node": "Wait8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If8": {
      "main": [
        [
          {
            "node": "Instagram Graph API2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If11",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If11": {
      "main": [
        [
          {
            "node": "Instagram Graph API3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If12",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram Graph API3": {
      "main": [
        [
          {
            "node": "Wait9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait8": {
      "main": [
        [
          {
            "node": "If11",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If12": {
      "main": [
        [
          {
            "node": "Instagram Graph API4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram Graph API4": {
      "main": [
        []
      ]
    },
    "Wait9": {
      "main": [
        [
          {
            "node": "If12",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar texto": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "62608e6d-dbb3-479d-a2c8-3c293261c191",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "8fd110a1507f4b81c2521b680117b018e5cfcd7ec8e54b2134772014dccd9f00"
  },
  "id": "8IFYzcciiVL0L35P",
  "tags": []
}