Skip to content

Chapter 3: The Agent and Routing System

With the knowledge base ready, it is time to build the main flow that will interact with the user.

1. The Intent Classifier: The Orchestrating Brain

This is the first and most important part of the flow.

  1. Add Components: Place a Chat Input, an Agent (rename it to “Intent Detector”), and a Gemini.
  2. Connections:
    • Connect the message output of Chat Input to the input_value input of the Intent Detector.
    • Connect the model_output output of Gemini to the llm input of the Intent Detector.
  3. Intent Detector Configuration:
    • System Prompt:
      You are an intent classifier for customer service.
      Analyze the user's message and respond with ONE SINGLE word: "nivel1", "nivel2", or "nivel3".
      Classification Criteria:
      - "nivel1": Inquiries about company information.
      - "nivel2": Inquiries about order status or system information such as products.
      - "nivel3": Requests for product returns or need for human intervention as requested by the client.
      Only respond with the corresponding word, without additional explanations.

2. The Decision Hub: Configuring the Routers

Unlike a chained system, we will connect three Conditional Routers in parallel to create an efficient decision hub.

  1. Add Components: Place three Conditional Router components.
  2. Parallel Connections:
    • Connect the response output of the Intent Detector to the input_text input of ALL THREE routers.
    • Connect the message output of the original Chat Input to the message input of ALL THREE routers. (This is crucial for the original question to reach the final agent).
  3. Configuration of Each Router:
    • Router 1: Match Text -> nivel1. The true_result output will activate the Level 1 Agent.
    • Router 2: Match Text -> nivel2. The true_result output will activate the Level 2 Agent.
    • Router 3: Match Text -> nivel3. The true_result output will activate the Level 3 Agent.

3. The AI Departments: Specialized Agents

Finally, build a branch for each level, connecting the true_result output of the corresponding router.

  • Agente Nivel 1 (Knowledge Department - RAG):

    • Components: An Agent, a Gemini, a RAG Agent as a tool, and a Chroma DB.
    • Connections: The true_result output of Router 1 connects to the input_value input of the Agent. This agent uses the RAG Agent as a tool, which in turn uses a Chroma DB configured in Retriever mode.
    • Chroma DB Configuration: Use the same Collection Name (ecommerce_policies) as in Chapter 2.
    • Agent’s System Prompt: Answer the user's question based solely on the information provided by your search tool.
  • Agente Nivel 2 (Systems Department - API):

    • Components: An Agent, a Gemini, and an API Request as a tool.
    • Connections: The true_result output of Router 2 connects to the input_value input of the Agent. The API Request connects to its tools input.
    • Agent’s System Prompt: Your sole function is to use the API tool to query the order status and communicate the result clearly to the user.
  • Agente Nivel 3 (Human Support Department - Escalation):

    • Components: An Agent, a Gemini, and a Telegram Message as a tool.
    • Connections: The true_result output of Router 3 connects to the input_value input of the Agent. The Telegram Message connects to its tools input.
    • Agent’s System Prompt: Use your Telegram tool to notify the support team about the customer request. Then, inform the user that their case has been escalated and that they will be contacted shortly.