AutomationFlowsAI & RAG › Agente Ia, Whatsapp, Flowise, N8n Y Chatwoot

Agente Ia, Whatsapp, Flowise, N8n Y Chatwoot

Agente IA, WhatsApp, Flowise, N8N Y Chatwoot. Uses whatsApp, httpRequest, openAi, redis. Webhook trigger; 33 nodes.

Webhook trigger★★★★★ complexityAI-powered33 nodesWhatsAppHTTP RequestOpenAIRedisData Table
AI & RAG Trigger: Webhook Nodes: 33 Complexity: ★★★★★ AI nodes: yes Added:
Agente Ia, Whatsapp, Flowise, N8n Y Chatwoot — n8n workflow card showing WhatsApp, HTTP Request, OpenAI integration

This workflow follows the Datatable → 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": "Agente IA, WhatsApp, Flowise, N8N Y Chatwoot",
  "nodes": [
    {
      "parameters": {
        "resource": "media",
        "operation": "mediaUrlGet",
        "mediaGetId": "={{ $json.body.conversation.messages[0].attachments[0].data_url }}"
      },
      "id": "4ed3fd90-36f9-4fab-8094-0d762cc9db7d",
      "name": "Get Audio URL1",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2176,
        1504
      ],
      "typeVersion": 1,
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "media",
        "operation": "mediaUrlGet",
        "mediaGetId": "={{ $json.body.conversation.messages[0].attachments[0].data_url }}"
      },
      "id": "939bf20d-9784-4a46-9d15-185f5ff2410e",
      "name": "Get Image URL1",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2176,
        1776
      ],
      "typeVersion": 1,
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "={{ $json.id }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "whatsAppApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "="
            }
          ]
        },
        "options": {}
      },
      "id": "d7c46adc-27d6-4bc3-aab0-fdfe5ee622ba",
      "name": "Download Audio1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2320,
        1504
      ],
      "typeVersion": 4.2,
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "={{ $json.id }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "whatsAppApi",
        "options": {}
      },
      "id": "9fd8e76c-535b-42be-8548-d39b1eaa8961",
      "name": "Download Image1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2320,
        1776
      ],
      "typeVersion": 4.2,
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "23b785c3-f38e-4706-80b7-51f333bba3bd",
              "name": "message_text",
              "type": "string",
              "value": "={{ $json.content }}"
            },
            {
              "id": "da4b602a-28ca-4b0d-a747-c3d3698c3731",
              "name": "message_caption",
              "type": "string",
              "value": "={{ $('Redirect Message Types1').item.json.video && $('Redirect Message Types1').item.json.video.caption || '' }}\n{{ $('Redirect Message Types1').item.json.image && $('Redirect Message Types1').item.json.image.caption || ''}}\n{{ $('Redirect Message Types1').item.json.audio && $('Redirect Message Types1').item.json.audio.caption || ''}}"
            }
          ]
        },
        "options": {}
      },
      "id": "916244a2-e286-4cd2-afc5-775a4d1773e1",
      "name": "Get User's Message2",
      "type": "n8n-nodes-base.set",
      "position": [
        2640,
        1776
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.body.conversation.messages[0].attachments[0].file_type == 'audio'}}",
                    "rightValue": "audio",
                    "id": "39210c4d-d9fb-4fb0-a92f-754e018c4ec9"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Audio Message"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "05b30af4-967b-4824-abdc-84a8292ac0e5",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.body.conversation.messages[0].attachments[0].file_type == 'image' }}",
                    "rightValue": ""
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Image Message"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Text Message"
        }
      },
      "id": "9c0c4269-581a-40dd-961f-d5958292ef1b",
      "name": "Redirect Message Types1",
      "type": "n8n-nodes-base.switch",
      "position": [
        1824,
        1760
      ],
      "typeVersion": 3.2
    },
    {
      "parameters": {
        "amount": 0
      },
      "id": "e712eecf-9830-47ff-9d26-cdaf6566fa17",
      "name": "Get Text1",
      "type": "n8n-nodes-base.wait",
      "position": [
        2208,
        2048
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2ec0e573-373b-4692-bfae-86b6d3b9aa9a",
              "name": "text",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        },
        "options": {}
      },
      "id": "0189ac1d-cd4d-4f38-abdf-7aae18abbd88",
      "name": "Format Response",
      "type": "n8n-nodes-base.set",
      "position": [
        2640,
        1504
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        2480,
        1504
      ],
      "id": "2bf9d8e1-8bc0-4064-8de2-79f05177e8e1",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d990cbd6-a408-4ec4-a889-41be698918d9",
              "name": "message_type",
              "type": "string",
              "value": "={{ $json.body.content_type }}"
            },
            {
              "id": "23b785c3-f38e-4706-80b7-51f333bba3bd",
              "name": "message_text",
              "type": "string",
              "value": "={{ $json.body.content }}"
            },
            {
              "id": "6e83f9a7-cf75-4182-b2d2-3151e8af76b9",
              "name": "from",
              "type": "string",
              "value": "={{ $json.body.conversation.contact_inbox.source_id }}"
            },
            {
              "id": "da4b602a-28ca-4b0d-a747-c3d3698c3731",
              "name": "message_caption",
              "type": "string",
              "value": "={{ $('Redirect Message Types1').item.json.video && $('Redirect Message Types1').item.json.video.caption || '' }}\n{{ $('Redirect Message Types1').item.json.image && $('Redirect Message Types1').item.json.image.caption || ''}}\n{{ $('Redirect Message Types1').item.json.audio && $('Redirect Message Types1').item.json.audio.caption || ''}}"
            }
          ]
        },
        "options": {}
      },
      "id": "8ac59f8f-91b6-4210-947a-9a4e47f3df19",
      "name": "Get User's Message3",
      "type": "n8n-nodes-base.set",
      "position": [
        2640,
        2048
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "chatgpt-4o-latest",
          "mode": "list",
          "cachedResultName": "CHATGPT-4O-LATEST"
        },
        "text": "Eres un asistente de un doctor, tu trabajo es analizar la imagen a la perfeccion y da especificaciones de lo que hay en la imagen, para que un doctor pueda entender mejor la imagen gracias a tus descripciones.\nNo separes los textos, solo responde corto y ya.\n\nFormato de respuesta:\n\nEl cliente mostro una imagen donde se le ve tal cosa y parece que tiene o se le ve algo\n\nResumido",
        "inputType": "base64",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        2480,
        1776
      ],
      "id": "729bfa1f-d463-4ad7-affb-44c35778f38b",
      "name": "Analiza Imagenes1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "push",
        "list": "={{ $('Entra Nuevo Mensaje').item.json.body.conversation.contact_inbox.source_id }}",
        "messageData": "={{ $json.mensaje_final }}",
        "tail": true
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        3152,
        1776
      ],
      "id": "15668b60-65cd-4d6b-90eb-0d7841827822",
      "name": "Redis3",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "let mensaje_final = \"\";\n\n// Eval\u00faa en orden de prioridad cu\u00e1l tiene contenido\nif ($json.text && $json.text.trim() !== \"\") {\n  mensaje_final = $json.text;\n} else if ($json.audio_text && $json.audio_text.trim() !== \"\") {\n  mensaje_final = $json.audio_text;\n} else if ($json.message_text && $json.message_text.trim() !== \"\") {\n  mensaje_final = $json.message_text;\n} else {\n  try {\n    const imagenCaption = $('Numero TEST ACS1').item.json.messages?.[0]?.image?.caption;\n    if (imagenCaption && imagenCaption.trim() !== \"\") {\n      mensaje_final = imagenCaption;\n    }\n  } catch (e) {\n    // No hacer nada si el nodo est\u00e1 vac\u00edo o falla\n  }\n}\n\n// Retornar siempre con la misma clave\nreturn {\n  json: {\n    mensaje_final\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2976,
        1776
      ],
      "id": "26585ded-f5cd-4652-a17f-23cbc5524e32",
      "name": "Union de mensajes1"
    },
    {
      "parameters": {
        "operation": "get",
        "propertyName": "mensajes",
        "key": "={{ $('Entra Nuevo Mensaje').item.json.body.conversation.messages[0].conversation.contact_inbox.source_id }}",
        "options": {}
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        3472,
        1776
      ],
      "id": "926d941c-8119-4bb4-96ad-7a459bc3b98a",
      "name": "Redis4",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "1d463773-5493-45a2-987a-2b8a971d73c8",
              "leftValue": "={{ $json.mensajes.last() }}",
              "rightValue": "={{ $('Union de mensajes1').item.json.mensaje_final }}",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        3616,
        1776
      ],
      "id": "fd40c4f2-ced3-4ba0-adda-cdbdecac0ee2",
      "name": "If1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        3776,
        1968
      ],
      "id": "f963f927-a4d7-4d62-aa44-e3ddde0791e3",
      "name": "No Operation, do nothing1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "cd304572-0dd7-4b1f-9d85-1d3c5343a6b1",
              "name": "Mensaje",
              "value": "={{ $json.mensajes.join() }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        3776,
        1776
      ],
      "id": "cfc129f5-9374-47f1-8dbe-afd77c11fdc0",
      "name": "Array de mensajes1"
    },
    {
      "parameters": {
        "operation": "delete",
        "key": "={{ $('Entra Nuevo Mensaje').item.json.body.conversation.contact_inbox.source_id }}"
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        3920,
        1776
      ],
      "id": "47b66531-c6db-4324-8deb-4288ecf976e2",
      "name": "Redis5",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Obt\u00e9n el texto original\nlet texto = $input.first().json.text;\n\n// Reemplaza todos los casos de **Texto** por *Texto*\ntexto = texto.replace(/\\*\\*(.*?)\\*\\*/g, '*$1*');\n\n// Elimina todos los s\u00edmbolos #\ntexto = texto.replace(/#/g, '');\n\n// Devuelve el resultado\nreturn {\n  json: {\n    output: texto\n  }\n};\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        4480,
        1776
      ],
      "id": "e77e453d-5332-47b2-a438-10a4520f732f",
      "name": "Limpiar Mensaje1"
    },
    {
      "parameters": {
        "amount": 12
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3312,
        1776
      ],
      "id": "e4eef8d1-fd05-4ef2-9474-1a251f7ce9d6",
      "name": "Wait1"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "Tu enlace fe flowise",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"question\": \"{{ $json.mensaje.replace(/\\n/g, ' ') }}\",\n  \"overrideConfig\": {\n    \"sessionId\": \"{{ $('Entra Nuevo Mensaje').item.json.body.conversation.contact_inbox.source_id }}\"\n  }\n}\n",
        "options": {
          "allowUnauthorizedCerts": true
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4256,
        1776
      ],
      "id": "293f6afc-419a-4695-9008-ff41d17e8b8b",
      "name": "HTTP Request",
      "retryOnFail": true
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=Tu enlace de chatwoot/api/v1/accounts/{{ $('Entra Nuevo Mensaje').item.json.body.conversation.messages[0].account_id }}/conversations/{{ $('Entra Nuevo Mensaje').item.json.body.conversation.messages[0].conversation_id }}/messages\n\n",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "api_access_token",
              "value": "Lfas6k8QJrGPHpdD3TQXnYsD"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "content",
              "value": "={{ $json.output }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4640,
        1776
      ],
      "id": "750debd0-a854-4f37-b4f5-683272e2c923",
      "name": "Enviar Mensaje",
      "retryOnFail": true
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1520,
        2000
      ],
      "id": "ae219a37-8505-4f4e-9f27-04e876df476e",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "df3cc619-934d-4d62-9bff-db91d69107e5",
              "leftValue": "={{ $json.body.conversation.messages[0].sender.type === 'agent_bot' }}",
              "rightValue": "contact",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1328,
        1808
      ],
      "id": "709b8c52-d281-4a48-a2e7-3dc0d8fb0a33",
      "name": "Agente IA o Humano"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.body.sender.custom_attributes.bot || \"On\"}}",
                    "rightValue": "On",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "ab26fedb-0084-4da5-bc2b-6e68da36b114"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "On"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f4448833-b7b8-43a9-9110-c9cc6ba8c044",
                    "leftValue": "={{ $json.body.sender.custom_attributes.bot || \"On\"}}",
                    "rightValue": "Off",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Off"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        1584,
        1792
      ],
      "id": "545fe189-a6bf-46d7-8fd3-dd3ab1d31eee",
      "name": "Bot On or Off"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "c954c6cb-f6f5-4733-8fbd-9b5dd1e439fa",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        1056,
        1808
      ],
      "id": "f54e6c30-561a-40c0-a532-c9679f43fb6f",
      "name": "Entra Nuevo Mensaje"
    },
    {
      "parameters": {
        "jsCode": "// Obtenemos la fecha y hora actual\nconst ahora = new Date();\n\n// Formateamos la hora local (HH:MM:SS)\nconst hora = ahora.toLocaleTimeString('es-NI', {\n  timeZone: 'America/Managua',\n  hour12: false\n});\n\n// Formateamos la fecha local (DD/MM/YYYY)\nconst fecha = ahora.toLocaleDateString('es-NI', {\n  timeZone: 'America/Managua'\n});\n\n// Mensaje base\nconst mensaje = $input.first().json.Mensaje;\n\n// Concatenamos mensaje con fecha y hora\nconst mensajeFinal = `${mensaje} --- No le prestes atenci\u00f3n a la fecha y a la hora, ya que esa se utilizar\u00e1 para nada mas cuando el usuario quiera agendar una cita. Fecha y Hora del mensaje ${fecha} a la ${hora} (hora actual)`;\n\n// Retornamos todo como campos separados\nreturn [{\n  mensaje: mensajeFinal,\n  fecha,\n  hora\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        4080,
        1776
      ],
      "id": "4d88001c-33c9-4b4f-aa94-11ca73a35fde",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "Tu enlace de flowise/api/v1/prediction/23722019-35d2-4f66-be2d-1d77ca9a3202",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"question\": \"{{ $json.mensajeFinal.replace(/\\n/g, ' ') }}\",\n  \"overrideConfig\": {\n    \"sessionId\": \"{{ $('Entra Nuevo Mensaje').item.json.body.conversation.contact_inbox.source_id }}\"\n  }\n}\n",
        "options": {
          "allowUnauthorizedCerts": true
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4704,
        2000
      ],
      "id": "307305d0-3a7c-4c5e-8f6f-6f3b2e36bd33",
      "name": "Seguimiento de Pacientes - Agente de Flowise"
    },
    {
      "parameters": {
        "jsCode": "const mensajePaciente = $('Entra Nuevo Mensaje').first().json.body.content; \nconst mensajeAgente = $input.first().json.text; \nconst numeroTelefono = $('Entra Nuevo Mensaje').first().json.body.conversation.messages[0].sender.phone_number;\n\n// Crear texto final combinando toda la informaci\u00f3n\nconst mensajeFinal = `\nEste es el mensaje que envi\u00f3 el paciente: ${mensajePaciente}.\n\nEste es el mensaje que respondi\u00f3 la atenci\u00f3n al cliente: ${mensajeAgente}.\n\nN\u00famero del paciente: ${numeroTelefono}.\n`;\n\n// Retornar como JSON para que lo lean otros nodos (por ejemplo, OpenAI)\nreturn {\n  json: {\n    mensajeFinal\n  }\n};\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        4512,
        2000
      ],
      "id": "60cac7c4-8a0a-482f-8a74-17270f97e2c4",
      "name": "Unir Informacion del cliente"
    },
    {
      "parameters": {
        "jsCode": "// Obtener el texto del input\nlet texto = $input.first().json.text;\n\n// --- \ud83e\uddf9 LIMPIEZA DEL TEXTO ---\n// Quita los posibles bloques markdown (```json, ```), saltos innecesarios y espacios\ntexto = texto\n  .replace(/```json/g, '')\n  .replace(/```/g, '')\n  .replace(/\\n/g, '')\n  .trim();\n\n// --- \ud83d\udd04 CONVERTIR TEXTO EN JSON ---\nlet datos;\ntry {\n  datos = JSON.parse(texto);\n} catch (error) {\n  // Si no es un JSON v\u00e1lido, devolvemos mensaje de error\n  return {\n    json: {\n      error: \"El texto no es un JSON v\u00e1lido\",\n      texto_original: texto\n    }\n  };\n}\n\nlet todosValidos;\n\n// --- \ud83d\udd0d VALIDACIONES CON RETURN DENTRO DEL IF ---\nif (datos.Agendo === true) {\n  const otrasClaves = Object.keys(datos).filter(k => k !== 'Agendo');\n  todosValidos = otrasClaves.every(k => datos[k] !== false && datos[k] !== '');\n}\n\nlet Agendo = false;\n\nif (todosValidos) {\n    // \u2705 Si agend\u00f3 y todo est\u00e1 correcto\n    return {\n      json: {\n        ...datos,\n        resultado: \"Agend\u00f3 la cita correctamente\"\n      }\n    };\n  } if (!todosValidos) {\n    // \u26a0\ufe0f Si agend\u00f3 pero faltan datos\n    return {\n      json: {\n        Agendo\n      }\n    };\n  }\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        4896,
        2000
      ],
      "id": "b31bf75f-05a0-4190-91e1-d353c6146278",
      "name": "Covert To Json"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "62ca1100-339c-462b-87b7-b2b23a2ec53f",
              "leftValue": "={{ $json.Agendo }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        5072,
        2000
      ],
      "id": "1714a1f8-5095-458c-bbee-b0b6e52cb944",
      "name": "If"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        5280,
        2080
      ],
      "id": "b3c27078-ed7f-4966-82a5-884f001131cd",
      "name": "No Operation, do nothing2"
    },
    {
      "parameters": {
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "value": "dEH1ICpt9Nn8MTOQ",
          "mode": "list",
          "cachedResultName": "Agenda Calendario Cl\u00ednica Oasis",
          "cachedResultUrl": "/projects/LqabXlRaK6LbD2Zq/datatables/dEH1ICpt9Nn8MTOQ"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "Numero",
              "keyValue": "={{ $json['Numero de telefono'] }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Nombre": "={{ $json['Nombre del paciente'] }}",
            "Numero": "={{ $json['Numero de telefono'] }}",
            "Cita": "={{ $json['Tipo de cita m\u00e9dica'] }}",
            "Hora": "={{ $json['Hora de la cita'] }}",
            "Fecha": "={{ $json['Fecha de la cita'] }}",
            "Cede": "={{ $json.Sede }}",
            "Seguimiento": false
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Nombre",
              "displayName": "Nombre",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "Numero",
              "displayName": "Numero",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "Cita",
              "displayName": "Cita",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "Fecha",
              "displayName": "Fecha",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "Hora",
              "displayName": "Hora",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "Cede",
              "displayName": "Cede",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "Seguimiento",
              "displayName": "Seguimiento",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1,
      "position": [
        5280,
        1888
      ],
      "id": "99f499dd-c578-44f3-aed5-e5a7d7955d00",
      "name": "Upsert row(s)"
    }
  ],
  "connections": {
    "Get Audio URL1": {
      "main": [
        [
          {
            "node": "Download Audio1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Image URL1": {
      "main": [
        [
          {
            "node": "Download Image1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Audio1": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image1": {
      "main": [
        [
          {
            "node": "Analiza Imagenes1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get User's Message2": {
      "main": [
        [
          {
            "node": "Union de mensajes1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redirect Message Types1": {
      "main": [
        [
          {
            "node": "Get Audio URL1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Image URL1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Text1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Text1": {
      "main": [
        [
          {
            "node": "Get User's Message3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Union de mensajes1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get User's Message3": {
      "main": [
        [
          {
            "node": "Union de mensajes1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analiza Imagenes1": {
      "main": [
        [
          {
            "node": "Get User's Message2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis3": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Union de mensajes1": {
      "main": [
        [
          {
            "node": "Redis3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis4": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Array de mensajes1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Array de mensajes1": {
      "main": [
        [
          {
            "node": "Redis5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis5": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limpiar Mensaje1": {
      "main": [
        [
          {
            "node": "Enviar Mensaje",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Redis4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Limpiar Mensaje1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Unir Informacion del cliente",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Operation, do nothing": {
      "main": [
        []
      ]
    },
    "Agente IA o Humano": {
      "main": [
        [
          {
            "node": "Bot On or Off",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bot On or Off": {
      "main": [
        [
          {
            "node": "Redirect Message Types1",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Entra Nuevo Mensaje": {
      "main": [
        [
          {
            "node": "Agente IA o Humano",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Unir Informacion del cliente": {
      "main": [
        [
          {
            "node": "Seguimiento de Pacientes - Agente de Flowise",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Seguimiento de Pacientes - Agente de Flowise": {
      "main": [
        [
          {
            "node": "Covert To Json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Covert To Json": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Upsert row(s)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/Managua",
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": "R0mC32a3gOT7Bjsy",
    "availableInMCP": false
  },
  "versionId": "601a055b-6fbe-4c8b-a6fe-40c5e41a8646",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "mWt5p5jCTyBDfTrD",
  "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

Agente IA, WhatsApp, Flowise, N8N Y Chatwoot. Uses whatsApp, httpRequest, openAi, redis. Webhook trigger; 33 nodes.

Source: https://gist.github.com/marketingfamoso/d18face298cee0d78311c0395b512b95 — 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

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

OpenAI, Redis, HTTP Request +8
AI & RAG

Transform your salon/service business with this streamlined WhatsApp automation system featuring Claude integration, zero-setup database management, and intelligent conversation handling. Claude MCP I

WhatsApp Trigger, WhatsApp, Redis +11
AI & RAG

Agent: IPTV (instance_e2165d22_1762376395079). Uses openAi, redis, supabase, httpRequest. Webhook trigger; 56 nodes.

OpenAI, Redis, Supabase +7
AI & RAG

'Elena AI' is a powerful n8n workflow that transforms your automation platform into a full-fledged, multi-agent AI hub. 🤖✨ By combining Redis state management with specialized “tool” sub-workflows, yo

Redis, HTTP Request, Supabase +7
AI & RAG

This workflow transforms natural language queries into research reports through a five-stage AI pipeline. When triggered via webhook (typically from Google Sheets using the companion [](https://gist.g

Redis, Agent, Output Parser Structured +7