Tutorial: Approval Workflow Automation | LanSphere User Guide

Tutorial: Approval Workflow Automation

Using “approval workflow automation” as the example, this tutorial shows how Conditional Branch multi-path routing, LLM-assisted summarization, and Lansenger MCP notifications combine in a LanSphere Workflow. It is for developers who need tiered approval by amount and real-time result notification via Lansenger.

Scenario and Value

Traditional approval flows rely on manual handoffs, with plenty of issues:

  • Different amounts require different approval levels — manual judgment easily routes to the wrong flow;
  • Results are communicated verbally or by email, and applicants may not learn in time;
  • High-amount approvals lack a synchronous notification mechanism — audit/compliance has to catch up after the fact;
  • Opinion formats are inconsistent, making post-hoc tracing time-consuming.

Automate the approval chain with a Workflow: receive the request → Conditional Branch routes by amount tier → LLM generates an opinion summary → Lansenger MCP notifies the applicant and relevant leaders. The whole flow is unattended and traceable.

What You Will Build

An “Approval Automation” Workflow app: it receives an approval request (applicant, amount, reason, type). A Conditional Branch node splits it into three paths by amount — low (< 5000) auto-pass, medium (5000-50000) department-head approval, high (> 50000) executive-leader approval. An LLM node assists in generating an opinion summary. MCP nodes send Lansenger notifications to the applicant; high-amount approvals additionally notify audit/compliance. An Output node returns the approval result.

Chain: Input → Conditional Branch → [Low auto-pass] / [Medium → LLM summary → MCP (notify head)] / [High → LLM summary → MCP (notify executive leader) → MCP (notify audit)] → Output.

Step Description
1 Prepare Add the Lansenger MCP Service; confirm approvers’ Lansenger accounts
2 Create the app New Workflow; configure the Input node to collect approval-request fields
3 Orchestrate the canvas Conditional Branch to three paths → LLM summary → MCP notification → Output
4 Debug per branch Verify routing, summary, and notification for each amount tier
5 Save and go live Publish to the Application Square or enable API access for business systems

Preparation

Item Requirement
Platform role Developer or above (create Workflows, add MCP Services)
Lansenger MCP Service The Lansenger MCP Service added under “left menu → MCP Services,” with the “Send Private Message” tool available
Approver accounts Lansenger accounts (staffId or phone number) for the department head, executive leader, and audit/compliance staff — used for MCP private messages
Approval rules Confirmed amount-tier thresholds (5000 / 50000 in this example) and approvers per tier with management

Step 1: Create the App and Configure Input

  1. Click “New Project,” pick the app type “Workflow,” and fill in the name (e.g., “Approval Automation”).
  2. The “Input” node exists by default. Define the approval-request fields to collect:
Field Type Description
applicant Text Applicant name
amount Number Requested amount (CNY)
reason Text Request reason
category Text Request type (e.g., procurement, travel, reimbursement)
  1. Add approver-account Environment Variables (e.g., MANAGER_ID, DIRECTOR_ID, AUDITOR_ID) with the corresponding Lansenger staffId values — mark them as secret variables.

Note: Keeping approver accounts in Environment Variables makes personnel changes easy — only the variable value changes, not the canvas. Do not write them directly into node configurations.

Step 2: Orchestrate the Conditional Branch

  1. Add a “Conditional Branch” node, connected after the “Input” node.
  2. Configure three branches, judging by the amount field:
Branch Condition Target
Low auto-pass amount < 5000 Connect directly to the Output node
Medium approval 5000 <= amount <= 50000 LLM → MCP (notify department head)
High approval amount > 50000 LLM → MCP (notify executive leader) → MCP (notify audit)
  1. The low auto-pass branch can connect directly to the Output node — no approval or notification needed.

Step 3: LLM Generates Approval Opinion Summary

In the medium and high branches, add an “LLM” node. Reference the Input node’s request fields as context. Sample prompt:

You are an approval summary assistant. Below is the approval request submitted by an employee:

Applicant: (insert applicant variable here)
Amount: (insert amount variable here) CNY
Reason: (insert reason variable here)
Type: (insert category variable here)

Generate an approval opinion summary with these requirements:
1. Summarize the request in one sentence (applicant + amount + reason).
2. Assess whether the reason is reasonable and whether the amount matches the reason.
3. Give a suggested approval result (recommend approval / recommend rejection) with justification.
4. Keep it within 150 characters, concise and formal.

