AI Architecture · Software Development · Voice AI · Business Automation

Customer Service AI Platform

AI that answers customer questions through chat, email, and phone. It retrieves information from company documents, looks up relevant account information using tools, and hands off to a person when it cannot answer reliably.

Status
In production: chat and email
Technology
  • Django
  • PostgreSQL
  • pgvector
  • LLM APIs
  • Python
Chat Email Voice status to confirm Conversation service multi-tenant Django Retrieval context assembly Language model Business tools rules in code Documents S3 · Drive · SharePoint Human agent Business systems

Select a component to see what it does, its inputs and outputs, and why it's there.

Chat

What it does
Website chat widget for customer conversations.
Inputs
Customer messages
Outputs
Messages to the conversation service; streamed replies
Technology
Django, real-time messaging

Email

What it does
Answers inbound support email in the same conversation model as chat.
Inputs
Inbound email
Outputs
Drafted or sent replies; escalations
Technology
Django, background workers

Voice

What it does
Real-time phone conversations on the same platform.
Inputs
Telephony audio stream
Outputs
Spoken replies, callbacks, transfers
Technology
SIP / telephony integration, streaming audio
Design notes
Latency and caller identification are the hard parts.

Conversation service

What it does
Owns each conversation: tenant configuration, history, state, and the response loop.
Inputs
Messages from any channel
Outputs
Grounded replies, tool requests, escalations
Technology
Django, PostgreSQL
Design notes
Shared by every channel and brand; channels stay thin.

Retrieval

What it does
Finds and assembles relevant document context up to a token budget.
Inputs
Conversation so far
Outputs
Ranked, assembled context
Technology
pgvector similarity, neighbor chunks, metadata search
Design notes
Weights and budget configurable per tenant.

Language model

What it does
Writes responses from the supplied context and proposes tool calls.
Inputs
Instructions, context, conversation
Outputs
Draft reply or structured tool request
Technology
LLM APIs
Design notes
Never the final authority on business rules.

Business tools

What it does
Executes order, shipment and appointment lookups and permitted actions.
Inputs
Structured tool requests
Outputs
Constrained results or refusals
Technology
Python, internal APIs
Design notes
Identity, permissions and policy enforced by application code.

Documents

What it does
Source of truth for answers, synchronized on a schedule.
Inputs
Business-managed documents
Outputs
Chunks, embeddings, metadata
Technology
Scheduled sync, AI-assisted metadata extraction

Human agent

What it does
Takes over when automation shouldn't answer.
Inputs
Escalated conversation with context
Outputs
Resolution
Technology
Support tooling
Design notes
Triggered by deterministic rules plus classification.

Business systems

What it does
Orders, shipping and scheduling systems.
Inputs
Authorized tool calls
Outputs
Account data
Technology
Internal APIs

Summary

A multi-tenant Django platform that answers customer questions through chat and email, with voice on the same foundation. It retrieves answers from company documents, looks up account information through controlled tool calls, and hands the conversation to a person when it can't answer reliably.

It's in production for chat and email. Employer source code and data aren't public, so this write-up describes the architecture in general terms. A fully working version with a fictional business, synthetic customers, and mock tools will be available in the Lab.

The problem

Customer support is a major operational cost, and much of the volume was repetitive: order status, shipping, appointments. Customers called or opened tickets for questions that had documented answers.

The goal was never "add a chatbot." It was to find which interactions software could handle reliably, take that load off agents, and keep a person one step away for everything else.

Requirements and constraints

  • Answers must be grounded. Responses come from company documents and account data, not the model's general knowledge.
  • Business rules can't depend on the model. Who can see an order, and which appointment changes are allowed, are enforced in application code.
  • Escalation is a feature, not a failure. The system must recognize when it shouldn't answer and route to a person cleanly.
  • Business teams own the content. Support leaders manage documents and bot instructions without engineering tickets.
  • One platform, multiple brands. Each business has its own documents, tools, instructions, and channels.

Architecture

The platform separates shared infrastructure from channel-specific pieces:

  • Shared: tenant configuration, document ingestion and synchronization, embeddings in PostgreSQL with pgvector, retrieval orchestration, language-model integration, tool execution, conversation management, evaluation, and escalation.
  • Channel-specific: the chat widget, email handling, and real-time telephony for voice.

Select a component in the diagram above to see its responsibility, inputs, and outputs.

Design decisions

Retrieval assembles context, not a single "best" chunk

Requirement: answers often depend on information spread across a section of a document, like a policy plus its exceptions.

Approach: retrieval combines several signals:

  1. Semantic similarity against the conversation so far, not just the latest message.
  2. Neighboring chunks around strong matches, to restore surrounding context.
  3. Metadata and title search, for documents a customer names directly.
  4. Weighted selection and assembly up to a configurable token budget.

Why: retrieving one apparently perfect chunk often loses the sentence before or after it that changes the answer. Including relevant surrounding text can improve answer quality and reduce missing context.

Trade-off: larger context costs more per conversation and can dilute relevance, which is why the budget and weights are configurable per tenant.

Tools enforce the rules; the model only asks

Requirement: the assistant needs live account data, such as orders, shipments, and appointments, without becoming a way around authorization.

Approach: the model can only request a structured tool call. Application code verifies the customer's identity, checks permissions and business rules, executes the action, and returns a constrained result. Actions outside policy are refused in code, regardless of how the request is phrased.

Trade-off: each new capability needs a deliberately built tool instead of a prompt change. That's slower to extend, and intentionally so.

Escalation combines classification with deterministic rules

The assistant hands off when supporting information isn't found, the account can't be identified, the request is outside permitted actions, the customer asks for a person, or the conversation fails defined checks. Model classification is one input, but deterministic rules and response validation make the final call. A model's confidence score alone doesn't guarantee a correct answer, so it isn't treated as one.

Layered, versioned instructions

System-level instructions that protect safety and behavior are restricted to the application team. Business teams edit their own bot's instructions within those bounds. Every change is versioned with history and rollback, and changes are followed by evaluation. Keeping business-editable behavior separate from protected logic lets support leaders iterate without risking the guardrails.

Knowledge management

Business users manage the documents behind each bot. Sources such as S3, Google Drive, and SharePoint synchronize on a schedule, so the AI's knowledge doesn't drift into a separate, outdated copy of company information. An AI-assisted step extracts metadata and categorizes documents against configurable business requirements, which feeds metadata search.

Voice

Voice extends the same platform to the phone: telephony integration, streaming audio, conversation state, tool calls during a live call, callbacks, and escalation to an agent. The hard parts are latency, audio quality, and identifying the caller's account reliably.

Evaluation and reliability

Useful measures include escalation rate, automated resolution rate, answer correctness, tool-call success, unsupported-answer frequency, and newly surfaced customer questions.

Next step

Want to talk through something like this?

I'm happy to go deeper on the architecture, the trade-offs, or how it would apply to your situation.