- A main Chat Driven workflow that uses an Intent Classification Agent to route messages
- Built-in session memory that carries financial data across conversation turns
- A knowledge base Q&A handler that answers mortgage questions from uploaded documents
- A data collection handler that extracts user financial data from free-text messages
- A personalized offer generator using hybrid AI extraction + business rule calculations
- A small talk responder and fallback handler
Architecture overview
The app is a Chat Driven workflow that uses an Intent Classification Agent to classify each user message and route it to the right handler. Each intent maps to a separate output branch on the node, eliminating the need for a Condition node. Each handler terminates in a Custom Agent node with Send as Chat Reply enabled, which delivers the response directly to the Chat component and updates session memory.Data model
In a Chat Driven workflow, the Start node provides Chat Session ID, User Message, and an optional UI Flow Context as dedicated input fields — you reference them as${sessionId}, ${userMessage}, and ${context} in downstream nodes. These are not keys you declare in the data model.
mainChat data model
The mainChat workflow does not need any chat-specific keys in its data model — everything comes from the Start node fields and from handler subworkflow outputs.answerPersonalisedOffer data model
Prerequisites
Before starting, make sure you have:- Access to a FlowX Designer workspace with AI Platform enabled
- Familiarity with creating workflows in FlowX
- A Knowledge Base data source with mortgage-related documents uploaded (see Step 4)
Step 1: Build the main orchestration workflow
Create a workflow namedmainChat and select Chat Driven as the workflow type.

Review the Start node
The Start node is created automatically with three fields:- Chat Session ID — a UUID populated by the Chat component at runtime (referenced as
${sessionId}) - User Message — the user’s text message (referenced as
${userMessage}) - UI Flow Context — optional JSON object passed from the UI (referenced as
${context})
Add the Intent Classification Agent
From the node palette, drag an Intent Classification Agent node (under AI Agents) onto the canvas and connect it to the Start node. Configure the node: User Message:${userMessage}
Intents:
intentResult
The If No Intent Matches branch is a default output port that fires when the classifier can’t confidently match any intent. It’s always present on the node — you just need to connect it to the fallback handler in Step 2.


Connect handler nodes to each branch
Add the following nodes and connect each to its corresponding intent output:Add the End Flow node
Add an End Flow node from the palette (it is not auto-created for Chat Driven workflows) and connect every handler branch to it. The End Flow node has no body configuration — responses are already delivered by the Custom Agent nodes upstream.Step 2: Build the inline handlers
The Greetings and No Match branches are handled by Custom Agent nodes placed directly in themainChat workflow — no subworkflow needed.
mainChat uses the same two defaults:- Use only referenced values as input: ON — keeps each call scoped to the values referenced with
${...}in the Context field and reduces token usage. See Custom Agent node for details. - Include Task for Prompt Suggestions: OFF — turn ON only if you want AI-generated follow-up prompts shown in the Chat component (5.7.0+). See Custom Agent node.
answerSmalltalk (Custom Agent)
Add a Custom Agent node namedanswerSmalltalk to the Greetings branch.
Instructions:
${...} references inside it with “This field is static. Use Context for dynamic values.” Put dynamic values in the Context field, which accepts mixed text and ${...} keys. This split applies to every AI node in this tutorial.fallback (Custom Agent)
Add a Custom Agent node namedfallback on the No Match branch.
Instructions:
Step 3: Build the data input handler
The Intent 4 branch combines a Script node (for deterministic data extraction) followed by a Custom Agent node (to confirm what was captured and send the chat reply). Script nodes cannot send chat replies on their own — only Custom Agent nodes can.3a: handleDataInput Script
Add a Script node namedhandleDataInput on the Intent 4 branch. Since the Intent Classification Agent already routed the message here, the script can assume the user is providing personal data and uses simple string matching to extract values.
import statements and file or OS access are blocked. Note that Python business rules in BPMN processes are more restricted (on the default provider there, avoid enumerate() and .get() with a default value) — the script below sticks to basic loops and in checks so it runs unchanged in either context.
age = 30, while “25 years” sets loan_duration = 25.3b: Confirmation Custom Agent
Add a Custom Agent node afterhandleDataInput to deliver the confirmation as a chat reply.
Instructions:
Step 4: Build the knowledge base Q&A handler
The KB question branch is a single Custom Agent node placed inline in themainChat workflow (on the Intent 3 branch) with a Knowledge Base attached and Send as Chat Reply enabled.
Set up the Knowledge Base
Create a Knowledge Base data source
MortgageKnowledgeBase.Upload mortgage documents
- Mortgage product sheets (rates, terms, eligibility criteria)
- FAQ documents (common questions about mortgages, DTI, LTV)
- Regulatory guides (required documents, application process)
Test queries
Configure the Custom Agent node
Add a Custom Agent node namedknowledgeBaseQA on the Intent 3 branch. Enable the Knowledge Base setting and select your MortgageKnowledgeBase data source.
Retrieval parameters:
Step 5: Build the personalized offer handler
This is the most complex handler. It implements the Hybrid AI + business rules pattern — alternating between AI nodes and deterministic Script nodes. Because this branch benefits from structured intermediate data (calculation results, ranked products) that the other branches do not need, implement it as an Output Focused subworkflow called frommainChat, which returns a reportText string.
Create a workflow named answerPersonalisedOffer with Output Focused as the workflow type.

