๐ผ For Business Leaders: What Does the System Do?
Traditional "chatbots" answer questions with generic text and link drops. A DavinLabs AI Employee performs the actual work. It acts as an always-on, senior front-desk and support specialist that directly interacts with your live database, validates availability, and takes real business actions.
๐ System Comparison: Old Way vs. Basic Chatbots vs. DavinLabs AI
Compare how your operations run today versus common automated solutions and the DavinLabs AI Employee Platform:
| Operational Metric | Traditional Human Staff | Basic Chatbots (GPT Wrappers) | โก DavinLabs AI Employee |
|---|---|---|---|
| Availability & Coverage | 8 hours/day, 5 days/week. Misses 60% of after-hours leads |
24/7 online. Canned replies, cannot resolve |
24/7/365 Omnichannel Instant resolution across all channels |
| Response Latency | 15 โ 45 minutes on email/tickets. Slow conversion |
3 โ 8 seconds. Generic delay |
< 1.5 seconds Streaming real-time execution |
| Action Capability | Manual execution in CRM/calendar. Human error prone |
None. Sends "visit link" or "call us" |
Full Business Execution Books, reschedules, syncs CRM, bills |
| Cost per Resolution | $4.50 โ $8.00 per inquiry. High overhead ($45k+/yr per agent) |
$0.25 โ $0.80 per conversation. Unoptimized high token bills |
$0.02 โ $0.04 per conversation 78% to 85% cost savings |
| Accuracy & Hallucination | Subject to fatigue, staff turnover. Variable answer quality |
High risk of hallucination. Makes up prices & availability |
99.4% Deterministic Safety Strict RAG & validated tool schema |
| Integration Architecture | Requires training and manual screens. High onboarding time |
Proprietary closed database sync. Fragile vendor lock-in |
Universal Integration SDK Plugs into any API in < 20 lines of code |
| System Reliability | Staff illness, holidays, turnover. Unpredictable availability |
API rate limits, server hangs. No idempotency protection |
Fault-Isolated Architecture Core system works even if AI is offline |
๐งฎ Interactive ROI & Cost Savings Calculator
Adjust the sliders below to see your business's estimated annual dollar savings, return on investment (ROI), and staff hours saved:
๐ข Industry Blueprints & Real-World Impact
DavinLabs AI Employee comes with 16 pre-configured blueprints across high-volume commercial industries:
- Automated patient appointment scheduling & doctor availability check
- Pre-visit preparation instructions & FAQ triage
- Automated WhatsApp reminder and reschedule flow
- 24/7 instant WhatsApp bookings matching stylist specialities
- Service upselling (e.g. hair treatment with color service)
- Live calendar sync with Google Calendar, Timely, Fresha
- Multi-lingual guest concierge (Wi-Fi, parking, amenities)
- Room service, dining reservations, and late checkout requests
- Automated local attraction & transfer recommendations
- Instant order status, tracking links & shipment queries
- Automated return & exchange label creation
- Personalized product recommendations based on inquiry
- Inbound lead qualification in under 45 seconds
- Instant CRM contact creation & enrichment (HubSpot, Salesforce)
- Direct calendar meeting booking with qualified specialists
๐ Platform Overview & Engineering Vision
A reusable, multi-tenant AI Employee platform designed to be built once and connected to any external business system (salons, clinics, hotels, e-commerce, CRM, ERP, vehicle service, or custom backends) through a standardized Integration Layer.
ai-employee-integration-sdk for Express, NestJS, Next.js, and Fastify with schema validation and idempotency.๐๏ธ Core Architecture & Request Flow
Customer inquiries arrive across omni-channel adapters (WhatsApp, Website Chat widget, Email, SMS). Inbound messages are normalized, routed through tenant context security, and processed by the specialized AI Agent pipeline before executing external actions.
graph TD
Customer([๐ค Customer]) -->|WhatsApp / Web Chat / Email| ChannelAdapter[๐ก Channel Adapter - WAHA / Web / Resend]
ChannelAdapter --> ConvService[๐ฌ Conversation Service]
ConvService --> TenantCtx[๐ก๏ธ Tenant & Branch Security Context]
TenantCtx --> RouterAgent[๐ Router Agent]
RouterAgent -->|FAQ / Policies| KnowledgeAgent[๐ Knowledge Agent]
RouterAgent -->|General Chit-Chat / Tone| SupportAgent[๐ค Support Agent]
RouterAgent -->|Bookings / Orders / API| ActionAgent[โ๏ธ Action Agent]
KnowledgeAgent --> RAG[(๐ Synced RAG Vector DB)]
ActionAgent --> Idempotency[๐ Idempotency Guard]
Idempotency --> IntegrationSDK[๐ฆ Integration Layer / SDK]
IntegrationSDK --> ExternalSystem[๐ข External Business System - CRM/ERP/Salon]
SupportAgent --> ResponseService[๐ค Response Service]
KnowledgeAgent --> ResponseService
ActionAgent --> ResponseService
ResponseService --> Customer
๐ง Multi-Agent Pipeline
The AI Employee pipeline decomposes customer interactions into specialized agents, keeping prompt context focused and drastically reducing token costs:
| Agent | Role & Responsibility | Underlying Model & Tools |
|---|---|---|
| Router Agent | Classifies intent, extracts parameters, and selects which specialist agent should handle the turn. | Fast model (Gemini 2.0 Flash / GPT-4o-mini) + JSON Schema structured outputs. |
| Support Agent | Handles greeting, tone calibration, business hours validation, and customer relationship chit-chat. | Standard context window + tenant persona instructions. |
| Knowledge Agent | Retrieves relevant chunk embeddings from the tenant's synced knowledge documents via RAG. | Vector similarity search + hybrid keyword matching. |
| Action Agent | Validates arguments, executes registered external actions over HTTP, and formats human confirmation. | Tool Calling / Function Calling engine + Idempotency tracking. |
โก Token & Cost Reduction Architecture
High LLM inference bills kill SaaS margins. DavinLabs implements a multi-tier token optimization strategy that reduces per-conversation token spend by up to 81%:
| Component | Standard Agent Implementation | DavinLabs Optimized Engine | Net Savings |
|---|---|---|---|
| System Prompt & Schemas | Full 30-action JSON schema loaded every turn (~3,200 tokens) | Filtered top-3 relevant action schemas loaded on-demand (~450 tokens) | -85% tokens |
| Conversation Memory | Full raw message history transmitted (~2,500 tokens) | Sliding window + semantic state summary (~400 tokens) | -84% tokens |
| Inference Cost per 10k Turns | $45.00 โ $75.00 | $6.80 โ $11.50 | ~80% cost reduction |
๐ฑ Omnichannel Engine: WhatsApp WAHA & Email
AI Employee connects seamlessly with customers on their preferred communication channels without requiring third-party messaging markups:
sequenceDiagram
autonumber
actor User as ๐ค Customer (WhatsApp)
participant WAHA as ๐ฑ WAHA Adapter
participant Core as โ๏ธ AI Employee Core
participant SDK as ๐ Integration SDK (Business System)
participant Resend as โ๏ธ Resend Email Service
User->>WAHA: "I want to book a massage for tomorrow at 3pm"
WAHA->>Core: Inbound Webhook POST /webhooks/whatsapp/waha
Core->>Core: Router Agent -> Action Agent (validate slot)
Core->>SDK: POST /ai/execute { action: "create_booking", ... }
SDK-->>Core: { success: true, bookingId: "BK-491", time: "3:00 PM" }
par Send WhatsApp Confirmation
Core->>WAHA: POST /api/sendText "Confirmed for tomorrow at 3 PM!"
WAHA->>User: WhatsApp Message Delivered
and Send Email Receipt
Core->>Resend: POST /emails { to: customerEmail, subject: "Booking Confirmed" }
end
๐ก๏ธ Multi-Tenancy & Access Control (RBAC)
AI Employee runs as a multi-tenant SaaS product with strict separation between platform administration and customer tenant boundaries:
| Role Type | Hierarchy / Values | Guard & Scope | Permissions |
|---|---|---|---|
| Platform Role | NONE | SUPER_ADMIN |
PlatformAdminGuard(Endpoints under /admin/*) |
Manage tenants, inspect usage analytics, manage platform users, configure global AI models. |
| Tenant Role | OWNER > ADMIN > MANAGER > EMPLOYEE |
RolesGuard(Scoped to tenantId) |
OWNER: Full tenant control. ADMIN: Integrations, Channels, Team. MANAGER: Workflows, Knowledge. EMPLOYEE: Live chat inbox. |
๐๏ธ Platform Admin Console & Management
The dedicated platform administration suite (/admin/*) gives DavinLabs super-administrators real-time oversight over all business tenants:
๐ The Integration API Contract
External business systems expose 3 standard endpoints to become compatible with AI Employee without requiring proprietary lock-in:
| Method | Endpoint | Payload / Query | Expected Response |
|---|---|---|---|
GET |
{baseUrl}/ai/actions |
None | { "actions": [{ "name", "description", "parameters": { ... } }] } |
POST |
{baseUrl}/ai/execute |
{ "action": "name", "data": { ... } } |
{ "success": true, "message": "...", "data": { ... } } |
GET |
{baseUrl}/ai/knowledge |
None | { "documents": [...], "locations": [...] } |
POST /ai/execute request from the AI Employee platform includes an Idempotency-Key header. The target system must deduplicate repeated requests to prevent double-booking or duplicate payments.
๐ฆ NPM Integration SDK: ai-employee-integration-sdk
The official TypeScript/Node.js package eliminates manual HTTP routing, validation boilerplate, idempotency caching, and authentication checks.
npm install ai-employee-integration-sdk express
# or with pnpm:
pnpm add ai-employee-integration-sdk express
๐ป Framework Quickstart Examples
import express from 'express';
import {
registerAction,
registerKnowledge,
createExpressRouter,
} from 'ai-employee-integration-sdk/express-adapter';
// 1. Register an action the AI Employee can call
registerAction({
name: 'create_booking',
description: 'Book an appointment for a customer',
parameters: {
customerName: { type: 'string', required: true, description: 'Customer full name' },
serviceId: { type: 'string', required: true, description: 'ID of the service to book' },
date: { type: 'string', required: true, description: 'ISO date (YYYY-MM-DD)' },
},
handler: async (data, ctx) => {
// Business logic (DB write, appointment booking, etc.)
return { bookingId: 'BK_9981', status: 'CONFIRMED' };
},
});
// 2. Provide business knowledge & locations for AI answers
registerKnowledge(async () => ({
documents: [
{
externalId: 'pricing-policy',
title: 'Services & Pricing',
content: 'Haircut: $40. Hair coloring: $90. Cancellation: 24h notice.',
},
],
locations: [
{
externalId: 'loc_downtown',
name: 'Downtown Salon',
address: '100 Main Street, Suite 4',
timezone: 'America/New_York',
phone: '+1-555-0199',
},
],
}));
const app = express();
app.use(express.json());
// Exposes GET /ai/actions, POST /ai/execute, GET /ai/knowledge
app.use('/ai', createExpressRouter({
apiKey: process.env.AI_EMPLOYEE_API_KEY,
}));
app.listen(4000, () => console.log('SDK listening on port 4000'));
import { Module } from '@nestjs/common';
import { AiActionsModule, registerAction } from 'ai-employee-integration-sdk/nestjs-adapter';
registerAction({
name: 'check_inventory',
description: 'Check stock availability for a given product SKU',
parameters: {
sku: { type: 'string', required: true, description: 'Product SKU' },
},
handler: async (data) => {
return { sku: data.sku, inStock: true, quantity: 24 };
},
});
@Module({
imports: [
AiActionsModule.forRoot({
apiKey: process.env.AI_EMPLOYEE_API_KEY,
}),
],
})
export class AppModule {}
import { handleIntegrationRequest, registerAction } from 'ai-employee-integration-sdk';
import { NextRequest, NextResponse } from 'next/server';
registerAction({
name: 'get_order_status',
description: 'Check customer order delivery status',
parameters: { orderId: { type: 'string', required: true } },
handler: async (data) => ({ orderId: data.orderId, status: 'DELIVERED' }),
});
async function handler(req: NextRequest) {
const url = new URL(req.url);
const path = url.pathname.replace(/^\/api/, '');
const body = req.method === 'POST' ? await req.json().catch(() => ({})) : undefined;
const response = await handleIntegrationRequest(
{
method: req.method,
path,
headers: Object.fromEntries(req.headers.entries()),
body,
},
{ apiKey: process.env.AI_EMPLOYEE_API_KEY },
);
return NextResponse.json(response.body, { status: response.status });
}
export { handler as GET, handler as POST };
๐ Security, Auth & Idempotency
The SDK includes automatic parameter validation, API key / Bearer authentication, and an Idempotency Cache to ensure safe retries.
verifyAuth: (req) => boolean.Idempotency-Key for 24h. Supports distributed Redis stores across clusters.โก n8n Automation Engine
For long-running background tasks, AI Employee dispatches events to an embedded n8n orchestration instance:
action.executed, booking.created, lead.qualified) for asynchronous sync.๐๏ธ Database Schema & Data Models
AI Employee uses PostgreSQL managed through Prisma with strict relational multi-tenancy. Every tenant-scoped entity carries a foreign key to Tenant:
erDiagram
TENANT ||--o{ USER_MEMBERSHIP : has
USER ||--o{ USER_MEMBERSHIP : belongs_to
TENANT ||--o{ BRANCH : contains
TENANT ||--o{ AI_EMPLOYEE : deploys
TENANT ||--o{ KNOWLEDGE_DOC : owns
TENANT ||--o{ CHANNEL_CONFIG : connects
AI_EMPLOYEE ||--o{ ACTION_LOG : executes
TENANT ||--o{ AUDIT_LOG : tracks
TENANT {
string id PK
string name
string slug
string plan
string status
}
USER {
string id PK
string email
string platformRole
}
AI_EMPLOYEE {
string id PK
string name
string role
string model
string prompt
string tenantId FK
}
ACTION_LOG {
string id PK
string actionName
string status
int executionTimeMs
string idempotencyKey
}
๐ Production Deployment & Resilience
DavinLabs AI Employee is engineered for high availability with an enterprise fault-isolation guarantee:
# 1. Clone & Configure
git clone https://github.com/davinlabs/ai-employee.git
cd ai-employee
cp .env.example .env
# 2. Start PostgreSQL, Redis, n8n, WAHA containers
docker compose up -d postgres redis n8n waha
# 3. Migrate database & seed admin
pnpm install
pnpm prisma:generate
pnpm prisma:migrate
pnpm prisma:seed
# 4. Build and run production apps
pnpm build
pnpm start
curl http://localhost:3001/health. Returns database query latency, Redis cache availability, WAHA session status, and uptime metrics.
๐ NPM Release & Publishing
To release new versions of ai-employee-integration-sdk to the npm registry:
cd "packages/integration-sdk"
pnpm build
pnpm test
npm publish --access public