Skip to content
reaatechREAATECH

Files · Azure AI Multi-Agent Handoff for E-commerce Customer Support

37 (0 binary, 387.5 kB total)attempt 1

README.md·2750 B·markdown
markdown
# Azure AI Multi-Agent Handoff for E-commerce Customer Support
 
A TypeScript reference recipe demonstrating a multi-agent switching fabric for e-commerce customer support. Every customer message first hits an intent classifier, which assigns an agent and confidence score. If confidence is high, the message is handed off to a specialised Azure-hosted agent (returns, recommendations, order-tracking, or tech-support). When confidence drops, the system escalates to a human.
 
## Architecture
 
- **Express server** — single `/chat` webhook endpoint
- **Classifier**`@reaatech/agent-mesh-classifier` labels intents from customer messages
- **Confidence gate**`@reaatech/agent-mesh-confidence` determines route/clarify/fallback
- **Router**`@reaatech/agent-handoff-routing` capability-based router selects the best agent
- **Handoff orchestration**`@reaatech/agent-handoff-protocol` HandoffManager with lifecycle events
- **Transport**`@reaatech/agent-handoff-transport` A2A transport for agent-to-agent delivery
- **Azure OpenAI**`@azure/openai` + `openai/azure` for agent response generation
 
## Quick Start
 
```bash
pnpm install
cp .env.example .env
# Edit .env with your Azure OpenAI credentials
pnpm start
```
 
## Scripts
 
| Command | Description |
|---------|-------------|
| `pnpm typecheck` | TypeScript type checking |
| `pnpm lint` | ESLint with strict type-checked rules |
| `pnpm test` | Vitest with 90% coverage thresholds |
| `pnpm build` | Compile TypeScript to `dist/` |
| `pnpm start` | Run the compiled server |
 
## Environment Variables
 
See `.env.example` for all required variables:
 
| Variable | Description |
|----------|-------------|
| `AZURE_OPENAI_ENDPOINT` | Azure OpenAI endpoint URL |
| `AZURE_OPENAI_API_KEY` | Azure OpenAI API key |
| `AZURE_OPENAI_DEPLOYMENT_NAME` | Azure OpenAI deployment name |
| `AZURE_OPENAI_API_VERSION` | API version (default: 2024-12-01-preview) |
| `PORT` | Server port (default: 3000) |
| `HUMAN_ESCALATION_ENDPOINT` | Optional human support webhook |
| `NODE_ENV` | Environment (development/production/test) |
 
## API
 
### POST /chat
 
```json
// Request
{ "message": "I want to return my order", "sessionId": "s1" }
 
// Route response
{ "action": "route", "reply": "Handoff completed", "agent_id": "returns", "confidence": 0.92 }
 
// Clarify response
{ "action": "clarify", "clarification_question": "...", "suggested_agent": "returns", "confidence": 0.55 }
 
// Escalate response
{ "action": "escalate", "reason": "...", "escalation_endpoint": null }
```
 
## Development
 
```bash
# Quick test
curl -X POST http://localhost:3000/chat \
  -H "Content-Type: application/json" \
  -d '{"message":"I want to return my order","sessionId":"s1"}'
```
 
## License
 
MIT