Skip to main content

Chat System

Overview

The CROW dashboard features a comprehensive chat application powered by the ai-chat-service. Users can interact with their data through natural language queries, getting insights, generating reports, and exporting data in multiple formats.

ai-chat-service

The ai-chat-service provides conversational AI capabilities for the CROW dashboard.

Capabilities

  • Natural Language Queries: Ask questions in plain English
  • Context-Aware Responses: Understands organizational context
  • Multi-turn Conversations: Remembers conversation history
  • Export Generation: Create reports in various formats
  • Visualization Creation: Generate charts and diagrams

Architecture

Query Examples

Users can ask questions like:

Data Queries

  • "How many users viewed Product X last week?"
  • "What's the conversion rate for our landing page?"
  • "Show me the top 10 most viewed products"

Reports

  • "Generate a weekly summary of user engagement"
  • "Create a report on cart abandonment rates"
  • "Analyze user behavior patterns for Product Y"

Analytics

  • "Which products have the highest interaction rates?"
  • "What's the average time users spend on product pages?"
  • "Show me products with declining interest"

Patterns

  • "What paths do users take before purchasing?"
  • "Identify common drop-off points"
  • "Show me user segments based on behavior"

Processing Flow

Query Processing

  1. Query Received: User submits natural language query
  2. Intent Classification: Determine query type
  3. Context Retrieval: Fetch relevant context from Vectorize
  4. Data Fetching: Query D1 for specific data
  5. Response Generation: Generate response using LLM
  6. Formatting: Format response for display

The ai-chat-service uses Vectorize for semantic search:

Export Capabilities

The chat system supports multiple export formats:

Diagrams

  • Mermaid: Flowcharts, sequence diagrams
  • Charts: Bar, line, pie charts
  • Tables: Formatted data tables

Documents

  • PDF: Professional reports
  • LaTeX: Academic format
  • Markdown: Documentation

Data

  • CSV: Spreadsheet-compatible
  • JSON: Programmatic access
  • Excel: Rich formatting

Conversation Features

Multi-turn Context

The chat maintains conversation context:

User: "Show me sales for Product X"
Bot: [Shows sales data]

User: "How does that compare to last month?"
Bot: [Shows comparison, understanding context]

Query Refinement

Users can refine queries:

User: "Show me user interactions"
Bot: "I found 125,432 interactions. Filter by date, product, or source?"

User: "Filter by last month"
Bot: [Shows filtered results]

Integration

Vectorize Integration

  • Query embeddings for semantic search
  • Interaction context retrieval
  • Product similarity matching

D1 Integration

  • User and organization context
  • Product catalog queries
  • Interaction metadata

R2 Integration

  • Export file storage
  • Generated report access

Performance

Response Times

Query TypeTarget Time
Simple queries< 2 seconds
Complex analytics< 10 seconds
Report generation< 30 seconds

Optimizations

  • Query result caching
  • Pre-computed aggregations
  • Streaming responses for long queries