mainChat, connect a Subworkflow node on the Intent 2 branch that calls answerPersonalisedOffer, with Response Key offerOutput. Pass ${userMessage} as the userMessage input. Then add a Custom Agent after the Subworkflow node to deliver the chat reply — see Step 5e below.
Step 5a: AI understanding (extract and filter)
Add a Text Understanding node that extracts the client’s financial profile from their message and filters the product catalog. Instructions:filteredProducts
Step 5b: Business rules (financial calculations)
Add a Script node (JavaScript) for deterministic financial calculations. These must be auditable and reproducible.Step 5c: Business rules (scoring, ranking, and report)
Add a second Script node (JavaScript) that scores products, ranks them, and generates the recommendation report text. The script writes the report toreportText, which the terminal Custom Agent node reads.
Step 5d: End Flow (output the report)
Add an End Flow node after the scoring Script. Configure the End Flow body to exposereportText as a workflow output:
answerPersonalisedOffer.
Step 5e: Terminal Custom Agent in mainChat (Send as Chat Reply)
Switch back tomainChat. On the Offer branch, after the Subworkflow node, add a Custom Agent node. This is where the chat reply is delivered.
Instructions:
mainChat.
Step 6: Connect to the chat UI
You have two options for wiringmainChat to a UI. Pick one.
Option A: Chat-Driven UI Flow (recommended, 5.7.0+)

Create a Chat-Driven UI Flow
mainChat in the AI Conversational Workflow field.
Add a Chat component
mainChat by default — no per-component configuration needed.Test the chat
Option B: Chat component per UI Flow page
Create a UI Flow
chat) and add a Page.Add a Chat component
mainChat.Test the chat
Step 7 (optional): Share captured data across turns
By default, theanswerPersonalisedOffer subworkflow re-extracts all financial data from the current user message — it does not see conversation memory (memory is a Chat Driven feature, and the subworkflow is Output Focused). This means users must provide age, income, loan amount, and duration in a single Offer request.
If you want the subworkflow to reuse data the user shared in earlier turns (captured by handleDataInput), pass clientProfile from mainChat into the subworkflow.
Declare clientProfile as an input on the subworkflow
answerPersonalisedOffer, open the Data Model panel. Add clientProfile (OBJECT) if not already there, and toggle Input Parameter ON.Map clientProfile on the Subworkflow node in mainChat
mainChat, open the Subworkflow node on the Offer branch. Map the clientProfile input: clientProfile ← ${clientProfile}. The clientProfile key on the Chat Driven workflow is populated by handleDataInput on previous Data Input turns.Update the Text Understanding node to prefer existing data
Update Script 5b to merge sources
input.clientProfile when the AI extraction didn’t find a field. Example guard for income:loanAmount and loanDuration.Testing
Test the mainChat workflow directly
mainChat and click Run Workflow. In the test modal, provide:- Chat Session ID — any valid UUID (e.g.,
550e8400-e29b-41d4-a716-446655440000). Reuse the same UUID across test runs to verify multi-turn memory. - User Message — the message to test (e.g.,
What is a debt-to-income ratio?).
Test the full chat flow

Test edge cases
What you learned
In this tutorial, you built a full-featured Chat Driven app that demonstrates:- Chat Driven workflow basics — dedicated Start node fields,
${userMessage}interpolation, simplified End Flow (guide) - Built-in session memory — multi-turn context without manually persisting conversation history
- Intent classification and routing — using an Intent Classification Agent to classify messages and route to handler branches automatically (pattern)
- Send as Chat Reply — delivering responses to the Chat component directly from Custom Agent nodes
- Knowledge base RAG with re-ranking — grounding answers in uploaded documents using a Custom Agent with Knowledge Base, hybrid search, and re-rank (pattern)
- Hybrid AI + business rules — combining AI qualitative filtering with deterministic financial calculations for auditable recommendations (pattern)
Extending the chatbot
Once the base app works, these Chat Driven features can add polish and context-awareness:- AI Triggers (5.7.0+) — let different UI Flow pages launch
mainChatwith parameterized starting messages, e.g., “Help me refinance order $” from an account page - Navigate in UI Flow node — add an action branch that opens a mortgage application form with pre-filled data when the user accepts a recommendation
- Conversation Context (5.7.0+) — pass UI state (active customer ID, current page) to the workflow via the Start node’s UI Flow Context field
- Knowledge Base metadata filters — as the KB grows beyond a handful of documents, tag each store (e.g.,
topic: basics | application | faq) and pass metadata filters to the KB Q&A Custom Agent to scope retrieval to the right subset. The 5.7.0 query builder supports typed operators and AND/OR grouping.

