CM01

Welcome & Intent Capture

Journey: Customer Mobile
Duration: ~30 seconds
AI Agent: Intent Analyzer
User Type: External Customer
1

User Interface Layer

Mobile chat interface with conversational AI

📱 Chat Interface Component

  • Message Display Area: Scrollable conversation history with AI and user messages
  • Typing Indicator: Three animated dots showing AI is processing
  • Message Bubbles: Differentiated styling for user vs assistant messages
  • Timestamp Display: Shows time of each message interaction

✍️ Message Input Field

  • Text Input: Multi-line textarea for natural language entry
  • Character Counter: Optional limit display (e.g., 500 chars max)
  • Send Button: Primary action button with loading state
  • Input Validation: Prevents empty submissions

⚡ Quick Action Buttons

  • "Need £50,000 for equipment": Pre-filled example for quick start
  • "Expanding my café": Business growth scenario template
  • "Working capital loan": Common loan purpose example
  • Custom Entry: Option to type unique intent

✅ Intent Validation Card

  • Extracted Amount: Displays loan amount in £ format
  • Loan Purpose: Business context and use case
  • Confidence Score: AI certainty level (e.g., 95%)
  • Edit Button: Allows customer to refine details
  • Confirm Button: Proceeds to next screen (CM02)

🎨 UI Events Captured

  • onMessageSend() → Triggers API call to /api/v1/applications/intent
  • onQuickAction() → Auto-fills input field with pre-defined text
  • onEditIntent() → Opens modal for manual correction
  • onConfirmIntent() → Saves intent and navigates to CM02
2

API / Backend for Frontend (BFF)

RESTful endpoint for intent capture and processing

🔌 API Endpoint

  • Method: POST
  • URL: /api/v1/applications/intent
  • Authentication: Bearer token (JWT) in Authorization header
  • Content-Type: application/json
Request
POST /api/v1/applications/intent
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json

{
  "session_id": "sess_cm01_user123_20251222_143022",
  "user_id": "usr_olivia_thompson",
  "message": "I need £150,000 to expand my café to a second location in Manchester",
  "timestamp": "2025-12-22T14:30:22Z",
  "device_info": {
    "type": "mobile",
    "os": "iOS 17.2",
    "app_version": "2.4.1"
  }
}
Response (200 OK)
{
  "request_id": "req_cm01_20251222_143023",
  "status": "success",
  "intent": {
    "loan_amount": 150000,
    "loan_amount_formatted": "£150,000",
    "loan_purpose": "Business expansion - second location",
    "business_context": "Café/restaurant business expanding to Manchester",
    "location": "Manchester",
    "use_case_category": "expansion"
  },
  "confidence": 0.95,
  "confidence_breakdown": {
    "amount_extraction": 0.98,
    "purpose_detection": 0.96,
    "context_understanding": 0.92
  },
  "next_steps": {
    "action": "review_financial_data",
    "screen": "CM02"
  },
  "processing_time_ms": 847,
  "timestamp": "2025-12-22T14:30:23Z"
}

🔒 Security & Validation

  • JWT Validation: Verify token signature and expiry
  • Rate Limiting: Max 10 requests per minute per user
  • Input Sanitization: Strip HTML, SQL injection attempts
  • Message Length Check: 10-500 characters
  • Session Validation: Ensure session_id exists and is active
3

Business Logic & AI Orchestration

AI-powered intent analysis and natural language understanding

🤖 AI Agent: Intent Analyzer

  • Model Type: Fine-tuned GPT-4 for financial intent extraction
  • Training Data: 50,000+ business loan applications
  • Inference Time: ~800ms average
  • Accuracy: 94.7% on validation set
AI Agent Logic
// Intent Analyzer Processing Pipeline

1. Text Preprocessing
   - Convert to lowercase
   - Remove special characters
   - Tokenization

2. Named Entity Recognition (NER)
   - Extract monetary amounts (£, GBP, pounds)
   - Identify business types (café, restaurant, shop)
   - Detect locations (Manchester, London, etc.)
   - Find time indicators (expanding, need, require)

3. Intent Classification
   - Loan purpose: [expansion, working_capital, equipment, property, refinancing]
   - Urgency: [immediate, planned, exploring]
   - Business stage: [startup, growth, established]

4. Confidence Scoring
   - Amount extraction confidence
   - Purpose detection confidence
   - Context understanding confidence
   - Combined weighted score

5. Structured Output Generation
   - Format extracted data into JSON
   - Add metadata and timestamps
   - Return to API layer

