Skip to content

Data Flow Architecture

This document provides a detailed explanation of the data flows in our architecture. We'll break down each major flow and explain how data moves through our system.

Overview

Our system has two main types of users:

  1. Clients - Organizations that use our admin dashboard to set up and manage their AI bot
  2. Website Visitors - End users who interact with the AI bot on the client's website

The architecture is designed to handle several key flows:

  • Client Onboarding Flow
  • Client Management Flow
  • Visitor Conversation Flow
  • Analytics Processing Flow
graph TD A[Client] -->|Visits| B[Admin Dashboard] B -->|Selects Plan| C[Stripe Payment] C -->|Webhook| D[Admin API] D -->|Create User| E[Cognito] D -->|Store Data| F[(RDS)] E -->|Send Credentials| G[Email to Client] G -->|Login| H[Dashboard Access] H -->|Customize| I[Bot Settings] I -->|Save| F H -->|Get| J[Integration Script] J -->|Deploy| K[Client Website]

Client Onboarding Flow

1. Signup and Payment Process

When a new client signs up, here's what happens:

  1. Client visits the Admin Dashboard and selects a plan. Available plans:

    • Free Trial
    • Plan 1
    • Plan 2
    • Plan 3
  2. Client is redirected to Stripe for payment processing

  3. Upon successful payment, Stripe sends a webhook to our Admin API

  4. Admin API creates a new Cognito user account

  5. Admin API stores customer data in RDS. Data stored:

    • Customer name
    • Cognito ID
    • Phone number
    • Email address
  6. Client is redirected back to the Admin Dashboard

2. Bot Customization

The bot customization process:

  1. Client logs into Admin Dashboard using Cognito credentials

  2. Client customizes the bot. Available options:

    • Bot appearance
    • Knowledge information (RAG - Retrieval Augmented Generation)
  3. Changes are saved through Admin API to RDS

Note: Changes are applied directly to the production bot without a preview feature (live client side preview is implemented on UI)

Website Integration

To integrate the bot on their website, clients need to add a simple script tag.

This script.js is hosted on S3.

This script automatically:

  1. Creates an iframe on the client's website
  2. Handles all communication with our backend services
  3. Manages the bot UI and interactions

Visitor Conversation Flow

1. Text Chat Flow

When a visitor starts a text chat:

  1. Visitor sends a message through Bot UI
  2. Message is forwarded to AI Engine API
  3. AI Engine requests LLM response from Bedrock
  4. Response is returned through the chain
  5. Conversation is stored in RDS
  6. Response is displayed to visitor

2. Voice Call Flow

When a visitor initiates a voice call:

  1. Visitor clicks voice call button in Bot UI
  2. AI Engine API creates a new call session
  3. Call ID is returned to Bot UI
  4. Bot UI connects to call using Ultravox SDK
  5. Audio is streamed between visitor and Ultravox directly

Post-Conversation Analytics

After each conversation ends:

  1. AI Engine triggers the Post Session API
  2. Post Session API generates analytics, sends emails to visitor etc. and stores in RDS
  3. Client can view analytics in Admin Dashboard

Analytics Generated

  • Intent analysis
  • Sentiment analysis
  • Call summary
  • Other conversation metrics
sequenceDiagram participant V as Visitor participant B as Bot UI participant A as AI Engine API participant L as Bedrock/Ultravox participant R as RDS participant D as Dashboard V->>B: Visit Website B->>B: Load iframe V->>B: Start Chat/Call B->>A: Request A->>L: Process Input L->>A: Generate Response B->>L: Connect Call A->>R: Store Conversation A->>B: Return Response B->>V: Display Response A->>L: Generate Analytics A->>R: Store Analytics R->>D: Update Dashboard

Security Architecture

Admin APIs

  • Protected behind AWS WAF
  • Require Cognito JWT authentication
  • Used for all dashboard operations

Public APIs

  • Also protected by WAF
  • No authentication required
  • Used by bot UI for visitor interactions
  • Planned to be rate limited and monitored

Environment Configuration

Development (Dev)

  • Used for testing new features
  • Isolated from production data

Production (Prod)

  • Live environment
  • Handles real client and visitor traffic

Example Flows

Example 1: Complete Client Onboarding

  1. Client visits dashboard and selects Plan 2
  2. Completes payment through Stripe ($199/month)
  3. System performs automatic setup:

    • Creates Cognito account
    • Stores customer data in RDS
    • Cognito automatically sends an email to Client with temp credentials
    • Client uses these to access dashboard
  4. Client customizes bot appearance

  5. Client adds embedding script to their website

Example 2: Visitor Interaction

  1. Visitor lands on client's website
  2. Bot iframe loads automatically
  3. Visitor starts chat or voice call
  4. AI Engine processes interaction using Bedrock / Ultravox
  5. Post-session analytics generated automatically
  6. Client views analytics in dashboard