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
🧩 Overview
The workflow is a customer‑service assistant that interprets a user’s message, classifies the request into one of three intent levels, and routes it to the appropriate automated responder.
At the lowest level it performs knowledge‑base retrieval using a Retrieval‑Augmented Generation (RAG) agent.
At the medium level it calls an external API and returns the result.
At the highest level it escalates the request to human staff by sending a Telegram notification.
All agents produce a reply that is displayed in the chat interface, keeping the user experience seamless and consistent.
⚙️ Main Features
- Intention classification that determines whether a query is informational, requires data retrieval, or needs human intervention.
- RAG retrieval that consults a vector database built from company documents.
- API integration that retrieves real‑time data from an external service.
- Telegram escalation that notifies the support team when a request cannot be auto‑handled.
- Unified chat interface that shows the result of each agent in the same conversational flow.
🔄 Workflow Steps
| Component Name |
Role in the Workflow |
Key Inputs |
Key Outputs |
| Chat Input |
Receives the raw text from the user. |
User message |
User message |
| Intent Detection Agent |
Classifies the intent as nivel1, nivel2 or nivel3. |
User message |
Intent keyword |
| Intent Router (nivel1) |
Directs nivel1 intent to the RAG agent. |
Intent keyword |
True/False route |
| Level 1 Retrieval Agent |
Performs RAG using embeddings and a vector store, then generates a natural‑language answer. |
User message |
Answer text |
| Level 1 Chat Output |
Displays the RAG answer to the user. |
Answer text |
Displayed chat message |
| Intent Router (nivel2) |
Directs nivel2 intent to the API agent. |
Intent keyword |
True/False route |
| Level 2 API Agent |
Calls an external HTTP endpoint, parses the result, and formats a response. |
User message |
API response text |
| Level 2 Chat Output |
Displays the API result to the user. |
API response text |
Displayed chat message |
| Intent Router (nivel3) |
Directs nivel3 intent to the Telegram notification agent. |
Intent keyword |
True/False route |
| Level 3 Notification Agent |
Sends a Telegram message to the support team to request manual handling. |
User message |
Telegram notification |
| Level 3 Chat Output |
Confirms to the user that their request has been escalated. |
Escalation confirmation |
Displayed chat message |
The embeddings, vector database, and tool configurations are instantiated once during workflow initialization and are reused for every request.
🧠 Notes
- The intent detection agent is a lightweight LLM classifier that outputs a single keyword; it uses the system prompt to enforce strict, one‑word responses.
- The RAG agent employs a Chroma vector store and Google Gemini embeddings. It is configured to use a retrieval pipeline that embeds incoming text, searches for the most relevant documents, and augments the LLM response.
- The API agent is supplied with an
APIRequest tool; its system prompt guarantees that the LLM will only formulate calls using the provided tool interface.
- The Telegram agent uses a dedicated Telegram bot token. It only sends plain text notifications (
Send Text operation).
- All agents are wrapped as Langgraph React agents, so they can be composed as tools for each other, allowing dynamic routing within a single graph.
- The workflow assumes that the user’s query will always match one of the three intent categories; if none match, the default branch is silent, and no reply is produced.
- The
ConditionalRouter components perform string equality checks; they are case‑insensitive by default.
- The vector store and embeddings are set up with a 1000‑character chunk size and a 200‑character overlap, which balances context length and semantic continuity.