📊 NLP Processing Steps

  • Amount Extraction: Regex + ML model to find £X, £X,XXX, £XkK formats
  • Purpose Detection: Keyword matching + semantic similarity
  • Business Context: Industry classification using BERT embeddings
  • Location Extraction: NER for UK cities and regions

🎯 Confidence Scoring Logic

  • High (≥90%): Clear amount, explicit purpose, business type identified → Auto-proceed
  • Medium (70-89%): Most elements clear, minor ambiguity → Show validation card
  • Low (<70%): Missing critical info → Request clarification
Confidence Calculation
// Weighted confidence score

confidence_score = (
  amount_confidence × 0.40 +  // Most critical
  purpose_confidence × 0.35 +  // Very important
  context_confidence × 0.25   // Supporting detail
)

// Example calculation:
amount: 0.98 × 0.40 = 0.392
purpose: 0.96 × 0.35 = 0.336
context: 0.92 × 0.25 = 0.230
TOTAL: 0.958 (95.8%)

✅ Intent Validation Rules

  • Amount Range: £5,000 - £5,000,000 (outside triggers warning)
  • Purpose Required: Must classify into one of 12 standard categories
  • Business Context: Should identify industry or business type
  • Completeness Check: All three elements must be present
4

Integration & Middleware Layer

API Gateway, session management, and request routing

