AutomationFlowsAI & RAG › Fluxo Nia App - Agendamento Multi-tenant

Fluxo Nia App - Agendamento Multi-tenant

Fluxo Nia App - Agendamento Multi-tenant. Uses redis, httpRequest, openAi, whatsApp. Webhook trigger; 52 nodes.

Webhook trigger★★★★★ complexityAI-powered52 nodesRedisHTTP RequestOpenAIWhatsAppAgentGoogle Gemini ChatMemory Redis ChatMcp Client Tool
AI & RAG Trigger: Webhook Nodes: 52 Complexity: ★★★★★ AI nodes: yes Added:
Fluxo Nia App - Agendamento Multi-tenant — n8n workflow card showing Redis, HTTP Request, OpenAI integration

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": "Fluxo Nia App - Agendamento Multi-tenant",
  "nodes": [
    {
      "parameters": {
        "path": "coexistencia",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -1712,
        400
      ],
      "id": "96050944-23fa-4080-bf03-119dc2133758",
      "name": "Webhook"
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{$json.query[\"hub.challenge\"]}}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        -1440,
        400
      ],
      "id": "058b5207-d05d-423a-8eda-709dde733aef",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "coexistencia",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -1808,
        560
      ],
      "id": "cecd52af-bfc3-47cf-9141-c2ed9b048383",
      "name": "Webhook1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e72db4ca-f7e7-4e1a-9128-d24226d773a0",
              "name": "debounce-resposta",
              "value": "5",
              "type": "string"
            },
            {
              "id": "af14c48f-8d3e-40dc-bb22-48b914f12af0",
              "name": "tokenMeta",
              "value": "={{ $('Fetch Tenant Info').item.json.meta_token }}",
              "type": "string"
            },
            {
              "id": "c7ce8a2c-d68e-42a6-8c6f-82c74c220d4c",
              "name": "messageContent",
              "value": "={{ $json.body.entry[0].changes[0].value.messages[0].text.body }}",
              "type": "string"
            },
            {
              "id": "ced8863c-53a8-4431-acd1-12a332cfaf27",
              "name": "wa_id",
              "value": "={{ $json.body.entry[0].changes[0].value.messages[0].from }}",
              "type": "string"
            },
            {
              "id": "d0104f6b-28c3-4963-89c7-31b7b463fa8b",
              "name": "fileType",
              "value": "={{ $json.body.entry[0].changes[0].value.messages[0].type }}",
              "type": "string"
            },
            {
              "id": "82bd6cad-2650-4bcc-be79-c2c4d5c39c23",
              "name": "contactName",
              "value": "={{ $json.body.entry[0].changes[0].value.contacts[0].profile.name }}",
              "type": "string"
            },
            {
              "id": "b3471cf1-7c9f-4249-8eba-595d9628ae8c",
              "name": "imageID",
              "value": "={{$json[\"body\"][\"entry\"][0][\"changes\"][0][\"value\"][\"messages\"][0][\"image\"][\"id\"]}}",
              "type": "string"
            },
            {
              "id": "a861a202-0282-4534-9457-f99dac74f596",
              "name": "audioID",
              "value": "={{ $json.body.entry[0].changes[0].value.messages[0].audio.id }}",
              "type": "string"
            },
            {
              "id": "88c78393-0c63-4f6f-9c88-3036bdea21c5",
              "name": "documentID",
              "value": "={{ $json.body.entry[0].changes[0].value.messages[0].document.id }}",
              "type": "string"
            },
            {
              "id": "db50ebf8-897d-4202-88f0-3e1b5a47b9e2",
              "name": "messageStatus",
              "value": "={{ $json.body.entry[0].changes[0].value.statuses[0].status }}",
              "type": "string"
            },
            {
              "id": "871988a6-dcef-4a6d-90ea-a1f41d0aa4b3",
              "name": "myPhoneNumber",
              "value": "={{ $json.body.entry[0].changes[0].value.metadata.display_phone_number }}",
              "type": "string"
            },
            {
              "id": "013395ac-1cd2-4597-93a0-a6c81a20b10b",
              "name": "category",
              "value": "={{ $json.body.entry[0].changes[0].value.statuses[0].pricing.category }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1552,
        560
      ],
      "id": "20d02e24-b16e-489b-9600-6f35d945fb7b",
      "name": "Vari\u00e1veis Globais"
    },
    {
      "parameters": {
        "operation": "get",
        "propertyName": "block",
        "key": "={{ $('Vari\u00e1veis Globais').item.json.myPhoneNumber }}_block",
        "options": {}
      },
      "id": "c32cd04b-a41b-47d7-8acf-218f3a51c292",
      "name": "VALIDA STATUS",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -896,
        608
      ],
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "set",
        "key": "={{ $('Vari\u00e1veis Globais').item.json.myPhoneNumber }}_block",
        "value": "true",
        "keyType": "string",
        "expire": true
      },
      "id": "13b84844-fc53-438e-b733-608a185f118d",
      "name": "DEBOUNCE",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -1024,
        208
      ],
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.block }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "empty",
                      "singleValue": true
                    },
                    "id": "7b08b945-3072-4a3b-a471-ce58cd3e0eec"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "SIGA"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "3ef0e01c-cc14-4663-bb4d-2905b350c3ab",
                    "leftValue": "={{ $json.block }}",
                    "rightValue": "true",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "PARE"
            }
          ]
        },
        "options": {}
      },
      "id": "0a900cbd-52e2-4fe4-9fd1-11add2e32c63",
      "name": "Switch PARE OU SIGA",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        -624,
        608
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "leftValue": "={{ $('Vari\u00e1veis Globais').item.json.messageStatus }}",
                    "rightValue": "outcoming",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "id": "51777fe9-ec84-4796-9d74-ffe890dfe190"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "fromMe"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "23a9df28-5a4e-4341-b35b-fbd9c82eee8c",
                    "leftValue": "={{ new Date().toLocaleTimeString('pt-BR', {\n  timeZone: 'America/Sao_Paulo',\n  hour: '2-digit',\n  minute: '2-digit',\n  hour12: false\n}) }}",
                    "rightValue": "={{ $('Fetch Tenant Info').item.json.business_hours_end || '19:00' }}",
                    "operator": {
                      "type": "dateTime",
                      "operation": "notExists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "stopbytime"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "e73fcbec-a30a-47fe-b526-a31ca01a0b97",
                    "leftValue": "={{ ['domingo', 'segunda', 'ter\u00e7a', 'quarta', 'quinta', 'sexta', 's\u00e1bado'][new Date().getDay()] }}",
                    "rightValue": "={{ $('Fetch Tenant Info').item.json.closed_day || 'domingo' }}",
                    "operator": {
                      "type": "string",
                      "operation": "notExists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "stopbydate"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "cf928e06-5062-459f-9772-c348c6c170a1",
                    "leftValue": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "fromUser"
            }
          ]
        },
        "options": {}
      },
      "id": "01fb41d2-5751-4e12-a87c-0ea4d85ed474",
      "name": "Switch4",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        -1296,
        528
      ],
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "83f43975-f24a-4d99-a9e4-604734180485",
                    "leftValue": "={{ $('Vari\u00e1veis Globais').item.json.fileType }}",
                    "rightValue": "audio",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "audio"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "b6eedcac-3d4c-4e6e-8d3e-5348b5495fe6",
                    "leftValue": "={{ $('Vari\u00e1veis Globais').item.json.fileType }}",
                    "rightValue": "image",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Imagem"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "3a1b10ae-8a03-465a-80a4-e51efdae6f6c",
                    "leftValue": "={{ $('Vari\u00e1veis Globais').item.json.fileType }}",
                    "rightValue": "document",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "PDF"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "b5d1faa3-6ed2-4801-930b-6fc03839d8dd",
                    "leftValue": "={{ $('Vari\u00e1veis Globais').item.json.messageContent }}",
                    "rightValue": "null",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Texto"
            }
          ]
        },
        "options": {}
      },
      "id": "31658ba1-0416-42d2-b160-06dd1e5ddec9",
      "name": "Tipo da Mensagem",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        -336,
        560
      ]
    },
    {
      "parameters": {
        "url": "=https://graph.facebook.com/v24.0/{{ $('Vari\u00e1veis Globais').item.json.imageID }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Vari\u00e1veis Globais').item.json.tokenMeta }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        176
      ],
      "id": "eba1697b-ee30-401f-a664-d3c33abe8ec9",
      "name": "getMetadados"
    },
    {
      "parameters": {
        "url": "={{ $json.url }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Vari\u00e1veis Globais').item.json.tokenMeta }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        192,
        176
      ],
      "id": "13be2d01-d38c-44fa-af25-f6573eaee0da",
      "name": "baixaImagem"
    },
    {
      "parameters": {
        "url": "=https://graph.facebook.com/v24.0/{{ $('Vari\u00e1veis Globais').item.json.audioID }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Vari\u00e1veis Globais').item.json.tokenMeta }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        0
      ],
      "id": "558fd261-c993-48aa-b516-5c4a999129c8",
      "name": "getMetadados1"
    },
    {
      "parameters": {
        "url": "={{ $json.url }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Vari\u00e1veis Globais').item.json.tokenMeta }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        192,
        0
      ],
      "id": "b944e6a0-a7de-497a-a36a-7f1746ca2d46",
      "name": "baixaAudio"
    },
    {
      "parameters": {
        "url": "=https://graph.facebook.com/v24.0/{{ $('Vari\u00e1veis Globais').item.json.documentID }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Vari\u00e1veis Globais').item.json.tokenMeta }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        352
      ],
      "id": "0a60c82b-c41f-4ad7-95f2-5bd2076d77c9",
      "name": "getMetadados2"
    },
    {
      "parameters": {
        "url": "={{ $json.url }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Vari\u00e1veis Globais').item.json.tokenMeta }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        192,
        352
      ],
      "id": "8188d0e0-05a0-4ec2-8335-fb64118ec1b5",
      "name": "baixaPDF"
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "binaryPropertyName": "=data",
        "options": {
          "language": "pt"
        }
      },
      "id": "3a275d53-fd50-478a-9db7-4e0bd642232e",
      "name": "Transcribe a recording",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.3,
      "position": [
        432,
        0
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "waitBetweenTries": 5000,
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini-2024-07-18",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI-2024-07-18"
        },
        "text": "Descreva toda imagem, \u00e9 importante n\u00e3o ter acentos e nem hifens na descri\u00e7\u00e3o",
        "inputType": "base64",
        "options": {}
      },
      "id": "a13b0125-04b7-4752-bed2-241792b141d0",
      "name": "Analyze image",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.4,
      "position": [
        432,
        176
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "waitBetweenTries": 5000,
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "pdf",
        "binaryPropertyName": "=data",
        "options": {}
      },
      "id": "2c608b1f-a29b-4d85-9178-b3b89727c07e",
      "name": "Extrair Dados .pdf",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        432,
        352
      ]
    },
    {
      "parameters": {
        "numberInputs": 3
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        720,
        160
      ],
      "id": "1318d815-5e3c-4417-96cb-eaa194175cb3",
      "name": "Merge1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e73c950c-7e2b-481c-b564-1b903b3e9084",
              "name": "mensagemTextoDireto",
              "value": "={{ $('Puxa as Mensagens').item.json.menssageText.join('\\n') }}",
              "type": "string"
            },
            {
              "id": "dac27915-2ad9-44d1-a1c7-868e900cd4c4",
              "name": "mobile",
              "value": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "f91527d5-3eda-42a6-bbe4-85ce8d5a9ef3",
      "name": "Trata a Mensagem",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2064,
        624
      ],
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "dac27915-2ad9-44d1-a1c7-868e900cd4c4",
              "name": "mobile",
              "value": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
              "type": "string"
            },
            {
              "id": "52924d5a-8f77-4320-bf9e-7304a6e8f89b",
              "name": "mensagemMediaTranscrita",
              "value": "={{ $('Puxa as Mensagens Trasncritas').item.json.mensagemTranscrita.join('\\n') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "cb6bc1ff-8876-4135-883e-8eb417b3381a",
      "name": "Trata a Mensagem Transcrita",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2048,
        160
      ],
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "operation": "push",
        "list": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
        "messageData": "={{ $json.mensagem }}",
        "tail": true
      },
      "id": "dae2156d-d9cc-449d-af07-a6caf021c79d",
      "name": "Fila as mensagens transcritas",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        1152,
        176
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "waitBetweenTries": 5000,
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "push",
        "list": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
        "messageData": "={{ $('mensagemTexto').item.json.mensagem }}",
        "tail": true
      },
      "id": "ec770016-9952-4f10-87b6-55a40bd35188",
      "name": "Fila as mensagens de texto direto",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        1152,
        640
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "waitBetweenTries": 5000,
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": "={{ $('Vari\u00e1veis Globais').item.json['debounce-resposta'] }}"
      },
      "id": "8b88c8b2-27d6-4125-982c-29eb53ef5a67",
      "name": "Debounce Resposta1",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1376,
        176
      ]
    },
    {
      "parameters": {},
      "id": "29b1f3bc-3c0d-4500-a0fa-81737eaa13ad",
      "name": "No Operation, do nothing1",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1808,
        16
      ]
    },
    {
      "parameters": {
        "amount": "={{ $('Vari\u00e1veis Globais').item.json['debounce-resposta'] }}"
      },
      "id": "6ec487d5-d397-466c-aa04-d0daeaa4f611",
      "name": "Debounce Resposta",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1376,
        640
      ]
    },
    {
      "parameters": {},
      "id": "da22d638-d0e7-4cee-a177-d33f94e52cf8",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1808,
        464
      ]
    },
    {
      "parameters": {
        "operation": "get",
        "propertyName": "menssageText",
        "key": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
        "options": {}
      },
      "id": "3c2bd2f6-45ec-4515-9ca6-6e90d6702929",
      "name": "Puxa as Mensagens",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        1584,
        640
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "waitBetweenTries": 5000,
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "a3f927d9-6a06-4be0-80f9-1104f2491042",
              "leftValue": "={{ $json.menssageText.last() }}",
              "rightValue": "={{ $('mensagemTexto').item.json.mensagem }}",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "1091d01d-43bc-427a-9bfc-1ea3b1022f7e",
      "name": "If1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.1,
      "position": [
        1808,
        640
      ],
      "alwaysOutputData": false,
      "retryOnFail": false,
      "maxTries": 5,
      "waitBetweenTries": 5000,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "operation": "get",
        "propertyName": "mensagemTranscrita",
        "key": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
        "options": {}
      },
      "id": "2cd3ae6a-1398-4ff2-904e-b7da29ecb755",
      "name": "Puxa as Mensagens Trasncritas",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        1584,
        176
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "waitBetweenTries": 5000,
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "a3f927d9-6a06-4be0-80f9-1104f2491042",
              "leftValue": "={{ $json.mensagemTranscrita.last() }}",
              "rightValue": "={{ $('mensagemM\u00eddia').item.json.mensagem }}",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "a82597d2-8c58-4a01-b756-28995c3d3178",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.1,
      "position": [
        1808,
        176
      ],
      "alwaysOutputData": false,
      "retryOnFail": false,
      "maxTries": 5,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "operation": "delete",
        "key": "={{ $json.mobile }}"
      },
      "id": "4a25d168-a3c1-491e-8f54-e4951667b568",
      "name": "Redis",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        2656,
        608
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "waitBetweenTries": 5000,
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "35fa457c-66ec-469e-bcff-e138580a8137",
              "name": "mensagem",
              "value": "={{ $('Vari\u00e1veis Globais').item.json.messageContent }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "fb3c6f2c-2b3a-4e29-ac5d-7158063319c1",
      "name": "mensagemTexto",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        912,
        640
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b6cd097d-3a3a-4cdc-a6f1-13c118a4618c",
              "name": "mensagem",
              "value": "={{\n  $if(\n    $(\"Analyze image\").isExecuted,\n    $(\"Analyze image\").item.json.content,\n    $if(\n      $(\"Extrair Dados .pdf\").isExecuted,\n      $(\"Extrair Dados .pdf\").item.json.text,\n      $if(\n        $(\"Transcribe a recording\").isExecuted,\n        $(\"Transcribe a recording\").item.json.text,\n        \"\"\n      )\n    )\n  )\n}}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "ee4cbdd0-3200-4e08-94ae-f9ec3ce0499a",
      "name": "mensagemM\u00eddia",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        944,
        176
      ]
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        2416,
        608
      ],
      "id": "2f7c1180-0d7d-423d-b234-5a76f38e8f0f",
      "name": "Merge"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "leftValue": "={{\n  (() => {\n    const mensagens = Array.isArray($json.mensagens)\n      ? $json.mensagens.join(\" \")\n      : ($json.mensagens || $json.output || \"\");\n\n    return mensagens &&\n      mensagens.trim() !== '' &&\n      mensagens !== '\\n\\n' &&\n      !mensagens.toLowerCase().includes('.mp3') &&\n      (\n        // Permite link do Mercado Pago\n        mensagens.toLowerCase().includes('mercadopago.com.br/checkout') ||\n        (\n          // Caso n\u00e3o seja URL sozinho\n          !mensagens.replace(/\\s+/g, '').isUrl()\n        )\n      );\n  })()\n}}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "id": "e9750bfc-23e1-4879-b53a-ccf9fbeda7fb"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Texto"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "a129b451-7650-4cf1-a7ec-6853f3723d48",
                    "leftValue": "={{ ( ($json.output ?? $json.mensagens ?? '').match(/https?:\\/\\/\\S+\\.pdf(?=$|[?#])/i) ) !== null }}",
                    "rightValue": ".pdf",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "pdf"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "bd6c6ac4-8ebd-4d14-9935-1fd270106c48",
                    "leftValue": "={{ ( ($json.output ?? $json.mensagens ?? '').match(/https?:\\/\\/\\S+\\.(?:png|jpe?g)(?=$|[?#])/i) ) !== null }}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Imagem"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "8a8907db-2f29-4fc3-a50d-264a2c5d015e",
                    "leftValue": "={{ $json.mensagens.match(/https:\\/\\/.*\\.(wmv|mp4|mov|mkv)/g)}}",
                    "rightValue": "=",
                    "operator": {
                      "type": "array",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "V\u00cdDEO"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "e6a4f0f2-24c0-47b0-947c-57b94eb021db",
                    "leftValue": "={{ $json.mensagens.match(/https:\\/\\/.*\\.mp3/g) || [] }}",
                    "rightValue": "true",
                    "operator": {
                      "type": "array",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "mp3"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "723f0c82-c409-41bb-a9db-9764fd4c19e4",
                    "leftValue": "",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Vazio"
            }
          ]
        },
        "options": {}
      },
      "id": "abcd25d0-abcb-432b-9ebd-26b1067c30aa",
      "name": "Switch1",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        2160,
        1280
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1888,
        976
      ],
      "id": "3c2a285d-bbf8-474e-8f5a-9eba55f4259d",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "fieldToSplitOut": "mensagens",
        "options": {}
      },
      "id": "b316895a-e333-417d-84ac-78e96312a978",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1568,
        976
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "3c751e2e-d0d2-4a77-91cd-6500be77b9fd",
              "name": "mensagens",
              "value": "={{\n(() => {\n  // Etapa 1 \u2013 texto limpo + convers\u00e3o para *negrito*\n  const texto = (\n    Array.isArray($json.output)\n      ? $json.output[0]?.text || ''\n      : $json.output\n  )\n    .replace(/###/g, '')                     // remove cabe\u00e7alhos\n    .replace(/`/g, '')                       // remove crases\n    .replace(/(^|\\n)\\s*\\*\\s+/g, '$1')        // remove bullet \"* \"\n    // *italics*  \u279c  *negrito*\n    .replace(/(^|[^*])\\*(?!\\*)([^*]+?)\\*(?!\\*)/g, '$1*$2*')\n    // **bold**   \u279c  *negrito*\n    .replace(/\\*\\*(.+?)\\*\\*/g, '*$1*');\n\n  // Etapa 2 \u2013 separa links e junta trechos\n  const partes = texto\n    .split(/(https:\\/\\/[^\\s]+)/gi)\n    .map(p => p.trim())\n    .filter(p => p && p !== '\\n\\n');\n\n  const resultado = [];\n  partes.forEach(parte => {\n    if (parte.startsWith('https://')) {\n      resultado.push(parte);\n    } else {\n      const ultimo = resultado[resultado.length - 1];\n      if (ultimo && !ultimo.startsWith('https://')) {\n        resultado[resultado.length - 1] = ultimo + ' ' + parte;\n      } else {\n        resultado.push(parte);\n      }\n    }\n  });\n\n  // Etapa 3 \u2013 remove colchetes/par\u00eanteses e ponto final\n  return [...new Set(\n    resultado.flatMap(msg =>\n      msg.split('\\n\\n').map(s =>\n        s\n          .replace(/[\\[\\]\\(\\)]/g, '')   // colchetes/par\u00eanteses\n          .replace(/\\.\\s*$/, '')        // ponto final\n          .trim()\n      )\n    ).filter(Boolean)\n  )];\n})()\n}}",
              "type": "array"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1312,
        976
      ],
      "id": "7fbc2a4c-66f3-400d-958c-eca13edef3a1",
      "name": "Formata Mensagens para Envio"
    },
    {
      "parameters": {
        "operation": "send",
        "phoneNumberId": "810013515533671",
        "recipientPhoneNumber": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
        "textBody": "={{ $json.mensagens }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.whatsApp",
      "typeVersion": 1.1,
      "position": [
        2688,
        1264
      ],
      "id": "6d2ec7e7-ed45-4377-b262-a4e6f8faa0b1",
      "name": "Send text",
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "send",
        "phoneNumberId": "810013515533671",
        "recipientPhoneNumber": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
        "messageType": "document",
        "mediaLink": "={{ $json.mensagens }}",
        "additionalFields": {
          "mediaFilename": "=Nome do arquivo",
          "mediaCaption": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }} - Aqui est\u00e1 seu exame {{ $('Vari\u00e1veis Globais').item.json.contactName }}"
        }
      },
      "type": "n8n-nodes-base.whatsApp",
      "typeVersion": 1.1,
      "position": [
        2688,
        1440
      ],
      "id": "30ef4f3e-5a52-44f4-86c4-1f4bd831380a",
      "name": "Send PDF",
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "send",
        "phoneNumberId": "810013515533671",
        "recipientPhoneNumber": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
        "messageType": "image",
        "mediaLink": "={{ $json.mensagens }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.whatsApp",
      "typeVersion": 1.1,
      "position": [
        2688,
        1632
      ],
      "id": "94e4d606-87c8-4330-8fd8-97f98c51cc52",
      "name": "Send IMAGEM",
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "send",
        "phoneNumberId": "810013515533671",
        "recipientPhoneNumber": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
        "messageType": "video",
        "mediaLink": "={{ $json.mensagens }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.whatsApp",
      "typeVersion": 1.1,
      "position": [
        2688,
        1824
      ],
      "id": "955efaf2-0c0f-43ad-bd56-16102a25f7c5",
      "name": "Send V\u00cdDEO",
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "send",
        "phoneNumberId": "810013515533671",
        "recipientPhoneNumber": "={{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
        "messageType": "audio",
        "mediaLink": "={{ $json.mensagens }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.whatsApp",
      "typeVersion": 1.1,
      "position": [
        2688,
        2032
      ],
      "id": "86c79e30-2ef2-4021-aa0e-70a7967454c3",
      "name": "Send AUDIO PRONTO",
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## Reseta mem\u00f3ria SourceID\n\nResete a mem\u00f3ria do seu agente toda vez que vc iniciar um novo teste, isso \u00e9 importante para seu fluxo nao gerar erros por misturar memorias de intera\u00e7\u00f5es anteriores",
        "height": 420,
        "width": 275,
        "color": 3
      },
      "id": "1e624366-b15e-4d7a-bdc3-9963395e76d3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1904,
        976
      ]
    },
    {
      "parameters": {
        "operation": "delete",
        "key": "5524998752538"
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -1840,
        1216
      ],
      "id": "701088f2-a3d1-45e0-81a1-a3973bed633a",
      "name": "deletaMem\u00f3riaSourceID",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "32e594c4-e876-41f4-a072-5c32af8301a5",
              "leftValue": "={{ $('Vari\u00e1veis Globais').item.json.category }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -1024,
        384
      ],
      "id": "44a436a6-7887-44ef-adfe-fdcd3b5c4ac2",
      "name": "existeRetorno"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ \n  [ $('Redis').item.json.mensagemTextoDireto, $('Redis').item.json.mensagemMediaTranscrita ]\n    .filter(x => !!x)\n    .join(' ')\n}}",
        "options": {
          "systemMessage": "=Voc\u00ea \u00e9 o assistente virtual de agendamento do estabelecimento {{ $('Fetch Tenant Info').item.json.company_name || 'Nia App' }}.\nSeu objetivo \u00e9 ajudar os clientes a marcar hor\u00e1rios e tirar d\u00favidas.\nHoje \u00e9: {{ new Date($now).toLocaleString('pt-BR', {timeZone: 'America/Sao_Paulo', weekday: 'long', day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit'}).replace(/^./, c => c.toUpperCase()) }}\n\nREGRAS:\n1. Sempre pergunte qual servi\u00e7o o cliente deseja antes de sugerir hor\u00e1rios.\n2. NUNCA confirme um hor\u00e1rio sem antes usar a ferramenta (tool) apropriada para verificar a disponibilidade no sistema.\n3. Seja cordial, direto e objetivo. Responda em par\u00e1grafos curtos ideais para WhatsApp."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.1,
      "position": [
        912,
        976
      ],
      "id": "89b2b299-6bc9-4d74-9cca-a7de02ec72f2",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {
          "temperature": 0.3
        },
        "model": "gemini-1.5-flash"
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        672,
        1168
      ],
      "id": "1792f674-bbcd-4cef-a4f2-0757fdd19dcf",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Vari\u00e1veis Globais').item.json.myPhoneNumber }}_{{ $('Vari\u00e1veis Globais').item.json.wa_id }}",
        "contextWindowLength": 100
      },
      "type": "@n8n/n8n-nodes-langchain.memoryRedisChat",
      "typeVersion": 1.5,
      "position": [
        880,
        1296
      ],
      "id": "3b7e2b67-4d71-45b2-8970-ef4554779dca",
      "name": "Redis Chat Memory",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sseEndpoint": "https://api.nia-ai.com.br/mcp/sse",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "typeVersion": 1,
      "position": [
        1152,
        1200
      ],
      "id": "3b4b5703-ad41-415e-b56e-f7198b57518d",
      "name": "MCP Client"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT * FROM tenants WHERE phone_number_id = '{{ $json.body.entry[0].changes[0].value.metadata.display_phone_number }}' LIMIT 1;"
      },
      "id": "fetch-tenant-info-placeholder",
      "name": "Fetch Tenant Info",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.4,
      "position": [
        -1680,
        560
      ],
      "notesInFlow": true,
      "notes": "Busca config do tenant no Banco de Dados"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook1": {
      "main": [
        [
          {
            "node": "Fetch Tenant Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Vari\u00e1veis Globais": {
      "main": [
        [
          {
            "node": "Switch4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "VALIDA STATUS": {
      "main": [
        [
          {
            "node": "Switch PARE OU SIGA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch4": {
      "main": [
        [
          {
            "node": "existeRetorno",
            "type": "main",
            "index": 0
          }
        ],
        [],
        [],
        [
          {
            "node": "VALIDA STATUS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch PARE OU SIGA": {
      "main": [
        [
          {
            "node": "Tipo da Mensagem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getMetadados": {
      "main": [
        [
          {
            "node": "baixaImagem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tipo da Mensagem": {
      "main": [
        [
          {
            "node": "getMetadados1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "getMetadados",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "getMetadados2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "mensagemTexto",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getMetadados1": {
      "main": [
        [
          {
            "node": "baixaAudio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getMetadados2": {
      "main": [
        [
          {
            "node": "baixaPDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "baixaAudio": {
      "main": [
        [
          {
            "node": "Transcribe a recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "baixaImagem": {
      "main": [
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "baixaPDF": {
      "main": [
        [
          {
            "node": "Extrair Dados .pdf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "mensagemM\u00eddia",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trata a Mensagem": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Trata a Mensagem Transcrita": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fila as mensagens transcritas": {
      "main": [
        [
          {
            "node": "Debounce Resposta1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fila as mensagens de texto direto": {
      "main": [
        [
          {
            "node": "Debounce Resposta",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Debounce Resposta1": {
      "main": [
        [
          {
            "node": "Puxa as Mensagens Trasncritas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Debounce Resposta": {
      "main": [
        [
          {
            "node": "Puxa as Mensagens",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Puxa as Mensagens": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Trata a Mensagem",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Puxa as Mensagens Trasncritas": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Trata a Mensagem Transcrita",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "mensagemTexto": {
      "main": [
        [
          {
            "node": "Fila as mensagens de texto direto",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "mensagemM\u00eddia": {
      "main": [
        [
          {
            "node": "Fila as mensagens transcritas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe a recording": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Extrair Dados .pdf": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Redis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Send text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send IMAGEM",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send V\u00cdDEO",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send AUDIO PRONTO",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Formata Mensagens para Envio": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send text": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send PDF": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send IMAGEM": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send V\u00cdDEO": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send AUDIO PRONTO": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "existeRetorno": {
      "main": [
        [
          {
            "node": "DEBOUNCE",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Formata Mensagens para Envio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Redis Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "MCP Client": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Tenant Info": {
      "main": [
        [
          {
            "node": "Vari\u00e1veis Globais",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "6bc76ecf-52f7-43d9-ba5f-0f0a3dac916f",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "mNNvJqrhgjgaXjUVpX46j",
  "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

Fluxo Nia App - Agendamento Multi-tenant. Uses redis, httpRequest, openAi, whatsApp. Webhook trigger; 52 nodes.

Source: https://github.com/giovanistefani/nia-app/blob/c8886978b6899b5b809660491ce01255107b34fb/doc/FLUXO_AGENDAMENTO_NIA.json — 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

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

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

secretaria. Uses postgres, n8n-nodes-evolution-api, openAi, httpRequest. Webhook trigger; 71 nodes.

Postgres, N8N Nodes Evolution Api, OpenAI +12
AI & RAG

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

OpenAI, Redis, Supabase +7
AI & RAG

Aura-bot. Uses postgres, lmChatOpenAi, memoryBufferWindow, httpRequest. Webhook trigger; 82 nodes.

Postgres, OpenAI Chat, Memory Buffer Window +6