Tutorial: Auto-Sorting and Replying to Support Tickets
Using “auto-sorting and replying to support tickets” as the example, this tutorial shows how Input, Conditional Branch, Knowledge Base, LLM, and MCP tools combine in a LanSphere Chatflow for multi-branch orchestration. It is for developers who need to auto-classify content, retrieve suggested replies from knowledge bases, and connect to an external ticketing system.
Scenario and Value
Customer support handles a large volume of tickets every day, and processing them one by one by hand is inefficient:
- Ticket types are mixed — support staff must read each one to decide who to route it to and how to reply;
- The same questions get answered repeatedly, with inconsistent tone across agents;
- IT-fault tickets need to be created in the ticketing system at the same time — manual entry is error-prone;
- Backlogs pile up during peak hours, leaving users waiting.
Automate this chain with a Chatflow: receive ticket text → auto-classify with Conditional Branch → each branch retrieves from the corresponding Knowledge Base → LLM generates a suggested reply → IT-fault tickets also create a ticket via MCP. Support staff only review and send, so both efficiency and consistency hold up.
What You Will Build
A “Ticket Sorting Assistant” Chatflow app: it receives ticket text submitted by users, and a Conditional Branch node classifies it into four types — IT Fault, Administrative, HR Inquiry, and Financial Reimbursement. Each branch connects to the corresponding Knowledge Base to retrieve a suggested reply, and an LLM node generates the final reply. IT-fault tickets additionally connect to an MCP node that creates a ticket in the ticketing system. The app is published to the Application Square for support staff to use.
Chain: Input → Conditional Branch → [IT Fault → Knowledge Base → LLM → MCP (Create Ticket)] / [Administrative → Knowledge Base → LLM] / [HR → Knowledge Base → LLM] / [Financial → Knowledge Base → LLM] → Reply.
Recommended Flow
| Step | Description |
|---|---|
| 1 Prepare | Create four Knowledge Bases; add Lansenger MCP and ticketing-system MCP Services |
| 2 Create the app | New Chatflow; configure the Input node to receive ticket text |
| 3 Orchestrate the canvas | Conditional Branch to four paths → Knowledge Base per path → LLM → add MCP on the IT-fault path |
| 4 Debug per branch | Verify classification, recall, and reply quality for each branch |
| 5 Save and go live | Publish to the Application Square; support staff review and send |
Preparation
| Item | Requirement |
|---|---|
| Platform role | Developer or above (create Chatflows, add MCP Services) |
| Knowledge Bases | Four Knowledge Bases created (IT Operations, Administrative Policies, HR Policies, Financial Reimbursement), each passing recall testing |
| Lansenger MCP Service | The Lansenger MCP Service added under “left menu → MCP Services,” with messaging tools available (to notify support staff for review) |
| Ticketing-system MCP Service | The ticketing system’s MCP Service added, with the “Create Ticket” tool available |
| Ticket classification rules | Confirmed keyword or feature rules for the four ticket types with the support team |
Step 1: Create the App and Configure Input
- Click “New Project,” pick the app type “Chatflow,” and fill in the name (e.g., “Ticket Sorting Assistant”).
- The “Input” node exists by default as the conversation entry. In the Input node, define the fields to collect — at minimum
ticket_textfor this scenario; optionally submitter name, contact info, etc.
Step 2: Orchestrate the Conditional Branch
- Click to add a “Conditional Branch” node, connected after the “Input” node.
- Configure four branches, judging by keywords or features in the ticket text:
| Branch | Condition (example) | Target |
|---|---|---|
| IT Fault | Text contains “network,” “system,” “cannot log in,” “error,” etc. | Knowledge Base (IT Operations) |
| Administrative | Text contains “office supplies,” “meeting room,” “vehicle,” etc. | Knowledge Base (Administrative Policies) |
| HR Inquiry | Text contains “annual leave,” “social insurance,” “onboarding,” “resignation,” etc. | Knowledge Base (HR Policies) |
| Financial Reimbursement | Text contains “reimbursement,” “invoice,” “payment,” etc. | Knowledge Base (Financial Reimbursement) |
- Configure a fallback branch (default branch) — when no type matches, it goes to a generic reply.
Tip: When keywords cannot cover all scenarios, switch to an “Intent Recognition” node for semantic classification with higher accuracy; however, Intent Recognition relies on LLM inference and is slightly slower, so prefer Conditional Branch when keyword matching is sufficient.
Step 3: Connect Knowledge Base and LLM per Branch
Each classification branch follows the same chain. Using the IT-fault branch as an example:
- Add a “Knowledge Base” node, associate the IT Operations Knowledge Base, set the input to reference
ticket_text, set Top K to 3, and set retrieval mode to hybrid retrieval. - Add an “LLM” node, connected after the Knowledge Base. Reference the Knowledge Base’s recall snippets and the original ticket text as context. Sample prompt:
You are a support reply assistant. Below are the ticket content submitted by the user and the relevant content retrieved from the Knowledge Base:
Ticket content: (insert the ticket_text variable from the Input node here)
Retrieval results: (insert the Knowledge Base node's output variable here)
Generate a suggested reply with these requirements:
1. First restate the user's question to confirm correct understanding.
2. Provide handling suggestions based on the retrieval results, in bullet points.
3. When the retrieval results contain no answer, clearly reply: "No standard handling plan found; this has been forwarded to the technical team."
4. Append the citation source (file name + section) at the end of the reply.
5. Keep it within 300 characters, professional and concise in tone.
- The Administrative, HR, and Financial branches follow the same pattern — connect their respective Knowledge Bases and LLMs with identical prompt structures; only the Knowledge Base association differs.
Step 4: Connect MCP to Create Tickets on the IT-Fault Branch
IT-fault tickets need to be created in the ticketing system at the same time. After the LLM node on this branch, add an MCP node:
- Click to add a tool-type node, pick the “MCP” category, and find the “Create Ticket” tool of the ticketing-system MCP Service in the tool list.
- Set the ticket title to reference
ticket_text(or the summary generated by the LLM node), the ticket content to reference the original ticket text, and other fields (priority, category) per the ticketing system’s requirements or variable references.
Note: If the ticketing system does not yet provide an MCP Service, temporarily use an “HTTP Request” node to call the ticketing-system API instead. See the HTTP Request node in “Node Reference” for configuration.
Step 5: Converge on Reply
- All four branches ultimately need to output a reply to the user. After each branch’s LLM node (or MCP node), connect a “Reply” node with the reply content referencing the LLM node’s output.
- The fallback branch connects to an “LLM” node that generates a generic reply (e.g., “Your ticket has been received and will be forwarded to the relevant team”), then connects to a “Reply” node.
Node Configuration Quick Reference
| Node | Key configuration | Notes |
|---|---|---|
| Input | Collect ticket_text field |
Ticket text entry |
| Conditional Branch | Four keyword branches + fallback | Routes by ticket type |
| Knowledge Base (×4) | Associate one of four KBs each; Top K 3; hybrid retrieval | Each path retrieves corresponding knowledge |
| LLM (×4) | Reply prompt + reference recall snippets and ticket text | Generates suggested reply |
| MCP (Create Ticket) | IT-fault branch only; title references ticket text | Creates ticket in ticketing system |
| Reply | Reference LLM output | Outputs suggested reply to support staff |
Step 6: Debug Step by Step
- Test each branch with typical ticket text for the four types:
- IT Fault: “Cannot log in to the OA system; it says password is wrong but I haven’t changed it.”
- Administrative: “Request a meeting room for next Tuesday morning; need a projector.”
- HR Inquiry: “I’ve been here one year — how many days of annual leave do I get?”
- Financial Reimbursement: “What should the invoice header say for travel reimbursement?”
- Check node by node:
- Conditional Branch: confirm the ticket went to the correct branch;
- Knowledge Base: confirm recall snippets are relevant to the ticket question;
- LLM: confirm the reply is based on Knowledge Base content, with no fabrication, and the format matches the prompt requirements;
- MCP node (IT-fault path): confirm a ticket was successfully created in the ticketing system.
- Test the fallback branch: submit an unclassifiable ticket and confirm it goes to the default reply.
- Each node’s input, output, and errors are visible in the debug details; past runs are in “Debug History.”
Troubleshooting common problems:
| Symptom | Where to look |
|---|---|
| Ticket misclassified | Whether the keyword list covers common phrasings; consider switching to Intent Recognition for semantic classification |
| Knowledge Base recall irrelevant | Re-check the corresponding KB with recall testing; increase Top K; enable the reranking model |
| LLM reply contains fabrication | Whether the context variable reference is correct; whether the “say so when no answer” constraint survived in the prompt |
| MCP ticket creation failed | Whether the MCP Service authorization is valid; whether ticket fields meet the system’s requirements; check the MCP node’s error info |
| Fallback branch not triggered | Whether the Conditional Branch’s default branch is correctly configured; whether branch conditions overlap and cause mismatches |
Step 7: Save and Go Live
- Click “Save” to save the Chatflow. The pre-publish Checklist automatically checks configuration completeness and logic — fill any gaps as prompted.
- Click the “Save” button dropdown → “Publish to Application Square,” and support staff across the platform can use it.
- After going live, open the app details page → “Conversation Logs” tab to review the actual ticket classification and reply records. Mark replies as good/bad and add annotation replies to continuously optimize prompts and Knowledge Bases.
Tip: In the early days after going live, have support staff review suggested replies before sending. Once classification and reply quality stabilize, gradually open up auto-reply.
Tuning and Boundaries
| Symptom | Adjustment |
|---|---|
| Same ticket matches multiple branches | Narrow keyword scope, or switch to Intent Recognition (mutually exclusive classification) |
| Poor recall for a ticket type | Tuning the segmentation strategy or adding documents for that specific KB |
| LLM reply too long | Strengthen the length limit in the prompt; reduce the number of bullet points |
| Ticketing-system MCP unavailable | Temporarily use an HTTP Request node to call the API, or remove the ticket-creation node and create manually |
| Adding a new ticket type | Add a branch in Conditional Branch, associate a new Knowledge Base, and copy the existing branch chain |
Ideas for Extension
- Intent Recognition instead of keywords: When ticket descriptions are colloquial and keywords fall short, use an “Intent Recognition” node for semantic classification with higher accuracy;
- Auto-notify support staff: After the Reply node, add the Lansenger MCP “Send Private Message” tool to push the suggested reply to the corresponding agent;
- Satisfaction collection: Append a satisfaction-rating prompt at the end of the reply to gather user feedback for continuous improvement;
- Multi-level routing: Within the IT-fault type, further split into network/hardware/software sub-branches, each connected to a different Knowledge Base;
- Ticket status write-back: Use the ticketing-system MCP’s update tool to write the reply result back to the ticket record.