🌐 API Gateway

  • Technology: AWS API Gateway / Kong
  • Routing: Routes /api/v1/applications/* to Application Service
  • Load Balancing: Distributes traffic across multiple service instances
  • SSL Termination: Handles HTTPS encryption

🔐 Session Management

  • Session Store: Redis (in-memory cache)
  • Session TTL: 30 minutes of inactivity
  • Session Data: user_id, device_info, conversation_history
  • Sticky Sessions: Ensures requests from same session go to same server
Session Structure (Redis)
KEY: session:sess_cm01_user123_20251222_143022
VALUE: {
  "user_id": "usr_olivia_thompson",
  "screen": "CM01",
  "started_at": "2025-12-22T14:30:00Z",
  "last_activity": "2025-12-22T14:30:23Z",
  "conversation_history": [
    {"role": "assistant", "message": "Hello! What brings you here?"},
    {"role": "user", "message": "I need £150k..."}
  ],
  "device": {"type": "mobile", "os": "iOS"}
}
TTL: 1800 seconds (30 min)

⚡ Rate Limiting

  • Per User: 10 requests/minute, 100 requests/hour
  • Per IP: 50 requests/minute (prevents DDoS)
  • Response: 429 Too Many Requests with Retry-After header
  • Implementation: Token bucket algorithm in Redis

📝 Request Logging

  • Every Request: Logged with timestamp, user_id, endpoint, status code
  • Storage: Elasticsearch for searchable logs
  • Retention: 90 days for compliance
  • Monitoring: Real-time alerts on error rate spikes
5

External Systems Integration

Third-party services and APIs

🔌 External Systems Used

  • None for CM01: This screen operates entirely with internal systems
  • Next Screen (CM02): Will integrate with TrueLayer, Xero, Companies House
  • Note: Intent capture is self-contained for fast response times

📊 Future Integration Points

  • Analytics: Google Analytics / Mixpanel for user behavior tracking
  • Monitoring: DataDog / New Relic for performance metrics
  • Error Tracking: Sentry for real-time error reporting
  • A/B Testing: Optimizely for UI/UX experiments
6

Data Persistence Layer

Database operations and storage

💾 Save Intent to Applications Table

  • Database: PostgreSQL (relational)
  • Table: applications
  • Operation: INSERT new application record
  • Status: "intent_captured" (first stage)
SQL Insert Statement
INSERT INTO applications (
  application_id,
  user_id,
  status,
  loan_amount,
  loan_purpose,
  business_context,
  confidence_score,
  session_id,
  created_at,
  updated_at
) VALUES (
  'app_20251222_143023_usr123',
  'usr_olivia_thompson',
  'intent_captured',
  150000,
  'Business expansion - second location',
  'Café/restaurant business expanding to Manchester',
  0.95,
  'sess_cm01_user123_20251222_143022',
  '2025-12-22 14:30:23',
  '2025-12-22 14:30:23'
);

📋 Log Interaction to Audit Trail

  • Database: Elasticsearch (time-series data)
  • Index: application-audit-logs
  • Purpose: Compliance, troubleshooting, analytics
  • Retention: 7 years (regulatory requirement)
Audit Log Entry (JSON)
{
  "log_id": "log_cm01_20251222_143023",
  "event_type": "intent_captured",
  "screen": "CM01",
  "user_id": "usr_olivia_thompson",
  "application_id": "app_20251222_143023_usr123",
  "timestamp": "2025-12-22T14:30:23Z",
  "details": {
    "raw_message": "I need £150,000 to expand my café...",
    "extracted_intent": {
      "amount": 150000,
      "purpose": "expansion"
    },
    "confidence": 0.95,
    "ai_agent": "Intent Analyzer v2.4",
    "processing_time_ms": 847
  },
  "ip_address": "203.0.113.42",
  "user_agent": "AINA-Mobile/2.4.1 (iOS 17.2)"
}

🗄️ Data Storage Summary

  • PostgreSQL: Structured application data (ACID compliant)
  • Redis: Session state, rate limiting counters (in-memory)
  • Elasticsearch: Audit logs, search indexes (time-series)
  • S3: Future document storage (not used in CM01)

🔄 Request-Response Sequence Flow

📱
Customer
1. Type message
🌐
Mobile App
🌐
Mobile App
2. POST /api/v1/applications/intent
⚙️
API Gateway
⚙️
API Gateway
3. Validate JWT & rate limit
🔐
Auth Service
⚙️
API Gateway
4. Route to Intent Service
🤖
Intent Analyzer
🤖
Intent Analyzer
5. NLP processing (~800ms)
🧠
AI Model
🤖
Intent Analyzer
6. Save to database
💾
PostgreSQL
🤖
Intent Analyzer
7. Log audit trail
📊
Elasticsearch
⚙️
API Gateway
8. Return JSON response
🌐
Mobile App
🌐
Mobile App
9. Display intent card
📱
Customer

Total Processing Time: ~1.2 seconds (800ms AI + 400ms database/network)

⚠️ Error Handling & Edge Cases

Low Confidence Score (<70%)

AI unable to extract clear intent from user message

Response: Request clarification with specific prompts
UI: "Could you tell me more about the loan amount you need?"

API Timeout (>5 seconds)

AI processing takes too long or service unavailable

Response: 504 Gateway Timeout
UI: "Taking longer than expected. Please try again."

Invalid Amount

Extracted amount outside acceptable range (£5K-£5M)

Response: 422 Unprocessable Entity
UI: "We offer loans between £5,000 and £5,000,000"

Rate Limit Exceeded

User sends too many requests in short time

Response: 429 Too Many Requests
UI: "Please wait a moment before sending another message"

Unauthorized Access

Invalid or expired JWT token

Response: 401 Unauthorized
UI: Redirect to login screen

Database Connection Failure

Unable to save application record

Response: 500 Internal Server Error
UI: "System error. We've been notified and will fix this soon"

Empty Message

User submits without typing anything

Response: Client-side validation prevents send
UI: Disabled send button until text entered

Message Too Long (>500 chars)

User types excessive text

Response: 400 Bad Request
UI: Character counter turns red, shows "Max 500 characters"

📋 Data Model: Applications Table

Field Name Data Type Description Example Value
application_id VARCHAR(50) Primary key, unique identifier app_20251222_143023_usr123
user_id VARCHAR(50) Foreign key to users table usr_olivia_thompson
status ENUM Application stage indicator intent_captured
loan_amount DECIMAL(12,2) Requested loan amount in GBP 150000.00
loan_purpose TEXT Extracted purpose description Business expansion - second location
business_context TEXT Additional business details Café/restaurant business expanding to Manchester
confidence_score DECIMAL(3,2) AI confidence (0.00-1.00) 0.95
session_id VARCHAR(100) User session identifier sess_cm01_user123_20251222_143022
created_at TIMESTAMP Record creation time (UTC) 2025-12-22 14:30:23
updated_at TIMESTAMP Last update time (UTC) 2025-12-22 14:30:23

📊 Status Enum Values

  • intent_captured: CM01 complete, initial intent recorded
  • data_review: CM02 in progress, reviewing financial data
  • consent_granted: CM03 complete, data connections authorized
  • identity_verified: CM04 complete, KYC passed
  • eligibility_confirmed: CM05 complete, credit check passed
  • offer_selected: CM07 complete, customer chose loan structure
  • documents_uploaded: CM08 complete, supporting docs received
  • signed: CM09 complete, e-signature captured
  • booked: CM10 complete, loan confirmed and scheduled
⬅️ Back to Customer Mobile Flow Next: CM02 Architecture (Financial Review) ➡️