Skip to main content

Smart Router

The Smart Router component is an LLM-powered variation of the If-Else component. Instead of string matching, the Smart Router uses a connected Language Model component to categorize and route incoming messages.

You can use the Smart Router component anywhere you would use the If-Else component. For an example, create the If-Else component example flow, then replace the If-Else component with a Smart Router component. Instead of a regex, use the Routes table to define the outputs for your messages.

The Routes table defines the categories for routing. For example, a routes table for sentiment analysis might look like this:

Route NameRoute DescriptionRoute Message
PositivePositive feedback, satisfaction, or compliments
NegativeComplaints, issues, or dissatisfaction
NeutralQuestions, requests for information, or neutral statementsThank you for your inquiry!

This component creates ports for the Positive, Negative, and Neutral routes. When the LLM categorizes the input text, it routes to the matching category's output port by route name. For the Positive and Negative routes, the original input text is passed through. For the Neutral route, the "Thank you for your inquiry!" route message is sent instead of the input text.

The Override Output parameter sends a single message regardless of which route the LLM matches. The override message takes precedence over all other output options, and completely replaces both the original input text and any custom route messages. For the sentiment analysis example, if you set the Override Output to "Message received", all routes send the same message.

The Additional Instructions parameter adds extra guidance to the LLM. Use the {input_text} placeholder to reference the input text being categorized, and {routes} to reference the comma-separated list of route names.

For example, to add domain-specific context for the LLM, include the following as the custom prompt:


_10
The text "{input_text}" is from a customer support context.
_10
Consider the urgency and emotional tone when choosing from {routes}.

Smart Router parameters

Some parameters are hidden by default in the visual editor. You can modify all parameters through the Controls in the component's header menu.

NameTypeDescription
Language ModelLanguageModelInput parameter. The language model to use for categorization. The LLM receives the input text and available categories, then returns the exact category name that matches. Required.
InputStringInput parameter. The primary text input for categorization. Required.
RoutesTableInput parameter. Table defining categories for routing. Each row contains a route name (required), an optional route description to help LLMs understand the category, and an optional custom output message. The component creates one output port for each route category. Required.
Override OutputMessageInput parameter. An optional override message that takes precedence over all other output options. When provided, this message replaces both the original input text and any custom route messages for all routes. Advanced.
Additional InstructionsStringInput parameter. Additional instructions for LLM-based categorization. These are added to the base classification prompt, which already includes the full Routes table (names and descriptions). Use {input_text} for the input text and {routes} for a comma-separated list of route names only.
Include Else OutputBooleanInput parameter. Include an Else output for cases that don't match any route. When disabled, no output is produced if no match is found. Default: false.
ElseMessageOutput parameter. The Else output. Only available when Include Else Output is true. Uses the override message (if provided) or the original input text when no route matches.
Search