Smart Router
Smart Router
The Smart Router acts as an intelligent switch within the NappAI platform. Its primary function is to analyze user input or a dataset and determine, through AI reasoning, the predominant intent to redirect the flow to the most appropriate execution branch.
Unlike a router based on rigid keywords, this component uses language models to understand context and semantic nuances, allowing for much more precise and flexible classification. Each configured intent generates its own physical output on the node, enabling clean and efficient bifurcation of the graph logic.
Main Use Cases
Use the Smart Router Agent to develop solutions requiring:
- Intelligent Multichannel Support: Classifying whether an incoming ticket is a complaint, a technical question, or a thank you, sending it to the correct department.
- Natural Voice or Chat Menus: Replacing numerical menus with a natural language interface that understands what the user wants.
- Conditional Data Processing: In batch processing flows, deciding which records should be audited and which can be automatically approved.
- Security Filtering: Identifying malicious or out-of-context intents before they reach more expensive or sensitive agents.
Fundamental Configuration
These parameters define the classification logic and the intelligence engine.
| Parameter | Technical Description | Purpose in the Flow |
|---|---|---|
Data Input | The object or message the router must analyze to classify. | The source of information on which the intent analysis will be performed. |
Model (llm) | The connection to the Language Model (LLM) that will perform the classification. | Acts as the cognitive engine that interprets the input against the intent descriptions. |
Number of Intentions | Number of output routes the agent should enable. | Determines how many bifurcation options the node will have (e.g., 3 intents will create 3 outputs). |
Intention [X] Name | Route identifier name (e.g., technical_support). | Defines the output label and the category name for the LLM. |
Intention [X] Description | Detailed description of when this route should be chosen. | Critical Note: Provide clear descriptions; the LLM uses this text to decide if the input fits here or not. |
Advanced Features
The Smart Router includes capabilities to adjust precision and handle large volumes of data.
Intention Accuracy: Certainty Control
Confidence Threshold: Defines the minimum certainty level (0.0 - 1.0) to classify an intent. If the model’s confidence is lower than the threshold (e.g., 0.7), the router can avoid making an erroneous decision or send the query to a default route.
Batch Mode: Massive Processing
Batch Mode (mapping_mode): Allows processing a list of items individually and in parallel. Each item in the list is classified and sent to its corresponding output.Parallel Executions: Defines how many items in the batch are processed simultaneously (Range 1-5). Optimizes execution time in massive classification tasks.Skip if Empty Batch Input: Prevents errors by stopping component execution if the input list is empty.
Run Conditions: Flow Control
Skip Branch if Empty Output: If the router does not find a valid classification or the output is null, it stops subsequent execution branches to avoid chain failures in later components.
Context and Memory: State Management
Use Memory (use_checkpointer): Allows the router to consider previous interactions to classify the current intent, ideal for conversations where the intent becomes clearer over the course of the dialogue.
Component Outputs
The node will dynamically generate as many outputs as defined in the Number of Intentions parameter.
Intention 1...X: The original data is redirected to the specific output that matches the detected intent.Default: (Optional) Escape route when no intent meets the minimum confidence threshold.
Tips and Best Practices
- Mutually Exclusive Descriptions: Ensure intent descriptions do not overlap. The more distinct they are from each other, the better the router’s performance.
- Confidence Threshold: A value of
0.7is ideal for most cases. Increase it to0.9for critical tasks where routing errors are not permitted. - Use as a Tool: By completing the
Agent Description, this router can be invoked by a Supervisor Agent so the latter knows it can be used for user classification.
You can watch a video showing the power of the Smart Router here.