BACK TO HOME
Relay Logo
RELAY DOCS
Documentation v1.0

RELAY DOCUMENTATION

Complete guide to building and deploying multi-agent AI customer support systems with Relay.

Getting Started

Prerequisites

  • Node.js 18+ and npm/pnpm installed
  • Supabase account with PostgreSQL database
  • Google AI API key (Gemini)

Installation

Terminal
# Clone the repository
git clone https://github.com/NirmanPatel036/relay.git
cd relay

# Install frontend dependencies
cd relay
npm install

# Install backend dependencies
cd ../backend
npm install

# Setup environment variables
cp .env.example .env

Environment Configuration

Create a .env file in the backend directory:

DATABASE_URL="postgresql://..."
GOOGLE_API_KEY="your-gemini-api-key"
PORT=8000

Running the Application

# Terminal 1 - Backend
cd backend
npm run dev

# Terminal 2 - Frontend
cd relay
npm run dev

# Terminal 3 - Database seeding (optional)
cd backend
npm run db:seed

Architecture Overview

Relay uses a Router-Agent pattern where a central Router Agent analyzes incoming queries and intelligently routes them to specialized sub-agents.

System Flow

1

User Query

Customer submits a query through the chat interface

2

Router Analysis

Router Agent analyzes intent and calculates confidence scores

3

Agent Delegation

Query routed to specialized agent (Order, Billing, or Support)

4

Tool Execution

Agent executes relevant tools (database queries, API calls)

5

Response Generation

AI generates natural language response with retrieved data

Agent Types

Router Agent

Central Orchestrator

Analyzes incoming queries using semantic understanding to determine user intent and route to the appropriate specialist agent.

Example routing logic:

"Where is my order #ORD-2026-1001?"
→ Intent: ORDER_TRACKING
→ Confidence: 0.95
→ Route to: OrderAgent

Order Agent

Order & Logistics

Handles order tracking, delivery status, modifications, and shipping updates with direct database access.

Available Tools:

  • fetch_order_details(orderNumber)
  • check_delivery_status(orderNumber)
  • get_user_orders(userId, limit)

Billing Agent

Payments & Invoices

Manages invoices, refund requests, payment history, and financial inquiries with precision and empathy.

Available Tools:

  • get_invoice_details(invoiceNumber)
  • check_refund_status(invoiceNumber)
  • get_payment_history(userId, limit)

Support Agent

General Assistance

Handles general inquiries, account management, troubleshooting, and provides conversational support.

Available Tools:

  • query_conversation_history(userId)

API Reference

The backend exposes RESTful endpoints for interacting with the multi-agent system.

POST/api/chat

Description

Send a chat message and receive AI-generated response from appropriate agent.

Request Body

{
  "message": "Where is my order #ORD-2026-1001?",
  "userId": "user_123",
  "conversationId": "conv_456"
}

Response

{
  "response": "Your order #ORD-2026-1001 is currently...",
  "agent": "order",
  "confidence": 0.95,
  "conversationId": "conv_456"
}
GET/api/orders/:orderNumber

Description

Retrieve detailed information about a specific order.

Response

{
  "order_number": "ORD-2026-1001",
  "status": "shipped",
  "items": [...],
  "tracking_number": "TRK123456",
  "estimated_delivery": "2026-02-16"
}

Usage Examples

Order Tracking Query

User Input

"Where is my order #ORD-2026-1004?"

Agent Response

Your order #ORD-2026-1004 (Dell XPS 15 laptop) is currently being shipped and is expected to arrive in Mumbai on February 16, 2026. You can track it using tracking number TRK789012.

System Flow

1. Router Agent → Intent: ORDER_TRACKING (0.96 confidence)

2. Delegated to Order Agent

3. Tool: fetch_order_details("ORD-2026-1004")

4. Tool: check_delivery_status("ORD-2026-1004")

5. Response generated with retrieved data

Refund Status Query

User Input

"What's the status of my refund for invoice INV-2026-1006?"

Agent Response

Your refund of ₹134,900 for invoice INV-2026-1006 has been successfully processed and credited back to your original payment method on February 12, 2026.

System Flow

1. Router Agent → Intent: REFUND_INQUIRY (0.93 confidence)

2. Delegated to Billing Agent

3. Tool: get_invoice_details("INV-2026-1006")

4. Tool: check_refund_status("INV-2026-1006")

5. Response generated with empathy and precision

Ready to Build?

Start implementing your own multi-agent AI system with Relay.