AutomationFlowsAI & RAG › Kalele Chatbot (lm Chat Open Ai)

Kalele Chatbot (lm Chat Open Ai)

KALELE CHATBOT. Uses lmChatOpenAi, agent, toolWorkflow, memoryPostgresChat. Webhook trigger; 48 nodes.

Webhook trigger★★★★★ complexityAI-powered48 nodesOpenAI ChatAgentTool WorkflowMemory Postgres ChatRedisHTTP RequestOpenAI
AI & RAG Trigger: Webhook Nodes: 48 Complexity: ★★★★★ AI nodes: yes Added:

This workflow follows the Agent → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "KALELE CHATBOT",
  "nodes": [
    {
      "parameters": {
        "model": "gpt-4.1-mini",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.1,
      "position": [
        -192,
        1888
      ],
      "id": "e287ff82-dee8-4a6d-abe8-fee7bc636f88",
      "name": "OpenAI Chat Model2",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Edit Fields2').item.json.Input }}",
        "options": {
          "systemMessage": "=Eres la asistente virtual oficial de Kalele Boutique, una tienda de ropa en Costa Rica.\n\nTu funci\u00f3n es atender mensajes de clientas en Instagram, WhatsApp y Messenger respondiendo de forma amable, natural, en espa\u00f1ol tico, clara y orientada a ventas.\n\n\ud83d\udd0c FUENTE DE INVENTARIO (importante):\nTu cat\u00e1logo NO est\u00e1 en una hoja manual. Est\u00e1 conectado en tiempo real con la tienda en l\u00ednea https://kaleleboutique.com v\u00eda su API de WooCommerce. Eso significa:\n- Cuando la due\u00f1a sube un producto nuevo en la web, vos ya lo ves.\n- Cuando una talla o producto se vende y queda en cero, vos autom\u00e1ticamente lo ves como agotado.\n- Cuando el due\u00f1o actualiza precio, talla, color o foto en la web, se refleja al instante en tus respuestas.\nNO hace falta tocar nada manual. SIEMPRE confi\u00e1 en lo que devuelva la herramienta buscar_producto.\n\n\ud83d\udce6 CATEGOR\u00cdAS REALES DE LA TIENDA (\u00fasalas tal cual en productos_similares):\nVestidos, Vestidos Gala, Tops, Blusas, Pantalones, Faldas, Faldas Shorts, Shorts, Enterizos, Abrigos, Blazers, Sets, Zapatos, Botas, Bailarinas, Plataformas, Accesorios, Chaleco, SALE\n\n\ud83d\udee0 HERRAMIENTAS DISPONIBLES (todas reciben UNA sola cadena 'query' o 'resumen'):\n\n1) buscar_producto({ query: string })\n\u00dasala SIEMPRE que la clienta pregunte por una prenda, precio, talla, color o disponibilidad. Nunca inventes datos.\nEn 'query' pon\u00e9 juntas todas las palabras \u00fatiles: tipo de prenda + talla + color si aplica.\nEjemplos:\n  - \"vestidos con botones\" \u2192 query: \"vestido botones\"\n  - \"cu\u00e1nto vale el vestido corset?\" \u2192 query: \"vestido corset\"\n  - \"tienen el vestido floral talla M en rojo?\" \u2192 query: \"vestido floral M rojo\"\nRespuesta:\n- status \"encontrado\": viene un producto principal con id, nombre, precio en \u20a1, tallas_disponibles, colores_disponibles, foto, link y disponibilidad. Tambi\u00e9n coincidencias_adicionales con hasta 5 m\u00e1s.\n- disponibilidad: \"disponible\" / \"agotado\" / \"talla_no_disponible\" / \"color_no_disponible\".\n- status \"no_encontrado\": prob\u00e1 otra b\u00fasqueda con palabras distintas o deriv\u00e1.\n\n2) productos_similares({ query: string })\n\u00dasala cuando lo que pidi\u00f3 est\u00e1 agotado o no existe. Pon\u00e9 en 'query' la categor\u00eda + color + talla.\nEjemplos:\n  - \"otro vestido rojo en M\" \u2192 query: \"vestido rojo M\"\n  - \"algo parecido a esa falda de mezclilla\" \u2192 query: \"falda mezclilla\"\nDevuelve hasta 5 alternativas en stock.\n\n3) derivar_encargada({ resumen: string })\n\u00dasala cuando:\n- La b\u00fasqueda no devuelve nada \u00fatil y los similares tampoco\n- La clienta mand\u00f3 una foto y no logras identificar la prenda\n- La clienta pregunta por env\u00edos exactos, m\u00e9todos de pago, ubicaci\u00f3n, cambios o cualquier dato que no tengas\n- La clienta pide expl\u00edcitamente hablar con una persona\nEn 'resumen' escrib\u00ed qu\u00e9 pidi\u00f3 y qu\u00e9 falta. Despu\u00e9s decile: \"Te voy a comunicar con una encargada para ayudarte mejor \ud83d\ude0a\".\n\n\ud83d\udccb FLUJO IDEAL:\n1. La clienta pregunta por una prenda \u2192 llam\u00e1s a buscar_producto.\n2. Si disponibilidad = \"disponible\": confirm\u00e1s precio, pregunt\u00e1s talla si falta, mostr\u00e1s colores disponibles, ofrec\u00e9s foto y/o link.\n3. Si \"talla_no_disponible\" o \"color_no_disponible\": ofrec\u00e9s otras opciones que s\u00ed est\u00e1n y/o us\u00e1s productos_similares.\n4. Si \"agotado\": llam\u00e1s a productos_similares con la misma categor\u00eda y ofrec\u00e9s alternativas. Si igual no hay nada, deriv\u00e1s.\n5. Si \"no_encontrado\": prob\u00e1s otra b\u00fasqueda con palabras distintas. Si tampoco, deriv\u00e1s.\n6. Si la clienta quiere comprar: le pas\u00e1s el link y le dec\u00eds que ah\u00ed mismo elige talla y paga, o deriv\u00e1s si prefiere atenci\u00f3n humana.\n\n\u270d\ufe0f EJEMPLOS DE RESPUESTA:\n\nDisponible:\n\"\u00a1Hola! Claro \ud83d\ude0a El [nombre] cuesta [precio]. Lo tengo en tallas [tallas]. \u00bfCu\u00e1l te interesa?\"\n\nTalla disponible confirmada:\n\"S\u00ed, en talla M est\u00e1 disponible \u2764\ufe0f Te paso el link para que lo veas y pidas: [link]\"\n\nTalla no disponible:\n\"En este momento no tengo ese modelo en talla M \ud83d\ude15 \u00bfTe muestro opciones parecidas que s\u00ed est\u00e1n en tu talla?\"\n\nAgotado:\n\"Ese modelo se acaba de agotar \ud83d\ude15 Te muestro 2 alternativas muy similares que s\u00ed est\u00e1n disponibles: ...\"\n\nFoto no identificada:\n\"No logro confirmar exactamente cu\u00e1l modelo es solo con la foto. Te voy a comunicar con una encargada para que pueda revisarlo \ud83d\ude0a\"\n\n\ud83d\udeab REGLAS:\n1. NUNCA inventes producto, precio, talla, color, foto, link ni disponibilidad. Siempre us\u00e1 buscar_producto.\n2. Si la herramienta dice agotado, NO lo ofrezcas como disponible.\n3. El link y la foto que entreg\u00e1s SIEMPRE son los que devuelve la herramienta (no los inventes).\n4. Respond\u00e9 corto, amable y natural. Emojis con moderaci\u00f3n.\n5. No menciones n8n, API, WooCommerce, automatizaci\u00f3n ni nada t\u00e9cnico.\n6. Si la clienta est\u00e1 confundida, hac\u00e9 preguntas simples.\n7. Si pide recomendaci\u00f3n, pregunt\u00e1 primero ocasi\u00f3n, talla, color o estilo.\n8. La p\u00e1gina oficial es https://kaleleboutique.com \u2014 si te piden el cat\u00e1logo general, pod\u00e9s enviar ese link.\n\n\ud83d\udce4 FORMATO DE RESPUESTA OBLIGATORIO:\nSIEMPRE respond\u00e9s con un array JSON de items cortos coherentes. Nunca texto plano.\n\n[\n  \"\u00a1Hola! Claro\",\n  \"El vestido midi corset cuesta \u20a125,000\",\n  \"Lo tengo en tallas S, M y L. \u00bfCu\u00e1l te interesa?\"\n]\n\nFecha actual:\n{{ new Date($now).toLocaleString(\"es-CR\", { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\", hour: \"2-digit\", minute: \"2-digit\", hour12: true, timeZone: \"America/Costa_Rica\" }) }}\n\nsubscriber_id de la clienta actual: {{ $('Webhook').item.json.body.id }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        -128,
        1728
      ],
      "id": "67550f71-7831-45ed-9664-3dd6f0b55698",
      "name": "VENDEDOR"
    },
    {
      "parameters": {
        "description": "buscar_producto: Consulta el cat\u00e1logo en vivo de Kalele Boutique. Pasale una sola cadena 'query' con la descripci\u00f3n de la prenda + talla + color si la clienta los mencion\u00f3. Ej: 'vestido corset M rojo' o 'falda de mezclilla'.",
        "workflowId": {
          "__rl": true,
          "value": "REEMPLAZAR_ID_BUSCAR_PRODUCTO",
          "mode": "list",
          "cachedResultName": "KALELE_BUSCAR_PRODUCTO"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', `Descripci\u00f3n de la prenda que busca la clienta. Si dio talla (S/M/L/XL) o color, incl\u00fayelos en la misma cadena.`, 'string') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "query",
              "displayName": "query",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        176,
        1936
      ],
      "id": "6f7fa091-a2af-46b0-b342-9e1eed4b96eb",
      "name": "BUSCAR PRODUCTO"
    },
    {
      "parameters": {
        "description": "productos_similares: Cuando algo est\u00e1 agotado o no existe, llam\u00e1 esta tool con una sola cadena 'query' que incluya categor\u00eda + color + talla + descripci\u00f3n. Ej: 'vestido rojo M' o 'falda mezclilla'. Devuelve hasta 5 alternativas en stock.",
        "workflowId": {
          "__rl": true,
          "value": "REEMPLAZAR_ID_PRODUCTOS_SIMILARES",
          "mode": "list",
          "cachedResultName": "KALELE_PRODUCTOS_SIMILARES"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', `Descripci\u00f3n de lo que busca: categor\u00eda + color + talla + estilo. Una sola cadena.`, 'string') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "query",
              "displayName": "query",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        16,
        1952
      ],
      "id": "44828aae-236d-44a6-acf0-c8e32745e870",
      "name": "PRODUCTOS SIMILARES"
    },
    {
      "parameters": {
        "description": "derivar_encargada: Llamala cuando la clienta necesite atenci\u00f3n humana (no se encontr\u00f3 producto, foto no identificada, info faltante, pide hablar con persona). Pasale 'resumen' con un texto breve que explique qu\u00e9 pidi\u00f3 y qu\u00e9 falta.",
        "workflowId": {
          "__rl": true,
          "value": "REEMPLAZAR_ID_DERIVAR_ENCARGADA",
          "mode": "list",
          "cachedResultName": "KALELE_DERIVAR_ENCARGADA"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "resumen": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('resumen', `Qu\u00e9 pidi\u00f3 la clienta y qu\u00e9 informaci\u00f3n falta para que la encargada pueda continuar.`, 'string') }}",
            "subscriber_id": "={{ $('Webhook').item.json.body.id }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "resumen",
              "displayName": "resumen",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            },
            {
              "id": "subscriber_id",
              "displayName": "subscriber_id",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        352,
        1888
      ],
      "id": "a69050ad-650c-4078-99d6-d72f376e9cec",
      "name": "DERIVAR ENCARGADA"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.1,
      "position": [
        -1168,
        2208
      ],
      "id": "0edbf53c-6a0f-4798-8136-8d59faca5823",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "f08493f0-5a28-4a67-86c5-c4742909b4f2",
              "leftValue": "={{ $json.output }}",
              "rightValue": "PRODUCTO",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -624,
        1760
      ],
      "id": "e4d2d214-8a1b-495c-a8ee-6682df0808d0",
      "name": "If"
    },
    {
      "parameters": {
        "model": "gpt-4.1-mini",
        "options": {
          "temperature": 0.7
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.1,
      "position": [
        -272,
        2320
      ],
      "id": "da148310-dde5-4de3-9260-c13107788190",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Webhook').item.json.body.key }}",
        "contextWindowLength": 15
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        -624,
        2176
      ],
      "id": "b3ac6149-ace9-4ae8-b1ee-a652ba1933bd",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.Input }}",
        "options": {
          "systemMessage": "=Eres un clasificador de intenciones para el chatbot de Kalele Boutique.\n\nTu \u00fanica tarea es decidir si el \u00faltimo mensaje de la clienta requiere consultar el inventario de productos o si es conversaci\u00f3n general.\n\nCategor\u00edas:\n\nPRODUCTO \u2192 la clienta:\n- Pregunta por una prenda concreta (vestido, blusa, pantal\u00f3n, jean, falda, etc.)\n- Pregunta por precio, talla, color, foto, disponibilidad o link\n- Pide recomendaci\u00f3n de outfit, talla o color\n- Manda una imagen de prenda (texto contiene descripci\u00f3n de la prenda)\n- Confirma intenci\u00f3n de compra o pide ver el cat\u00e1logo\n- Da una talla / color como respuesta dentro de un flujo activo de b\u00fasqueda de producto\n\nGENERAL \u2192 la clienta:\n- Saluda sin pedir producto (\"hola\", \"buenas\")\n- Pregunta por horarios, ubicaci\u00f3n, env\u00edos, m\u00e9todos de pago, cambios y devoluciones, pol\u00edticas\n- Hace conversaci\u00f3n casual\n- Pide hablar con una persona\n\nReglas:\n1. Si hay un flujo de producto activo en el historial y la clienta da una talla/color/decisi\u00f3n, sigue siendo PRODUCTO.\n2. Cuando dudes entre las dos, prioriza PRODUCTO para no romper el flujo de venta.\n3. Analiza TODO el historial, no solo la \u00faltima frase.\n\nResponde UNA sola palabra: PRODUCTO o GENERAL"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        -1008,
        1760
      ],
      "id": "67a87f79-8848-4362-b4bf-ddf664093966",
      "name": "POLICIA"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Edit Fields2').item.json.Input }}",
        "options": {
          "systemMessage": "=Eres la asistente virtual de Kalele Boutique para conversaci\u00f3n general (no consultas de inventario).\n\nTu tarea es responder con tono amable, cercano, profesional y natural, en espa\u00f1ol tico, preguntas sobre la tienda como horarios, ubicaci\u00f3n, env\u00edos, m\u00e9todos de pago, cambios, devoluciones, pol\u00edticas y dudas casuales.\n\n\ud83d\udccc Informaci\u00f3n est\u00e1tica de la tienda (\u00fasala cuando aplique):\n- Nombre: Kalele Boutique\n- Pa\u00eds: Costa Rica\n- M\u00e9todos de pago: SINPE M\u00f3vil, transferencia, tarjeta\n- Env\u00edos: a todo el pa\u00eds por Correos de Costa Rica / Servientrega (1 a 3 d\u00edas h\u00e1biles)\n- Cambios: hasta 8 d\u00edas naturales con etiqueta puesta\n- Horario: lunes a s\u00e1bado 10am \u2013 7pm\n- Contacto humano: las encargadas atienden en horario laboral\n\nSi te preguntan algo MUY espec\u00edfico que NO est\u00e1 aqu\u00ed (ej. precio de un env\u00edo exacto, disponibilidad en tienda f\u00edsica, monto de un pago, datos de SINPE, direcci\u00f3n exacta), responde de forma amable: \"Para confirmarte bien esa informaci\u00f3n, te voy a comunicar con una encargada \ud83d\ude0a\" y termina ah\u00ed. No inventes datos.\n\nNUNCA hables de productos espec\u00edficos, precios, tallas, colores ni disponibilidad \u2014 para eso existe otro agente. Si la clienta empieza a preguntar por un producto, redirige de forma natural: \"Claro \ud83d\ude0a para ayudarte mejor, contame qu\u00e9 prenda and\u00e1s buscando.\"\n\nReglas:\n- Responde breve, sin sonar robot.\n- Usa emojis con moderaci\u00f3n.\n- No menciones n8n, base de datos, automatizaci\u00f3n ni procesos internos.\n- No prometas env\u00edos o cambios fuera de las pol\u00edticas listadas arriba.\n\n\ud83d\udce4 FORMATO DE RESPUESTA OBLIGATORIO:\nSIEMPRE responde con este formato JSON exacto, dividiendo en items cortos coherentes:\n\n[\n  \"\u00a1Hola! Con gusto te ayudo\",\n  \"Recibimos pagos por SINPE, transferencia o tarjeta\",\n  \"\u00bfTe ayudo con algo m\u00e1s?\"\n]\n\nIMPORTANTE: Nunca devuelvas texto plano, siempre este formato JSON."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        -112,
        2112
      ],
      "id": "71ba1df5-5f96-4858-b46f-db298d18804e",
      "name": "CONVERSACI\u00d3N"
    },
    {
      "parameters": {
        "operation": "push",
        "list": "={{ $('Edit Fields').item.json.body.key }}",
        "messageData": "={{ JSON.stringify($('Edit Fields').item.json.body) }}",
        "tail": true
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -2128,
        1344
      ],
      "id": "1ec731d2-01b8-4318-9719-34004f58e1ae",
      "name": "Insertar",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "35e1061d-69e7-4800-a6ab-42de43f71524",
              "name": "body.key",
              "value": "={{ $json.body.key }}",
              "type": "string"
            },
            {
              "id": "3faa58fb-b3fd-443e-83df-45c1d542806f",
              "name": "body",
              "value": "={{ $json.body }}",
              "type": "object"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2448,
        1632
      ],
      "id": "c1fed83d-2736-4712-9e4f-c17bd890f96c",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "operation": "get",
        "propertyName": "mensaje",
        "key": "={{ $('Edit Fields').item.json.body.key }}",
        "options": {}
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -1904,
        1360
      ],
      "id": "9af4afbd-f939-417f-8b8c-963ee8cb82e9",
      "name": "CACHAR INFO",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ JSON.parse($json.mensaje.last()).key }}",
                    "rightValue": "={{ $('Edit Fields').item.json.body.key }}",
                    "operator": {
                      "type": "string",
                      "operation": "notEquals"
                    },
                    "id": "342f8e42-f993-40d8-9188-5b501338a035"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "NADA"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "dee9248c-bc58-4d0d-80f4-eba8bafba419",
                    "leftValue": "={{ JSON.parse($json.mensaje.last()).ig_last_interaction }}",
                    "rightValue": "={{ $now.minus(25,'seconds') }}",
                    "operator": {
                      "type": "dateTime",
                      "operation": "before"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "AGARRAR"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f1515c3b-6a0a-463a-a3e9-171eed40ecb6",
                    "leftValue": "={{ JSON.parse($json.mensaje.first()).key }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "notExists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "NO EXISTE"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "POLICIA"
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -1600,
        1344
      ],
      "id": "23663744-63ce-45ad-9f04-daebfa3a19e1",
      "name": "Switch",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "amount": 25
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -1360,
        1568
      ],
      "id": "39307463-2650-414f-b37e-87c7049f967d",
      "name": "Wait"
    },
    {
      "parameters": {
        "operation": "delete",
        "key": "={{ $('Edit Fields').item.json.body.key }}"
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -1312,
        1392
      ],
      "id": "3931227a-482b-4b3a-ae44-531eb3cc6bd2",
      "name": "Redis",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "mensaje",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -1120,
        1408
      ],
      "id": "280c41a1-aa74-4da5-95d2-cb524ac9fef3",
      "name": "Split Out"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0d1729a1-0e28-425e-a8c0-a7e945d919ec",
              "name": "mensaje",
              "value": "={{ $json.last_input_text }}",
              "type": "string"
            },
            {
              "id": "5ef4a455-4c16-4328-8569-3c5ebced96b0",
              "name": "hora_llegada",
              "value": "={{ $json.ig_last_interaction }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -448,
        1216
      ],
      "id": "f4e35ccf-f9dd-4929-90e1-801f435f7c9c",
      "name": "Edit Fields1"
    },
    {
      "parameters": {
        "sortFieldsUi": {
          "sortField": [
            {
              "fieldName": "hora_llegada"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.sort",
      "typeVersion": 1,
      "position": [
        864,
        1232
      ],
      "id": "42a5ee1c-232f-4bc8-ad66-f02a83d9bbda",
      "name": "Sort",
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "mensaje"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        400,
        1440
      ],
      "id": "6d2828a2-c1c4-4e9c-ab58-d72fc0703311",
      "name": "Aggregate"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "9bc6147a-2246-4d74-833b-bc694f075aeb",
              "name": "Input",
              "value": "={{ $json.mensaje.join(\" \") }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1168,
        1760
      ],
      "id": "2c9d0f03-d80e-4494-86fa-9bec6f373a71",
      "name": "Edit Fields2"
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "={{ JSON.parse($json.mensaje) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -944,
        1408
      ],
      "id": "4aa437ff-6353-48a6-89cd-0db6c49d71d4",
      "name": "Edit Fields3"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -1440,
        1152
      ],
      "id": "d31dc26c-d6fd-487c-9acb-5cb63e07f1f2",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -1520,
        1680
      ],
      "id": "75867646-5c57-428b-ad02-7e8382c83cb0",
      "name": "No Operation, do nothing1"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.last_input_text }}",
                    "rightValue": "https://lookaside",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "id": "20dd2c64-e7ff-416f-a972-953f645ce11b"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "AUDIO"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "1fcd18f0-0b0a-4b58-9242-0bb6d276ba0c",
                    "leftValue": "={{ $json.last_input_text }}",
                    "rightValue": "https://lookaside",
                    "operator": {
                      "type": "string",
                      "operation": "notContains"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "TEXTO"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -848,
        1200
      ],
      "id": "0e9aea99-b733-49b0-93ba-5f28e0a117a7",
      "name": "Switch1"
    },
    {
      "parameters": {
        "method": "HEAD",
        "url": "={{ $('Edit Fields3').item.json.last_input_text }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -672,
        960
      ],
      "id": "e84c17cb-0a32-4e2a-b6e9-81aab03f3419",
      "name": "HTTP Request3"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{$binary.data.mimeType}}",
                    "rightValue": "video/mp4",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "4ad8004f-f867-497a-9de8-4c4d901f974c"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "AUDIO"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "93275bc1-904c-4af8-a9a5-a319642b58c2",
                    "leftValue": "={{$binary.data.mimeType}}",
                    "rightValue": "image/jpeg",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "IMAGEN"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -400,
        976
      ],
      "id": "3c71242a-4e8f-4f75-bab6-4fc3083e670f",
      "name": "Switch2"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -48,
        1184
      ],
      "id": "0548b2d8-4131-4689-a897-a812dcced5b3",
      "name": "No Operation, do nothing2"
    },
    {
      "parameters": {
        "url": "={{ $('Edit Fields3').item.json.last_input_text }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        32,
        864
      ],
      "id": "c1ef8fb0-3e30-4a85-a713-60960dbc3eab",
      "name": "HTTP Request4"
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "text": "Describe con detalle la prenda de ropa que ves en la imagen. Incluye: tipo de prenda (vestido, blusa, falda, jean, etc.), color principal, colores secundarios, estampado o liso, material aparente, estilo (casual, formal, fiesta, deportivo), detalles destacados (escote, manga, largo, corte). Responde en un p\u00e1rrafo corto en espa\u00f1ol.",
        "inputType": "base64",
        "simplify": false,
        "options": {
          "detail": "high"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        48,
        992
      ],
      "id": "7ef4a679-4a3c-4abc-b832-010038c3b5d8",
      "name": "OpenAI1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        544,
        1232
      ],
      "id": "cabb6561-0395-41a6-8cc5-729223fa6a2f",
      "name": "Merge"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0d1729a1-0e28-425e-a8c0-a7e945d919ec",
              "name": "mensaje",
              "value": "={{ $json.choices[0].message.content }}",
              "type": "string"
            },
            {
              "id": "5ef4a455-4c16-4328-8569-3c5ebced96b0",
              "name": "hora_llegada",
              "value": "={{ $('Edit Fields3').item.json.ig_last_interaction }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        288,
        1104
      ],
      "id": "fb8cec8b-3a12-41f4-9fcc-afcc97bd9aea",
      "name": "Edit Fields6"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0d1729a1-0e28-425e-a8c0-a7e945d919ec",
              "name": "mensaje",
              "value": "={{ $json.text }}",
              "type": "string"
            },
            {
              "id": "5ef4a455-4c16-4328-8569-3c5ebced96b0",
              "name": "hora_llegada",
              "value": "={{ $('Edit Fields3').item.json.ig_last_interaction }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        448,
        896
      ],
      "id": "125fe40e-2782-4edb-bac4-b8b7c0b91590",
      "name": "Edit Fields7"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.manychat.com/fb/sending/sendContent",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n\"subscriber_id\": {{ $('Webhook').item.json.body.id }},\n\"data\": {\n\"version\": \"v2\",\n\"content\": {\n\"type\": \"instagram\",\n\"messages\": [\n{\n\"type\": \"text\",\n\"text\": \"{{ $json.output }}\"\n}\n]\n}\n}\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        976,
        1760
      ],
      "id": "3f550879-140d-4e6d-ac25-dfe7ad21c80f",
      "name": "HTTP Request",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.manychat.com/fb/sending/sendContent",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n\"subscriber_id\": {{ $('Webhook').item.json.body.id }},\n\"data\": {\n\"version\": \"v2\",\n\"content\": {\n\"type\": \"instagram\",\n\"messages\": [\n{\n\"type\": \"text\",\n\"text\": \"{{ $json.output }}\"\n}\n]\n}\n}\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        2272
      ],
      "id": "674ae02f-848b-41aa-b49f-9937dc6582a6",
      "name": "HTTP Request2",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        784,
        2112
      ],
      "id": "0166f423-1399-4900-880a-bb4e53aa7949",
      "name": "Loop Over Items1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1024,
        2400
      ],
      "id": "a68362a8-a0b0-4147-b14b-c52a2d0fd761",
      "name": "Wait2"
    },
    {
      "parameters": {
        "jsCode": "const items = $input.all();\n\nfunction cleanTextForManyChat(text) {\n  const textStr = typeof text === 'string' ? text : String(text);\n  return textStr\n    .replace(/\\n+/g, ' ')\n    .replace(/\"/g, '')\n    .replace(/\\s+/g, ' ')\n    .trim();\n}\n\nfunction extractJSON(text) {\n  try {\n    return JSON.parse(text);\n  } catch (error) {\n    const jsonMatches = text.match(/\\{[^{}]*\\[[^\\]]*\\][^{}]*\\}/g) || text.match(/\\[[^\\]]*\\]/g);\n    if (jsonMatches && jsonMatches.length > 0) {\n      try { return JSON.parse(jsonMatches[0]); }\n      catch (e) { throw new Error('No se pudo parsear el JSON encontrado'); }\n    }\n    throw new Error('No se encontr\u00f3 JSON v\u00e1lido');\n  }\n}\n\nconst processedItems = [];\n\nitems.forEach(item => {\n  const rawOutput = item.json.output;\n  try {\n    const parsedData = extractJSON(rawOutput);\n    let messages = [];\n    if (Array.isArray(parsedData)) messages = parsedData;\n    else if (parsedData.output && Array.isArray(parsedData.output)) messages = parsedData.output;\n    else if (parsedData.messages && Array.isArray(parsedData.messages)) messages = parsedData.messages;\n    else messages = [JSON.stringify(parsedData)];\n\n    if (messages.length > 0) {\n      messages.forEach((m, idx) => processedItems.push({\n        json: { output: cleanTextForManyChat(m), messageIndex: idx + 1, totalMessages: messages.length, parseStatus: 'success' }\n      }));\n    } else {\n      processedItems.push({ json: { output: 'Disculp\u00e1, hubo un detalle. \u00bfPod\u00e9s repetir tu mensaje?', messageIndex: 1, totalMessages: 1, parseStatus: 'empty_array' } });\n    }\n  } catch (error) {\n    processedItems.push({ json: { output: cleanTextForManyChat(rawOutput), messageIndex: 1, totalMessages: 1, parseStatus: 'fallback_text', parseError: error.message } });\n  }\n});\n\nreturn processedItems;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        320,
        2112
      ],
      "id": "5cdfdac0-c3b3-46d9-a704-c5194d2b1a46",
      "name": "Code3"
    },
    {
      "parameters": {
        "url": "={{ $('Edit Fields').item.json.body.last_input_text }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -128,
        992
      ],
      "id": "457f14d6-feb4-4670-9448-3b100df6ba58",
      "name": "HTTP Request8"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Webhook').item.json.body.key }}",
        "contextWindowLength": 30
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        -720,
        2128
      ],
      "id": "a2401d5a-2829-4ce1-9638-cf0bff513b36",
      "name": "Postgres Chat Memory1",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Webhook').item.json.body.key }}",
        "contextWindowLength": 30
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        -128,
        1968
      ],
      "id": "1799fc99-6e0e-4ac8-b0d4-57d82a8546d6",
      "name": "Postgres Chat Memory2",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1072,
        1328
      ],
      "id": "daa460f0-db95-46d0-b688-7fc7e473f5ea",
      "name": "No Operation, do nothing3"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        784,
        1712
      ],
      "id": "e7e98ec5-fd6d-4476-bf98-c204982d12f4",
      "name": "Loop Over Items3"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1184,
        1872
      ],
      "id": "66241eaf-91d6-4417-9985-8399ebf6778c",
      "name": "Wait3"
    },
    {
      "parameters": {
        "jsCode": "const items = $input.all();\n\nfunction cleanTextForManyChat(text) {\n  const textStr = typeof text === 'string' ? text : String(text);\n  return textStr\n    .replace(/\\n+/g, ' ')\n    .replace(/\"/g, '')\n    .replace(/\\s+/g, ' ')\n    .trim();\n}\n\nfunction extractJSON(text) {\n  try {\n    return JSON.parse(text);\n  } catch (error) {\n    const jsonMatches = text.match(/\\{[^{}]*\\[[^\\]]*\\][^{}]*\\}/g) || text.match(/\\[[^\\]]*\\]/g);\n    if (jsonMatches && jsonMatches.length > 0) {\n      try { return JSON.parse(jsonMatches[0]); }\n      catch (e) { throw new Error('No se pudo parsear el JSON encontrado'); }\n    }\n    throw new Error('No se encontr\u00f3 JSON v\u00e1lido');\n  }\n}\n\nconst processedItems = [];\n\nitems.forEach(item => {\n  const rawOutput = item.json.output;\n  try {\n    const parsedData = extractJSON(rawOutput);\n    let messages = [];\n    if (Array.isArray(parsedData)) messages = parsedData;\n    else if (parsedData.output && Array.isArray(parsedData.output)) messages = parsedData.output;\n    else if (parsedData.messages && Array.isArray(parsedData.messages)) messages = parsedData.messages;\n    else messages = [JSON.stringify(parsedData)];\n\n    if (messages.length > 0) {\n      messages.forEach((m, idx) => processedItems.push({\n        json: { output: cleanTextForManyChat(m), messageIndex: idx + 1, totalMessages: messages.length, parseStatus: 'success' }\n      }));\n    } else {\n      processedItems.push({ json: { output: 'Disculp\u00e1, hubo un detalle. \u00bfPod\u00e9s repetir tu mensaje?', messageIndex: 1, totalMessages: 1, parseStatus: 'empty_array' } });\n    }\n  } catch (error) {\n    processedItems.push({ json: { output: cleanTextForManyChat(rawOutput), messageIndex: 1, totalMessages: 1, parseStatus: 'fallback_text', parseError: error.message } });\n  }\n});\n\nreturn processedItems;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        400,
        1712
      ],
      "id": "b8f091cd-98be-41db-a571-a9d6e7d28d21",
      "name": "Code"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "kalele-chatbot-webhook",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -2592,
        1328
      ],
      "id": "ba0d4b04-633c-4ec2-9cfc-32b7881850a3",
      "name": "Webhook"
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        256,
        848
      ],
      "id": "139b5dc9-db86-4170-8014-b4e8be44b04c",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "VENDEDOR",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "VENDEDOR": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BUSCAR PRODUCTO": {
      "ai_tool": [
        [
          {
            "node": "VENDEDOR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "PRODUCTOS SIMILARES": {
      "ai_tool": [
        [
          {
            "node": "VENDEDOR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "DERIVAR ENCARGADA": {
      "ai_tool": [
        [
          {
            "node": "VENDEDOR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "POLICIA",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "VENDEDOR",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "CONVERSACI\u00d3N",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "CONVERSACI\u00d3N",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "CONVERSACI\u00d3N",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "POLICIA": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CONVERSACI\u00d3N": {
      "main": [
        [
          {
            "node": "Code3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insertar": {
      "main": [
        [
          {
            "node": "CACHAR INFO",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Insertar",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CACHAR INFO": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Redis",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "CACHAR INFO",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sort": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "POLICIA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields3": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "HTTP Request3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request3": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch2": {
      "main": [
        [
          {
            "node": "HTTP Request4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request8",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request4": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI1": {
      "main": [
        [
          {
            "node": "Edit Fields6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Sort",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields6": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields7": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Wait3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request2": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [],
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code3": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request8": {
      "main": [
        [
          {
            "node": "OpenAI1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory1": {
      "ai_memory": [
        [
          {
            "node": "POLICIA",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory2": {
      "ai_memory": [
        [
          {
            "node": "VENDEDOR",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items3": {
      "main": [
        [],
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait3": {
      "main": [
        [
          {
            "node": "Loop Over Items3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Loop Over Items3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Edit Fields7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "tags": []
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

KALELE CHATBOT. Uses lmChatOpenAi, agent, toolWorkflow, memoryPostgresChat. Webhook trigger; 48 nodes.

Source: https://gist.github.com/ivanfuentes1024-dot/3a40df7d7f2605debb6c566795f31ab1 — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

CLINICAINTEGRAL_secretary. Uses postgres, mcpClientTool, googleDriveTool, toolWorkflow. Webhook trigger; 89 nodes.

Postgres, Mcp Client Tool, Google Drive Tool +14
AI & RAG

Remi 1.1. Uses lmChatOpenAi, memoryPostgresChat, openAi, postgres. Webhook trigger; 89 nodes.

OpenAI Chat, Memory Postgres Chat, OpenAI +7
AI & RAG

my-secretary. Uses postgres, mcpClientTool, googleDriveTool, toolWorkflow. Webhook trigger; 86 nodes.

Postgres, Mcp Client Tool, Google Drive Tool +13
AI & RAG

My workflow 7. Uses openAi, redis, httpRequest, agent. Webhook trigger; 77 nodes.

OpenAI, Redis, HTTP Request +8
AI & RAG

My workflow 7. Uses openAi, redis, httpRequest, agent. Webhook trigger; 77 nodes.

OpenAI, Redis, HTTP Request +8