Tip: The LLM node here assists in generating a summary and suggestion; the final approval decision is still confirmed by a human. The summary is sent to the approver via Lansenger notification for reference.

Step 4: MCP Nodes Notify Approvers

  1. After the LLM node in the medium branch, add an MCP node and select the Lansenger MCP Service’s “Send Private Message” tool.
  2. Set the recipient to reference the Environment Variable MANAGER_ID; set the message content to reference the LLM node’s output (the approval opinion summary).
  3. After the LLM node in the high branch, add two MCP nodes in sequence:
    • First: recipient references DIRECTOR_ID; message content references the LLM output;
    • Second: recipient references AUDITOR_ID; message content also references the LLM output (synchronous notification to audit).

Note: The two MCP nodes in the high branch are serially connected — notify the executive leader first, then audit. To send in parallel, use a “Batch Processing” node to send to multiple recipients in batch.

Step 5: Connect the Output Node

  1. All three branches ultimately connect to the “Output” node. The output content references each branch’s processing result:
    • Low auto-pass: reference the original request fields, annotated “low-amount auto-pass”;
    • Medium/High: reference the LLM node’s summary and the MCP node’s send result.
  2. The Workflow returns the approval-routing result at the end through the “Output” node.

Node Configuration Quick Reference

Node Key configuration Notes
Input Collect applicant / amount / reason / category Approval-request entry
Conditional Branch Three amount branches Routes by amount
LLM (medium/high) Summary prompt + reference request fields Generates approval opinion summary
MCP (Send Private Message) Recipient references Environment Variable; content references LLM output Lansenger notification to approver
Output Reference each branch’s result Returns approval-routing result

Step 6: Debug Step by Step

  1. Test each branch with the three amount tiers:
Test scenario Input example Expected path
Low auto-pass Amount 3000, procurement of office supplies Direct to output, no notification
Medium approval Amount 20000, business travel LLM summary → notify department head
High approval Amount 80000, equipment procurement LLM summary → notify executive leader → notify audit
  1. Check node by node:
    • Conditional Branch: confirm the amount went to the correct branch;
    • LLM: confirm the summary includes the request content and suggested result, with no fabrication;
    • MCP node: confirm the approver received a private message in Lansenger, with readable content;
    • High branch: confirm both the executive leader and audit received the notification.
  2. 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
Amount routed incorrectly Whether the Conditional Branch thresholds are correct; whether the amount field type is numeric
LLM summary missing suggested result Whether the “give a suggested approval result” requirement survived in the prompt; whether the context variable reference is correct
Lansenger notification not delivered Whether the recipient staffId is correct; whether the Lansenger MCP Service authorization is valid; the MCP node’s error info
High branch only notified one party Whether both MCP nodes are correctly connected; whether the second MCP’s recipient variable is correctly referenced

Step 7: Save and Go Live

  1. Click “Save” to save the Workflow. The pre-publish Checklist automatically checks configuration completeness and logic — fill any gaps as prompted.
  2. Click the “Save” button dropdown → “Publish to Application Square,” or enable API access through the “Publish Channels” tab for OA and other business systems to call.
  3. After going live, open the app details page → “Conversation Logs” tab to review each approval’s routing record and each node’s intermediate process.

Tip: In the early days after going live, have a human confirm the LLM’s suggested result before sending notifications. Once summary quality stabilizes, open up auto-notification.

Tuning and Boundaries

Symptom Adjustment
Amount thresholds need adjustment Modify the Conditional Branch conditions and re-save — no need to change the canvas structure
Approver changes Update the staffId in the Environment Variable — no canvas change needed
Summary quality unstable Add approval-rule constraints in the prompt (e.g., amount caps per type) to strengthen the judgment logic
Need multi-level serial approval Chain multiple LLM + MCP nodes within a branch — notify and confirm level by level
Need a rejection flow Add a Conditional Branch to handle the rejection scenario; notify the applicant of the rejection reason via MCP

Ideas for Extension

  • Parallel notification: Use a “Batch Processing” node to send to multiple approvers simultaneously, cutting wait time;
  • Approval record persistence: Add an “HTTP Request” node before the output to write approval records into the OA-system database;
  • Timeout reminders: Package the Workflow as a scheduled task that periodically checks unprocessed approvals and reminds via Lansenger;
  • Smart pre-review: Add an “LLM” node before the Conditional Branch to pre-judge the reasonableness of the request — flag anomalous requests as warnings;
  • Multi-dimensional routing: Beyond amount, further tier approval levels by request type (procurement / travel / reimbursement).