graph TD
%%{init: {'theme': 'mc','layout': 'elk'}}%%
ChatInput-larrt[<div><img src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Input]
style ChatInput-larrt stroke:#a170ff
LanggraphReactAgent-e7sh0[Detector de Intención]
style LanggraphReactAgent-e7sh0 stroke:#a170ff
ConditionalRouter-e0whx[Conditional Router]
style ConditionalRouter-e0whx stroke:#a170ff
ConditionalRouter-k37bb[Conditional Router2]
style ConditionalRouter-k37bb stroke:#a170ff
ConditionalRouter-7onzp[Conditional Router3]
style ConditionalRouter-7onzp stroke:#a170ff
GoogleGenerativeAIModel-hrflu[Gemini]
style GoogleGenerativeAIModel-hrflu stroke:#a170ff
LanggraphReactAgent-feiuj[Agent]
style LanggraphReactAgent-feiuj stroke:#a170ff
GoogleGenerativeAIModel-0aobu[Gemini2]
style GoogleGenerativeAIModel-0aobu stroke:#a170ff
GoogleGenerativeAIEmbeddings-fnjt0[Google Generative AI Embeddings]
style GoogleGenerativeAIEmbeddings-fnjt0 stroke:#a170ff
LanggraphReactAgent-r6l2z[Agent2]
style LanggraphReactAgent-r6l2z stroke:#a170ff
APIRequest-78xr1[API Request]
style APIRequest-78xr1 stroke:#a170ff
LanggraphReactAgent-py6gc[Agent3]
style LanggraphReactAgent-py6gc stroke:#a170ff
GoogleGenerativeAIModel-y15kz[Gemini3]
style GoogleGenerativeAIModel-y15kz stroke:#a170ff
GoogleGenerativeAIModel-gta86[Gemini4]
style GoogleGenerativeAIModel-gta86 stroke:#a170ff
TelegramMessage-zvrp9[Telegram Message]
style TelegramMessage-zvrp9 stroke:#a170ff
ChatOutput-16z2g[<div><img src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Output]
style ChatOutput-16z2g stroke:#a170ff
ChatOutput-0vfib[<div><img src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Output2]
style ChatOutput-0vfib stroke:#a170ff
ChatOutput-7h910[<div><img src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Output3]
style ChatOutput-7h910 stroke:#a170ff
Prompt-c8k88[<div><img src="/_astro/square-terminal.BMOXc-nZ.svg" style="height: 20px !important;width: 20px !important"/></div>Prompt]
style Prompt-c8k88 stroke:#a170ff
LanggraphRAGAgent-4j24w[RAG Agent]
style LanggraphRAGAgent-4j24w stroke:#a170ff
GoogleGenerativeAIModel-lcmte[Gemini5]
style GoogleGenerativeAIModel-lcmte stroke:#a170ff
GoogleGenerativeAIEmbeddings-mn2ew[Google Generative AI Embeddings2]
style GoogleGenerativeAIEmbeddings-mn2ew stroke:#a170ff
SplitText-xm92m[<div><img src="/_astro/scissors-line-dashed.CajsPhTx.svg" style="height: 20px !important;width: 20px !important"/></div>Split Text]
style SplitText-xm92m stroke:#a170ff
GDriveFilesComponent-q2n9y[<div><img src="/_astro/google_drive.wKmDsV2c.svg" style="height: 20px !important;width: 20px !important"/></div>Google Drive File Manager]
style GDriveFilesComponent-q2n9y stroke:#a170ff
ParseData-dpd2k[<div><img src="/_astro/braces.Djq0PW4_.svg" style="height: 20px !important;width: 20px !important"/></div>Parse Data]
style ParseData-dpd2k stroke:#a170ff
Chroma-d83zz[<div><img src="/_astro/chroma.CDTUBZSx.svg" style="height: 20px !important;width: 20px !important"/></div>Chroma DB]
style Chroma-d83zz stroke:#a170ff
Chroma-0gshk[<div><img src="/_astro/chroma.CDTUBZSx.svg" style="height: 20px !important;width: 20px !important"/></div>Chroma DB2]
style Chroma-0gshk stroke:#a170ff
ChatInput-larrt -.- LanggraphReactAgent-e7sh0
linkStyle 0 stroke:#a170ff
GoogleGenerativeAIModel-hrflu -.- LanggraphReactAgent-e7sh0
linkStyle 1 stroke:#a170ff
LanggraphReactAgent-e7sh0 -.- ConditionalRouter-e0whx
linkStyle 2 stroke:#a170ff
ChatInput-larrt -.- ConditionalRouter-e0whx
linkStyle 3 stroke:#a170ff
ChatInput-larrt -.- ConditionalRouter-k37bb
linkStyle 4 stroke:#a170ff
ChatInput-larrt -.- ConditionalRouter-7onzp
linkStyle 5 stroke:#a170ff
LanggraphReactAgent-e7sh0 -.- ConditionalRouter-k37bb
linkStyle 6 stroke:#a170ff
LanggraphReactAgent-e7sh0 -.- ConditionalRouter-7onzp
linkStyle 7 stroke:#a170ff
ConditionalRouter-e0whx -.- LanggraphReactAgent-feiuj
linkStyle 8 stroke:#a170ff
GoogleGenerativeAIModel-0aobu -.- LanggraphReactAgent-feiuj
linkStyle 9 stroke:#a170ff
ConditionalRouter-k37bb -.- LanggraphReactAgent-r6l2z
linkStyle 10 stroke:#a170ff
APIRequest-78xr1 -.- LanggraphReactAgent-r6l2z
linkStyle 11 stroke:#a170ff
ConditionalRouter-7onzp -.- LanggraphReactAgent-py6gc
linkStyle 12 stroke:#a170ff
GoogleGenerativeAIModel-y15kz -.- LanggraphReactAgent-r6l2z
linkStyle 13 stroke:#a170ff
GoogleGenerativeAIModel-gta86 -.- LanggraphReactAgent-py6gc
linkStyle 14 stroke:#a170ff
TelegramMessage-zvrp9 -.- LanggraphReactAgent-py6gc
linkStyle 15 stroke:#a170ff
LanggraphReactAgent-py6gc -.- ChatOutput-0vfib
linkStyle 16 stroke:#a170ff
LanggraphReactAgent-r6l2z -.- ChatOutput-7h910
linkStyle 17 stroke:#a170ff
LanggraphReactAgent-feiuj -.- ChatOutput-16z2g
linkStyle 18 stroke:#a170ff
Prompt-c8k88 -.- LanggraphReactAgent-r6l2z
linkStyle 19 stroke:#a170ff
GoogleGenerativeAIModel-lcmte -.- LanggraphRAGAgent-4j24w
linkStyle 20 stroke:#a170ff
ParseData-dpd2k -.- SplitText-xm92m
linkStyle 21 stroke:#a170ff
GDriveFilesComponent-q2n9y -.- ParseData-dpd2k
linkStyle 22 stroke:#a170ff
LanggraphRAGAgent-4j24w -.- LanggraphReactAgent-feiuj
linkStyle 23 stroke:#a170ff
Chroma-d83zz -.- LanggraphRAGAgent-4j24w
linkStyle 24 stroke:#a170ff
GoogleGenerativeAIEmbeddings-fnjt0 -.- Chroma-d83zz
linkStyle 25 stroke:#a170ff
SplitText-xm92m -.- Chroma-0gshk
linkStyle 26 stroke:#a170ff
GoogleGenerativeAIEmbeddings-mn2ew -.- Chroma-0gshk
linkStyle 27 stroke:#a170ff
🧩 Visão Geral
O fluxo de trabalho é um assistente de atendimento ao cliente que interpreta a mensagem do usuário, classifica o pedido em um de três níveis de intenção e o direciona para o respondedor automatizado apropriado.
No nível mais baixo, ele realiza recuperação baseada em conhecimento usando um agente RAG (Retrieval-Augmented Generation).
No nível intermediário, ele chama uma API externa e retorna o resultado.
No nível mais alto, ele faz a escalada da solicitação para a equipe humana enviando uma notificação pelo Telegram.
Todos os agentes produzem uma resposta exibida na interface de chat, mantendo a experiência do usuário contínua e consistente.
⚙️ Principais Funcionalidades
- Classificação de intenção que determina se a consulta é informativa, requer recuperação de dados ou precisa de intervenção humana.
- Recuperação RAG que consulta uma base vetorial construída a partir de documentos da empresa.
- Integração com API que obtém dados em tempo real de um serviço externo.
- Escalada via Telegram que notifica a equipe de suporte quando um pedido não pode ser tratado automaticamente.
- Interface de chat unificada que exibe os resultados de cada agente no mesmo fluxo conversacional.
🔄 Etapas do Fluxo de Trabalho
| Nome do Componente |
Função no Fluxo de Trabalho |
Entradas Principais |
Saídas Principais |
| Chat Input |
Recebe o texto bruto do usuário. |
Mensagem do usuário |
Mensagem do usuário |
| Intent Detection Agent |
Classifica a intenção como nivel1, nivel2 ou nivel3. |
Mensagem do usuário |
Palavra-chave da intenção |
| Intent Router (nivel1) |
Direciona a intenção nivel1 para o agente RAG. |
Palavra-chave da intenção |
Rota verdadeiro/falso |
| Level 1 Retrieval Agent |
Realiza RAG usando embeddings e uma base vetorial, depois gera uma resposta em linguagem natural. |
Mensagem do usuário |
Texto da resposta |
| Level 1 Chat Output |
Exibe a resposta RAG para o usuário. |
Texto da resposta |
Mensagem exibida |
| Intent Router (nivel2) |
Direciona a intenção nivel2 para o agente de API. |
Palavra-chave da intenção |
Rota verdadeiro/falso |
| Level 2 API Agent |
Chama um endpoint HTTP externo, interpreta o resultado e formata a resposta. |
Mensagem do usuário |
Texto da resposta da API |
| Level 2 Chat Output |
Exibe o resultado da API ao usuário. |
Texto da resposta da API |
Mensagem exibida |
| Intent Router (nivel3) |
Direciona a intenção nivel3 para o agente de notificação Telegram. |
Palavra-chave da intenção |
Rota verdadeiro/falso |
| Level 3 Notification Agent |
Envia uma mensagem ao Telegram para solicitar atendimento manual pela equipe. |
Mensagem do usuário |
Notificação Telegram |
| Level 3 Chat Output |
Confirma ao usuário que o pedido foi escalado. |
Confirmação de escalada |
Mensagem exibida |
Os embeddings, a base vetorial e as configurações das ferramentas são inicializados uma única vez no início do fluxo e reutilizados para cada solicitação.
🧠 Notas
- O agente de detecção de intenção é um classificador LLM leve que retorna uma única palavra-chave; ele usa o system prompt para impor respostas estritas de uma palavra.
- O agente RAG utiliza uma base vetorial Chroma e embeddings do Google Gemini. Ele está configurado com um pipeline que incorpora o texto de entrada, busca os documentos mais relevantes e aprimora a resposta do LLM.
- O agente de API recebe uma ferramenta
APIRequest; seu system prompt garante que o LLM formule chamadas apenas usando a interface fornecida.
- O agente Telegram usa um token dedicado de bot e envia apenas notificações de texto simples (
Send Text).
- Todos os agentes são encapsulados como agentes Langgraph React, permitindo que sejam usados como ferramentas uns para os outros, possibilitando roteamento dinâmico dentro de um único grafo.
- O fluxo supõe que a consulta do usuário sempre corresponderá a uma das três categorias de intenção; se nenhuma corresponder, o ramo padrão permanece silencioso e nenhuma resposta é produzida.
- Os componentes
ConditionalRouter fazem comparações de igualdade de strings; eles são insensíveis a maiúsculas/minúsculas por padrão.
- A base vetorial e os embeddings são configurados com fragmentos de 1000 caracteres e sobreposição de 200 caracteres, equilibrando comprimento de contexto e continuidade semântica.