Chapter 3: Classify and handle each enquiry
In the same project as the previous chapter, now build the part that talks to the customer. It has three pieces: an agent that classifies the enquiry, three branches that send it to the right level, and three specialised agents that resolve it.
1. The classifier
Add a Chat Input, an Agent and a Gemini. Rename the Agent to Classifier with the pencil icon.
| From | Output | To | Input |
|---|---|---|---|
| Chat Input | Message | Classifier | Input |
| Gemini | Model | Classifier | Model |
In Gemini, choose your credential in Credential and a model in Model.
In the Classifier’s System Prompt, write:
You classify customer service enquiries for an online shop.Read the customer's message and answer with a single word: level1, level2 or level3.
- level1: general questions about the shop (shipping, returns, opening hours, terms).- level2: questions about the status of an order or about specific products.- level3: return requests, or when the customer asks to speak to a person.
Answer only with the word, without explanations.2. The branches
Add three Conditional Router components. Each one compares the Classifier’s answer with a level and, if it matches, lets the customer’s original message through its True Route output.
Connect all three the same way:
| From | Output | To | Input |
|---|---|---|---|
| Classifier | Response | Conditional Router | Input Text |
| Chat Input | Message | Conditional Router | Message |
Configure them like this:
| Router | Operator | Match Text |
|---|---|---|
| First | equals | level1 |
| Second | equals | level2 |
| Third | equals | level3 |
That way the specialised agent receives the question exactly as the customer wrote it, not the Classifier’s word.
3. The specialised agents
Each level has its own Agent, with its own Gemini connected to Model and a Chat Output for the answer. In each one, connect:
| From | Output | To | Input |
|---|---|---|---|
| Its Conditional Router | True Route | Agent | Input |
| Agent | Response | Chat Output | Text |
And give each agent its tool, connecting the tool’s Tool output to the agent’s Tools input.
Level 1: answers from the policies
- Tool: a Chroma DB with its own Google Generative AI Embeddings connected to Embedding.
- Chroma DB: Operation set to Search, the same Collection Name as in chapter 2 (
shop_policies) and Persist Directory empty. In Search Query, click the sparkles button so the agent writes the search (Defined by AI). - The agent’s System Prompt:
Answer the customer's question using only the information you find with your search tool.If you can't find the answer, say so and offer to put them in touch with the support team.Level 2: the order status
- Tool: an API Request.
- API Request: in URLs, type the address of your shop’s orders API. If it changes with the order number, click the sparkles button so the agent completes it. If the API needs a key, add it in Headers. In Advanced, write in Tool Description what it returns, for example Checks the status of an order from its number.
- The agent’s System Prompt:
Use your tool to check the status of the order the customer is asking about and explain it clearly.If the customer hasn't given the order number, ask for it.Level 3: alert the support team
- Tool: a Telegram Message.
- Telegram Message: choose your bot credential in Credential and Send Text in Action. In Mode, choose Advanced and type the support team’s chat in Chat ID. In Text, click the sparkles button so the agent writes the alert.
- The agent’s System Prompt:
Send the support team an alert with the customer's request using your Telegram tool.Then tell the customer their case has been passed to the team and that they will be contacted.4. Test it
Open Playground and try one enquiry for each level:
- How long does shipping to the Canary Islands take? (level 1)
- Where is my order 10234? (level 2)
- I want to return a product, can someone help me? (level 3)
In Executions you’ll see what the Classifier answered, which branch the enquiry went through and what the specialised agent did. If an enquiry doesn’t reach any agent, check that the Classifier answers exactly level1, level2 or level3.