AutomationFlowsData & Sheets › Agendamento Advocacia_main

Agendamento Advocacia_main

Agendamento advocacia_MAIN. Uses redis, openAi, httpRequest, supabase. Webhook trigger; 75 nodes.

Webhook trigger★★★★★ complexityAI-powered75 nodesRedisOpenAIHTTP RequestSupabaseChain LlmText ClassifierRabbitmqExecution Data
Data & Sheets Trigger: Webhook Nodes: 75 Complexity: ★★★★★ AI nodes: yes Added:

This workflow follows the Chainllm → Google Sheets 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
{
  "createdAt": "2025-04-06T18:13:21.558Z",
  "updatedAt": "2025-05-19T11:19:24.899Z",
  "id": "TZ8ioxPXgNEMWpLB",
  "name": "Agendamento advocacia_MAIN",
  "active": false,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {
        "operation": "set",
        "key": "={{ $('RECEBE').item.json.content.Tel[' Cliente'] }}_block",
        "value": "true",
        "expire": true,
        "ttl": 7200
      },
      "id": "facf56ab-a2f1-492e-966f-d7c68b5e3a42",
      "name": "Block AI1",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -740,
        560
      ],
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "propertyName": "block",
        "key": "={{ $('RECEBE').item.json.content.Tel[' Cliente'] }}_block",
        "options": {}
      },
      "id": "df6c2e9f-1e9c-4565-a44d-fd6f86610ad9",
      "name": "Get Block chat_id1",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -740,
        740
      ],
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.content.event }}",
                    "rightValue": "=outcoming",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "f156c451-90f8-4167-acb6-3dc7df7bc0fc"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "outcoming"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "fc9fcc0f-92bd-41e9-80b4-acaad2c952b5",
                    "leftValue": "={{ $json.content.event }}",
                    "rightValue": "incoming",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "incoming"
            }
          ]
        },
        "options": {}
      },
      "id": "c86b5bcb-4260-4050-97d7-535ec57e3433",
      "name": "Switch5",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        -920,
        660
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e88a3c82-208d-4d8a-bf02-5fd6d3498043",
              "name": "base64",
              "value": "={{ $('RECEBE').item.json.content.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "cc1f171a-6841-40f3-a96c-a4aac96bd80c",
      "name": "pegar base66",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1600,
        920
      ]
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "base64",
        "binaryPropertyName": "=data",
        "options": {
          "fileName": "=imagem.jpeg",
          "mimeType": "image/jpeg"
        }
      },
      "id": "38f57bd2-fcbe-4657-ba5f-60022ab6b273",
      "name": "Convert to File6",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1820,
        720
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e88a3c82-208d-4d8a-bf02-5fd6d3498043",
              "name": "base64",
              "value": "={{ $('RECEBE').item.json.content.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "6af3042e-ff42-4d44-8281-2164a2ae5e2b",
      "name": "pegar base67",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1600,
        720
      ]
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "base64",
        "binaryPropertyName": "=data",
        "options": {
          "fileName": "=Audio.mp3",
          "mimeType": "audio/mpeg"
        }
      },
      "id": "8c103435-cfb0-48ed-adc7-074ce9ec8579",
      "name": "Convert to File7",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1820,
        920
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "54fbef04-4208-4c5c-8c7f-71ff21900570",
              "name": "mensagem",
              "value": "={{ $('RECEBE').item.json.content.mensagem }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "4758dfe9-ada3-43e4-9fd4-7e8ad3ae562d",
      "name": "Edit Fields11",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1080,
        1000
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e88a3c82-208d-4d8a-bf02-5fd6d3498043",
              "name": "base64",
              "value": "={{ $('RECEBE').item.json.content.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "4b6eca58-f46a-4de2-9337-8fc286e06ef3",
      "name": "pegar base4",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        500,
        260
      ]
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "id": "755faf9f-4fd9-4993-8dcb-15b420b4f145",
      "name": "OpenAI2",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.4,
      "position": [
        2480,
        920
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "base64",
        "options": {
          "fileName": "={{ $('RECEBE').item.json.content.telefoneCliente }} ",
          "mimeType": "application/pdf"
        }
      },
      "id": "f22552e7-fda6-412c-accd-086d92335e44",
      "name": "Convert to File8",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        720,
        260
      ]
    },
    {
      "parameters": {
        "operation": "pdf",
        "options": {}
      },
      "id": "cb3b3095-83e9-43be-a3c5-aee0b5cdd669",
      "name": "Extract from File2",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        940,
        260
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://sua_url_instalar_no_servidor_stirlingpdf/api/v1/convert/pdf/img",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "*/*"
            },
            {
              "name": "Content-Type",
              "value": "multipart/form-data"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "fileInput",
              "inputDataFieldName": "data"
            },
            {
              "name": "imageFormat",
              "value": "jpg"
            },
            {
              "name": "singleOrMultiple",
              "value": "single"
            },
            {
              "name": "colorType",
              "value": "color"
            },
            {
              "name": "dpi",
              "value": "400"
            }
          ]
        },
        "options": {}
      },
      "id": "2c094275-ae1d-4981-b300-a9fa5b8c41ba",
      "name": "HTTP Request19",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1820,
        180
      ],
      "retryOnFail": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "b11b5c61-276a-49cc-ad24-1fc35dd2bfd8",
              "leftValue": "={{ $json.text }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "328dbcd9-b6d6-45bf-a599-02719c36341b",
      "name": "If10",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1120,
        220
      ]
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "base64",
        "options": {
          "fileName": "file.pdf",
          "mimeType": "application/pdf"
        }
      },
      "id": "51cdc850-7948-47dc-965a-ae2f3b6a53e5",
      "name": "Convert to File9",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1600,
        180
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e88a3c82-208d-4d8a-bf02-5fd6d3498043",
              "name": "base64",
              "value": "={{ $('RECEBE').item.json.content.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "e41bb348-f75d-4912-8908-9c99bff822e4",
      "name": "pegar base5",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1380,
        180
      ]
    },
    {
      "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": "identifique e cite qual o documento que \u00e9 e Transforme em texto tudo que estiver na imagem para assim eu saber do que o documento no formato de sa\u00edda:\n\naqui est\u00e1 o [nome do documento]\n[transcri\u00e7\u00e3o da imagem]",
        "inputType": "base64",
        "options": {}
      },
      "id": "266608d8-739b-4169-aea3-e806535d1a1c",
      "name": "OpenAI3",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.4,
      "position": [
        2060,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e88a3c82-208d-4d8a-bf02-5fd6d3498043",
              "name": "base64",
              "value": "={{ $('RECEBE').item.json.content.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "23fd6cb3-0974-4cda-83ae-0fea2f726e39",
      "name": "pegar base6",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        720,
        520
      ]
    },
    {
      "parameters": {
        "operation": "pdf",
        "options": {}
      },
      "id": "7baeb09c-0920-4af9-a843-9cd47e844734",
      "name": "Extract from File3",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        1160,
        520
      ],
      "retryOnFail": true
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://sua_url_instalar_no_servidor_stirlingpdf/api/v1/convert/pdf/img",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "*/*"
            },
            {
              "name": "Content-Type",
              "value": "multipart/form-data"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "fileInput",
              "inputDataFieldName": "data"
            },
            {
              "name": "imageFormat",
              "value": "jpg"
            },
            {
              "name": "singleOrMultiple",
              "value": "single"
            },
            {
              "name": "colorType",
              "value": "color"
            },
            {
              "name": "dpi",
              "value": "400"
            }
          ]
        },
        "options": {}
      },
      "id": "e9165b2d-e41b-467e-a1ad-3e744c9c3164",
      "name": "HTTP Request20",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2040,
        520
      ],
      "retryOnFail": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "b11b5c61-276a-49cc-ad24-1fc35dd2bfd8",
              "leftValue": "={{ $json.text }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "affa8f42-083a-4769-80fc-6b3ceec1ba53",
      "name": "If11",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1380,
        520
      ]
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "base64",
        "options": {
          "fileName": "file.pdf",
          "mimeType": "application/pdf"
        }
      },
      "id": "09bddf51-3383-46a6-a17e-ec12e071e1d9",
      "name": "Convert to File10",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1820,
        520
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e88a3c82-208d-4d8a-bf02-5fd6d3498043",
              "name": "base64",
              "value": "={{ $('RECEBE').item.json.content.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "1208f38a-cd3b-4d5a-a974-92f9d4f75102",
      "name": "pegar base7",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1600,
        520
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "76ab7a43-b74d-4565-ae35-3308b36a6388",
              "leftValue": "={{ $('RECEBE').item.json.content.body.data.message.documentWithCaptionMessage.message.documentMessage.mimetype }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "61577aca-a800-45c8-a86e-4eeb16854a6e",
      "name": "If12",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        280,
        460
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "05fe3f7a-8266-468f-a412-7ffa82f6f9ba",
                    "leftValue": "={{ $('RECEBE').item.json.content['Tipo de arquivo'] }}",
                    "rightValue": "documentMessage",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "PDF"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "05fe3f7a-8266-468f-a412-7ffa82f6f9ba",
                    "leftValue": "={{ $('RECEBE').item.json.content['Tipo de arquivo'] }}",
                    "rightValue": "=documentWithCaptionMessage",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "documento"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "leftValue": "={{ $('RECEBE').item.json.content['Tipo de arquivo'] }}",
                    "rightValue": "imageMessage",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "009f97d1-f73b-4a27-981a-05301fa6265b"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "imagem"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 1
                },
                "conditions": [
                  {
                    "id": "bc304812-2320-4bd4-a904-e2c41be0c8ab",
                    "leftValue": "={{ $('RECEBE').item.json.content['Tipo de arquivo'] }}",
                    "rightValue": "=audioMessage",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "=audio"
            }
          ]
        },
        "options": {}
      },
      "id": "9b52013b-8a1b-4492-adee-5930a72add44",
      "name": "Switch9",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        60,
        540
      ],
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "operation": "ods",
        "options": {}
      },
      "id": "463b081c-e32e-469a-92b6-d4f5e97c77c0",
      "name": "Convert to File11",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        940,
        520
      ]
    },
    {
      "parameters": {},
      "id": "b4c39827-d066-4144-b5be-397bd9159573",
      "name": "Merge3",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        2920,
        520
      ]
    },
    {
      "parameters": {
        "content": "# Interfer\u00eancia humana",
        "height": 462,
        "width": 582
      },
      "id": "65dff81c-9850-4cfb-a740-4df0bfbbf864",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -960,
        460
      ]
    },
    {
      "parameters": {
        "content": "# processamento de n\u00e3o texto: imagens, audio,  pdf",
        "height": 1187,
        "width": 2154,
        "color": 2
      },
      "id": "ddfc96be-5f6c-4b58-b7c3-10a632f14431",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        60
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $('RECEBE').item.json.content.base64 }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "id": "8f39d069-6ac1-43a9-bb46-5d42e308a1aa"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "arquivo"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "6e049e96-1dec-426a-adc8-d8956edfe7ad",
                    "leftValue": "={{ $('RECEBE').item.json.content.message.content }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "texto"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -260,
        720
      ],
      "id": "dae7182e-2e41-401c-acbb-b7cb0da5350f",
      "name": "Switch11"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.block }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "empty",
                      "singleValue": true
                    },
                    "id": "9e30af89-bba5-41e7-80ee-3fba0fbad4c1"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "IA pode responder"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "aff5c565-1e5c-4959-9d14-102e0d3552ce",
                    "leftValue": "={{ $json.block }}",
                    "rightValue": "true",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "n\u00e3o pode responder"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -540,
        740
      ],
      "id": "be6179d6-5ddd-4c42-9f46-fad6ba3a4b45",
      "name": "Switch19"
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "IA Clientes",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "keyValue": "={{ $json.body.id }}"
            }
          ]
        }
      },
      "id": "ee3fcc04-1692-4714-ac23-955d1f2b8418",
      "name": "Supabase6",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -1040,
        1940
      ],
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "IA empresa",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "keyValue": "={{ $json.ID_empresa }}"
            }
          ]
        }
      },
      "id": "c59cea4e-3b63-42c9-9c16-aff88fb6ab4b",
      "name": "Supabase9",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -820,
        1940
      ],
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "81c4d040-835d-43e9-a334-05de96a9650f",
              "name": "response",
              "value": "Certo, muito obrigado pelas informa\u00e7\u00f5es. Vou repassar seu caso para nossa equipe especializada entrar em contato e finalizar. . Gostaria de agradecer muito pelas informa\u00e7\u00f5es. Espero que Deus aben\u00e7oe sua vida e a de sua fam\u00edlia, e se depender de n\u00f3s, faremos de tudo para lutarmos juntos pelo seu benef\u00edcio! . Conte conosco para esclarecer suas d\u00favidas! . E se voc\u00ea tem algu\u00e9m para indicar, um familiar, um vizinho ou um conhecido que esteja precisando, ser\u00e1 uma grande honra ajudar algu\u00e9m que voc\u00ea indicar, e juntos podemos fazer a diferen\u00e7a na vida das pessoas! . Lembre-se que N\u00c3O cobramos entrada e voc\u00ea s\u00f3 PAGA se der certo e quando der certo! . Justamente porque acreditamos no nosso trabalho e lutaremos para tentar fazer seu benef\u00edcio dar certo, trazendo assim dignidade e possibilidades para as pessoas!",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "d3d6834f-23f1-46cb-9252-78302f51dbd8",
      "name": "Edit Fields4",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -380,
        2060
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://lucid-generosity-production.up.railway.app/message/sendText/{{ $json['nome'] }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "={{ $json['Apikey Evo'] }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "=\u2b55 CLIENTE ANTIGO\n\n*{{ $('Supabase6').item.json['nome do possivel beneficiado'] }}*\n\n{{ $('cliente passado').item.json.body['resumo da conversa'] }}\n\nhttps://wa.me/{{ $('Supabase6').item.json.telefone }}?text=Ol%C3%A1%20{{ $('Supabase6').item.json.nome.split(' ')[0] }}%2C%20tudo%20bem%3F%20Recebi%20o%20seu%20caso"
            },
            {
              "name": "number",
              "value": "={{ $json['Numero do Advogado'] }}"
            }
          ]
        },
        "options": {}
      },
      "id": "a367db5e-43a5-43f0-b3fa-2200d589b70c",
      "name": "HTTP Request6",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -600,
        1840
      ],
      "retryOnFail": true
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://lucid-generosity-production.up.railway.app/message/sendText/61985154043",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "={{ $json['Apikey Evo'] }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "=\u2b55 CLIENTE PASSADO \u2b55\n\n*{{ $('Supabase6').item.json['nome do possivel beneficiado'] }}*\n\n{{ $('cliente passado').item.json.body['resumo da conversa'] }}\n\nhttps://wa.me/{{ $('Supabase6').item.json.telefone }}?text=Ol%C3%A1%20{{ $('Supabase6').item.json.nome.split(' ')[0] }}%2C%20tudo%20bem%3F%20Recebi%20o%20seu%20caso"
            },
            {
              "name": "number",
              "value": "5561994081617"
            }
          ]
        },
        "options": {}
      },
      "id": "82ccd236-583e-40e4-a5b8-22ed8c5024e8",
      "name": "HTTP Request7",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -600,
        2020
      ],
      "retryOnFail": true
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "IA Clientes",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "condition": "eq",
              "keyValue": "={{ $json.body.id_cliente_supabase }}"
            }
          ]
        },
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "Contribui INSS",
              "fieldValue": "={{ $json.body.contribuiu }}"
            },
            {
              "fieldId": "PCD e isso afeta o trabalho",
              "fieldValue": "={{ $json.body.PCD_afeta_trabalho }}"
            },
            {
              "fieldId": "idade",
              "fieldValue": "={{ $json.body.idade }}"
            },
            {
              "fieldId": "cnpj_empresa",
              "fieldValue": "={{ $json.body.cnpj_empresa }}"
            },
            {
              "fieldId": "aposentadoria_maior",
              "fieldValue": "={{ $json.body.aposentadoria_maior }}"
            },
            {
              "fieldId": "pensao_morte",
              "fieldValue": "={{ $json.body.pensao_morte }}"
            },
            {
              "fieldId": "trabalho_carteira",
              "fieldValue": "={{ $json.body.trabalho_carteira }}"
            },
            {
              "fieldId": "num_pessoas_casa",
              "fieldValue": "={{ $json.body.num_pessoas_casa }}"
            },
            {
              "fieldId": "sequelas_acidente",
              "fieldValue": "={{ $json.body.sequelas_acidente }}"
            },
            {
              "fieldId": "auxilio_acidente",
              "fieldValue": "={{ $json.body.auxilio_acidente }}"
            },
            {
              "fieldId": "sofreu_acidente",
              "fieldValue": "={{ $json.body.sofreu_acidente }}"
            },
            {
              "fieldId": "inicio_problemas",
              "fieldValue": "={{ $json.body.inicio_problemas }}"
            },
            {
              "fieldId": "tem_documentos",
              "fieldValue": "={{ $json.body.tem_documentos }}"
            },
            {
              "fieldId": "problema_saude",
              "fieldValue": "={{ $json.body.problema_saude }}"
            },
            {
              "fieldId": "trabalho_roca",
              "fieldValue": "={{ $json.body.trabalho_roca }}"
            },
            {
              "fieldId": "beneficios_anteriores",
              "fieldValue": "={{ $json.body.beneficios_anteriores }}"
            },
            {
              "fieldId": "tempo_contribuicao",
              "fieldValue": "={{ $json.body.tempo_contribuicao }}"
            },
            {
              "fieldId": "explicacao_caso",
              "fieldValue": "={{ $json.body.explicacao_caso }}"
            },
            {
              "fieldId": "nome do possivel beneficiado",
              "fieldValue": "={{ $json.body.nome_do_possivel_beneficiado }}"
            },
            {
              "fieldId": "com_quem_esta_conversando",
              "fieldValue": "={{ $json.body.com_quem_esta_conversando }}"
            },
            {
              "fieldId": "resumo da conversa",
              "fieldValue": "={{ $json.body['resumo da conversa'] }}"
            },
            {
              "fieldId": "registro_acidente",
              "fieldValue": "={{ $json.body.registro_acidente }}"
            },
            {
              "fieldId": "Status",
              "fieldValue": "Conclu\u00eddo"
            }
          ]
        }
      },
      "id": "d958b5d7-5723-49bf-be23-4729709f63f8",
      "name": "Supabase10",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -1040,
        1480
      ],
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "IA empresa",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "keyValue": "={{ $json.ID_empresa }}"
            }
          ]
        }
      },
      "id": "9fff4234-0d42-428f-a427-e1fc144724fe",
      "name": "Supabase11",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -820,
        1480
      ],
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://lucid-generosity-production.up.railway.app/message/sendText/{{ $json['nome'] }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "={{ $json['Apikey Evo'] }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "=\u2705 CLIENTE NOVO\n\n*{{ $('Supabase10').item.json['nome do possivel beneficiado'] }}*\n\n{{ $('qualifica\u00e7\u00e3o1').item.json.body['resumo da conversa'] }}\n\nhttps://wa.me/{{ $('Supabase10').item.json.telefone }}?text=Ol%C3%A1%20{{ $('Supabase10').item.json.nome.split(' ')[0] }}%2C%20tudo%20bem%3F%20Recebi%20o%20seu%20caso"
            },
            {
              "name": "number",
              "value": "={{ $json['Numero do Advogado'] }}"
            }
          ]
        },
        "options": {}
      },
      "id": "7cb86761-750f-40a6-b4ae-c4d13f2342cb",
      "name": "HTTP Request8",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -600,
        1380
      ],
      "retryOnFail": true
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://lucid-generosity-production.up.railway.app/message/sendText/61985154043",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "={{ $json['Apikey Evo'] }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "=\u2705 CLIENTE NOVO\n\n*{{ $('Supabase10').item.json['nome do possivel beneficiado'] }}*\n\n{{ $('qualifica\u00e7\u00e3o1').item.json.body['resumo da conversa'] }}\n\nhttps://wa.me/{{ $('Supabase10').item.json.telefone }}?text=Ol%C3%A1%20{{ $('Supabase10').item.json.nome.split(' ')[0] }}%2C%20tudo%20bem%3F%20Recebi%20o%20seu%20caso"
            },
            {
              "name": "number",
              "value": "5561994081617"
            }
          ]
        },
        "options": {}
      },
      "id": "5ad215e2-7b26-470f-804a-4e199fbc45ea",
      "name": "HTTP Request9",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -600,
        1580
      ],
      "retryOnFail": true
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "81c4d040-835d-43e9-a334-05de96a9650f",
              "name": "response",
              "value": "=fale para o cliente de forma natural o resumo: este \u00e9 o resumo que vou enviar para o advogado: {{ $('qualifica\u00e7\u00e3o1').item.json.body['resumo da conversa'] }}! e depois fale: \"vou repassar seu caso para nossa equipe especializada entrar em contato e finalizar, ela entrar\u00e1 em contato dentro de {{ $('Supabase11').item.json['Tempo at\u00e9 algu\u00e9m entrar em contato'] }}, conte conosco para esclarecer suas d\u00favidas e se voc\u00ea tem algu\u00e9m para indicar, um familiar, um vizinho ou um conhecido que esteja precisando, ser\u00e1 uma grande honra ajudar\" porem se voc\u00ea j\u00e1 falou isso anteriomente para o cliente encerre a conversa educadamente",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "bd015dfe-b9ea-4f8c-b312-550b642e4130",
      "name": "Edit Fields8",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -220,
        1660
      ]
    },
    {
      "parameters": {
        "content": "# Registro de informa\u00e7\u00f5es no supabase e encaminha card para advogado",
        "height": 476,
        "width": 1353
      },
      "id": "a5a6a4ba-1e5c-496c-97ec-e973f350fffe",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1300,
        1300
      ]
    },
    {
      "parameters": {
        "content": "# Encaminha card para advogado quando ele \u00e9 cliente antigo",
        "height": 368,
        "width": 1365
      },
      "id": "6c2f8bda-d135-49dc-af58-766ed0bc5cf8",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1320,
        1820
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "cliente_passado",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "44a6b5b3-9764-4241-8b64-76563239b167",
      "name": "cliente passado",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -1260,
        1940
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "qualifica\u00e7\u00e3o",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "a7f2e3a3-f77b-4976-bf98-f24661159db5",
      "name": "qualifica\u00e7\u00e3o1",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -1260,
        1480
      ]
    },
    {
      "parameters": {
        "operation": "getAll",
        "tableId": "IA Clientes",
        "filters": {
          "conditions": [
            {
              "keyName": "updated_at",
              "condition": "gt",
              "keyValue": "={{ $now.plus(5,'minutes') }}"
            },
            {
              "keyName": "Status",
              "condition": "eq",
              "keyValue": "Em andamento"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -1040,
        2540
      ],
      "id": "e2388769-5728-47e2-829d-9ea84ee38283",
      "name": "ListChats-Supabase",
      "disabled": true
    },
    {
      "parameters": {
        "operation": "getAll",
        "tableId": "IA Clientes",
        "matchType": "allFilters",
        "filters": {
          "conditions": [
            {
              "keyName": "telefone",
              "condition": "eq",
              "keyValue": "={{ $json.phone }}"
            },
            {
              "keyName": "active",
              "condition": "eq",
              "keyValue": "true"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -600,
        2460
      ],
      "id": "56043b96-e05c-438e-bd3c-659f2068bbe8",
      "name": "ListMessages-Supabase",
      "alwaysOutputData": true,
      "disabled": true
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "chat_messages",
        "filters": {
          "conditions": [
            {
              "keyName": "phone",
              "condition": "eq",
              "keyValue": "={{ $('Aggregate1')?.item?.json?.conversas?.last()?.phone }}"
            }
          ]
        },
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "active",
              "fieldValue": "false"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1260,
        2640
      ],
      "id": "5cb4ca21-2745-42cd-86a1-ad3e53318d89",
      "name": "DisableMessage-Supabase",
      "disabled": true
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c9c00627-84a9-49a9-bc7e-d923a5918346",
              "name": "output",
              "value": "={{ $json.text }}",
              "type": "string"
            },
            {
              "id": "0e34f673-b6dc-4748-89d2-a178dfe91853",
              "name": "phone",
              "value": "={{ $('Aggregate1').item.json.conversas.last().phone }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        820,
        2300
      ],
      "id": "04c2530d-b918-4e64-88a5-6b2c8a8e5bf1",
      "name": "SetConfig",
      "disabled": true
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=# Voc\u00ea \u00e9 um agente facilitador de vendas e est\u00e1 buscando conversas n\u00e3o finalizadas entre o cliente e um agent de IA. \n\n# Cria a responda apenas a resposta n\u00e3o precisa justificar sua resposta\n\n# Identifique o cliente n\u00e3o enviou mais mensagens de resposta\n\n# Se o cliente n\u00e3o responder mesmo assim, agrade\u00e7a e diga que ir\u00e1 encerrar o pedido e est\u00e1 a disposi\u00e7\u00e3o para outros pedidos\n\n# Use frase simples e naturais como nos exemplos\n\nExemplos : \n - 'Oi .. ainda est\u00e1 ai'\n - 'E ai ? vamos finalizar o pedido?' \n\n# Conversa entre o cliete e o agente de IA:\n{{ $json.texto }}"
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.5,
      "position": [
        440,
        2400
      ],
      "id": "7724352c-1980-410c-9367-fc00bcd0f679",
      "name": "Basic LLM Chain",
      "disabled": true
    },
    {
      "parameters": {
        "inputText": "={{ $json.texto }}",
        "categories": {
          "categories": [
            {
              "category": "pendente_resposta",
              "description": "A conversa est\u00e1 pendente devido a uma informa\u00e7\u00e3o que o cliente ficou de fornecer ou confirmar"
            },
            {
              "category": "encerrada",
              "description": "Houve um desfecho da conversa e o agente de IA se despediu"
            },
            {
              "category": "sem_resposta",
              "description": "=Se o cliente n\u00e3o respondeu mais as mensagens do agente - mensagem do cliente vazia"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "typeVersion": 1,
      "position": [
        60,
        2460
      ],
      "id": "7a85e06e-2277-4f1f-8e50-9c884ff9debb",
      "name": "Text Classifier",
      "disabled": true
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "conversas",
        "include": "specifiedFields",
        "fieldsToInclude": "id,message_type,created_at,user_message, bot_message,phone, conversation_id",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        -380,
        2460
      ],
      "id": "cabc8bae-6685-49a7-b15c-6f750393479f",
      "name": "Aggregate1",
      "disabled": true
    },
    {
      "parameters": {
        "jsCode": "return $('Aggregate1').all().map(item => {\n  // Tenta acessar a propriedade 'conversas' e verifica se ela \u00e9 um array\n  const conversas = item.json.conversas || []; // Garante que \u00e9 pelo menos um array vazio\n\n  if (!Array.isArray(conversas)) {\n    throw new Error(\"A propriedade 'conversas' n\u00e3o \u00e9 um array.\");\n  }\n\n  // Processa cada conversa e verifica as mensagens\n  const textoUnico = conversas.map(conversa => {\n    const cliente = conversa.user_message || \"sem mensagem do chatbot\";\n    const agente = conversa.bot_message || \"sem resposta\";\n    \n    // Verifica se a data existe e formata\n    const dataOriginal = conversa.created_at || \"Data da Mensagem indispon\u00edvel\";\n    const dataFormatada = dataOriginal !== \"Data da Mensagem indispon\u00edvel\"\n      ? formatarData(dataOriginal)\n      : dataOriginal;\n\n    return `em: ${dataFormatada}\\n\\n - agente(chatbot): ${agente} \\n - cliente: ${cliente}\\n`;\n  }).join('\\n\\n');\n\n  // Retorna o texto final como resultado\n  return {\n    json: {\n      texto: textoUnico\n    }\n  };\n});\n\n// Fun\u00e7\u00e3o para formatar a data\nfunction formatarData(dataString) {\n  const data = new Date(dataString); // Converte a string em objeto Date\n  if (isNaN(data)) {\n    return \"Data inv\u00e1lida\"; // Retorna se a data n\u00e3o for v\u00e1lida\n  }\n  \n  // Formata no padr\u00e3o DD/MM/YYYY HH:mm\n  const dia = String(data.getDate()).padStart(2, '0');\n  const mes = String(data.getMonth() + 1).padStart(2, '0'); // M\u00eas come\u00e7a em 0\n  const ano = data.getFullYear();\n  const horas = String(data.getHours()).padStart(2, '0');\n  const minutos = String(data.getMinutes()).padStart(2, '0');\n  \n  return `${dia}/${mes}/${ano} ${horas}:${minutos}`;\n}\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -160,
        2460
      ],
      "id": "3d898bf2-423b-4546-a219-3e15eee1af4e",
      "name": "Code4",
      "disabled": true
    },
    {
      "parameters": {
        "tableId": "chat_messages",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "phone",
              "fieldValue": "={{ $('Aggregate1').item.json.conversas.last().phone }}"
            },
            {
              "fieldId": "conversation_id",
              "fieldValue": "={{ $('Aggregate1').item.json.conversas.last().phone }}"
            },
            {
              "fieldId": "message_type",
              "fieldValue": "={{ $('Aggregate1').item.json.conversas.last().message_type }}"
            },
            {
              "fieldId": "bot_message",
              "fieldValue": "={{ $json.text }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        820,
        2500
      ],
      "id": "29ea10f4-dfdf-4a9a-a58c-a50c5dcf3479",
      "name": "Supabase2",
      "disabled": true
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 10-16/2 * * 1-5"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -1260,
        2540
      ],
      "id": "22c775a6-62d0-4363-aa6e-985b5775f465",
      "name": "Schedule Trigger2",
      "disabled": true
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -820,
        2540
      ],
      "id": "0b119320-8cf2-4e6c-bf41-968c0b63cecc",
      "name": "Loop Over Items4",
      "disabled": true
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1040,
        2560
      ],
      "id": "f3562d03-35dd-4d9d-8827-80de0fbe85a9",
      "name": "Wait2",
      "disabled": true
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "16616783-d22b-4a9d-8b7a-ec27324cb0db",
              "name": "messages",
              "value": "={{ $json.messages }}",
              "type": "string"
            },
            {
              "id": "27ea214a-f4c5-46b7-9abe-289422fcb722",
              "name": "Tel. Cliente",
              "value": "={{ $('RECEBE').item.json.content.Tel[' Cliente'] }}",
              "type": "string"
            },
            {
              "id": "872cbabb-ffec-4ffd-8300-b27986923b86",
              "name": "Tel. Empresa",
              "value": "={{ $('RECEBE').item.json.content.Tel[' Empresa'] }}",
              "type": "string"
            },
            {
              "id": "9b73cbec-0291-4460-94f1-6b04c436011c",
              "name": "content.delay",
              "value": "={{ $('RECEBE').item.json.content.delay }}",
              "type": "number"
            },
            {
              "id": "cbc8f09a-c6a9-455c-a947-a68c9ce0bb7c",
              "name": "content['delay mensagem longa']",
              "value": "={{ $('RECEBE').item.json.content['delay mensagem longa'] }}",
              "type": "number"
            },
            {
              "id": "6bd48334-d9f5-483f-a341-a00385850102",
              "name": "=content.instancia",
              "value": "={{ $('RECEBE').item.json.content.instancia }}",
              "type": "string"
            },
            {
              "id": "c4109dfc-58c3-4ef5-b264-5be2907f5ca7",
              "name": "content['Nome do cliente']",
              "value": "={{ $('RECEBE').item.json.content['Nome do cliente'] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        4240,
        540
      ],
      "id": "309c07b6-ee90-47af-a01c-c6fdb46c9de1",
      "name": "Edit Fields1"
    },
    {
      "parameters": {
        "queue": "={{ $('RECEBE').item.json.content['Nome da Fila 02'] }}",
        "options": {
          "arguments": {
            "argument": [
              {
                "key": "x-queue-type",
                "value": "quorum"
              }
            ]
          },
          "durable": true
        }
      },
      "id": "06b9b265-f476-48ca-9e43-1c111154d61b",
      "name": "ENVIA",
      "type": "n8n-nodes-base.rabbitmq",
      "typeVersion": 1.1,
      "position": [
        4460,
        420
      ],
      "credentials": {
        "rabbitmq": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "queue": "={{ $json['Nome da Fila'] }}",
        "options": {
          "arguments": {
            "argument": [
              {
                "key": "x-queue-type",
                "value": "quorum"
              }
            ]
          },
          "durable": true
        }
      },
      "id": "426a1dbe-0f0e-44e0-81d9-9cbd5eea5f19",
      "name": "ENVIA1",
      "type": "n8n-nodes-base.rabbitmq",
      "typeVersion": 1.1,
      "position": [
        -720,
        160
      ],
      "credentials": {
        "rabbitmq": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1552359-8f5b-4fbf-ab0d-13c8378e5f61",
              "name": "Tel. Cliente",
              "value": "={{ $('Webhook').item.json.body.data.key.remoteJid.replace('@s.whatsapp.net', '') }}",
              "type": "string"
            },
            {
              "id": "ffa2f821-18b1-4dff-8ba0-ea080037b6ca",
              "name": "Nome do cliente",
              "value": "={{ $('Webhook').item.json.body.data.pushName }}",
              "type": "string"
            },
            {
              "id": "ef07bf81-42a1-4dd2-8662-5f61d43e5812",
              "name": "Tel. Empresa",
              "value": "={{ $('Webhook').item.json.body.sender.replace('@s.whatsapp.net', '') }}",
              "type": "string"
            },
            {
              "id": "49f4d9bb-7694-4c58-8876-03b3eeac9f83",
              "name": "mensagem",
              "value": "={{ $('Webhook').item.json.body.data.message.conversation }}",
              "type": "string"
            },
            {
              "id": "6cbc7a15-6694-47ad-8975-51265881561e",
              "name": "delay",
              "value": 1500,
              "type": "number"
            },
            {
              "id": "e8bdaaf9-23ec-42b0-bd5f-054beca89395",
              "name": "base64",
              "value": "={{ $('Webhook').item.json.body.data.message.base64 }}",
              "type": "string"
            },
            {
              "id": "54ee33be-68dd-443d-b83d-753ba7aab83c",
              "name": "Tipo de arquivo",
              "value": "={{ $('Webhook').item.json.body.data.messageType }}",
              "type": "string"
            },
            {
              "id": "e1088cc7-a2ec-4a47-b61d-592027ac18a3",
              "name": "event",
              "value": "={{ $('Webhook').item.json.body.data.key.fromMe ? 'outcoming' : 'incoming' }}",
              "type": "string"
            },
            {
              "id": "793992a3-76df-4ef9-9e92-f5da16449f5c",
              "name": "delay mensagem longa",
              "value": 15000,
              "type": "number"
            },
            {
              "id": "9a652ee2-1f91-4149-a65f-b5bd6296d358",
              "name": "instancia",
              "value": "={{ $('Webhook').item.json.body.instance }}",
              "type": "string"
            },
            {
              "id": "5b38a3b7-c4ae-443b-8c07-0bd325ca707e",
              "name": "body.data.message.documentWithCaptionMessage.message.documentMessage.mimetype",
              "value": "={{ $('Webhook').item.json.body.data.message.documentWithCaptionMessage.message.documentMessage.mimetype }}",
              "type": "string"
            },
            {
              "id": "07c1f810-1657-4b00-942e-96f15ebb4249",
              "name": "body.data.message.documentWithCaptionMessage.message.documentMessage.fileName",
              "value": "={{ $('Webhook').item.json.body.data.message.documentWithCaptionMessage.message.documentMessage.fileName }}",
              "type": "string"
            },
            {
              "id": "c9ea1893-bdfb-4c60-9085-93bbee24a603",
              "name": "message.timestamp",
              "value": "={{ $('Webhook').item.json.body.data.messageTimestamp.toDateTime('s').toISO() }}",
              "type": "string"
            },
            {
              "id": "f5b1157a-7aa3-47ef-92be-a80df4540974",
              "name": "message.message_id",
              "value": "={{ $('Webhook').item.json.body.data.key.id || '' }}",
              "type": "string"
            },
            {
              "id": "9f8306c7-bc9b-4125-b382-2186aa2f5ab0",
              "name": "message.content",
              "value": "={{ $('Webhook').item.json.body.data.message.extendedTextMessage?.text || '' }}{{ $('Webhook').item.json.body.data.message.imageMessage?.caption || '' }}{{ $('Webhook').item.json.body.data.message.conversation || '' }}",
              "type": "string"
            },
            {
              "id": "2ff226de-cf12-466e-bca9-742c6e53e323",
              "name": "Nome da Fila",
              "value": "01_advocacia",
              "type": "string"
            },
            {
              "id": "35b60c89-3656-4119-a001-f299e2ad99db",
              "name": "Nome da Fila 02",
              "value": "02_advocacia",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "79a51be3-adc2-4c0c-88d5-8edaa0a60d13",
      "name": "Edit Fields5",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -980,
        160
      ],
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "encaminhamento",
        "options": {}
      },
      "id": "8d2004ba-5b04-443c-b970-d597de31512d",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -1180,
        160
      ]
    },
    {
      "parameters": {
        "dataToSave": {
          "values": [
            {
              "key": "mensagem_do_cliente",
              "value": "={{ $('Edit Fields1').item.json.messages }}"
            },
            {
              "key": "Telefone_cliente",
              "value": "={{ $('RECEBE').item.json.content.Tel[' Cliente'] }}"
            },
            {
              "key": "Telefone_empresa",
              "value": "={{ $('RECEBE').item.json.content.Tel[' Empresa'] }}"
            },
            {
              "key": "instancia",
              "value": "={{ $('RECEBE').item.json.content.instancia }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executionData",
      "typeVersion": 1,
      "position": [
        4480,
        600
      ],
      "id": "7f48bdd0-a387-41f1-b583-55710c7be9d7",
      "name": "Execution Data"
    },
    {
      "parameters": {
        "dataToSave": {
          "values": [
            {
              "key": "tool_qualificar",
              "value": "={{ $('HTTP Request9').item.json.message.extendedTextMessage.text }}"
            },
            {
              "key": "Telefone_cliente",
              "value": "={{ $('Supabase10').item.json.tele

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

Agendamento advocacia_MAIN. Uses redis, openAi, httpRequest, supabase. Webhook trigger; 75 nodes.

Source: https://github.com/AndersonNascimentoDosSantos/n8n-workflow-backup/blob/main/agendamento-advocacia_main-TZ8ioxPXgNEMWpLB.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

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

Data & Sheets

• Multi-Layer Message Analysis - Every customer interaction passes through three specialized AI classifiers: privacy detection (identifies sensitive data and security requirements), intent recognition

OpenAI, OpenAI Chat, Tool Think +13
Data & Sheets

This n8n workflow automates the transformation of spreadsheet data into professional charts and graphs using AI-driven analysis. Triggered via Slack, it processes uploaded files (Excel, CSV, Google Sh

Agent, Postgres, HTTP Request +8
Data & Sheets

aula-00-mapa-do-n8n. Uses emailReadImap, stopAndError, httpRequest, graphql. Event-driven trigger; 46 nodes.

Email Read Imap, Stop And Error, HTTP Request +14
Data & Sheets

upload_answer. Uses httpRequest, openAi, googleDrive, googleSheets. Webhook trigger; 27 nodes.

HTTP Request, OpenAI, Google Drive +2
Data & Sheets

DAta lake 1. Uses openAi, httpRequest, googleSheets, mongoDb. Webhook trigger; 23 nodes.

OpenAI, HTTP Request, Google Sheets +1