A sophisticated Node.js application that implements an AI-powered sales agent using Together AI's LLM capabilities. The platform handles product inquiries, demo scheduling, and customer interactions with a focus on AWS product information.
- 🤖 AI-powered conversational agent using Together AI's LLM (Meta-Llama-3.1-70B-Instruct-Turbo)
- 📝 RAG (Retrieval Augmented Generation) for accurate product information retrieval
- 📅 Automated demo scheduling with email confirmation
- 💾 MongoDB integration for persistent data storage
- 🔄 Real-time communication via WebSocket
- 📊 Sophisticated conversation state management
- 🔍 Vector search using Pinecone for semantic similarity
- 📝 Comprehensive logging system
- TypeScript-based architecture
- Express.js server with WebSocket support
- Modular service architecture
- Comprehensive error handling
- Structured logging with Winston
- Zod schema validation
- Environment-based configuration
- WebSocket Manager: Handles real-time communication
- Conversation Manager: Manages conversation flow and state
- Node Service: Implements conversation flow logic
- AI Service: Integrates with Together AI
- Embedding Service: Manages vector embeddings with Pinecone
- Product Service: Handles product-related queries
- Customer
- Message
- Event
- Session
- Node.js (v14 or higher)
- MongoDB (v4.4 or higher)
- npm or yarn package manager
- Pinecone account
- Together AI API key
Create a .env
file with:
TOGETHER_API_KEY=your_together_ai_key PINECONE_API_KEY=your_pinecone_key PINECONE_ENVIRONMENT=your_pinecone_environment
MONGODB_URI=your_mongodb_connection_string
PORT=3000 LOG_LEVEL=debug
- Clone the repository:
git clone https://github.com/gooduru-vineeth/sales-agent-backend.git
cd sales-agent-backend
- Install dependencies:
npm install
- Build the project:
npm run build
- Load AWS product data:
npm run load-aws-data
- Start the server:
npm start
npm start
: Run the production servernpm run dev
: Run development server with hot reloadnpm run build
: Build the TypeScript projectnpm run lint
: Run ESLintnpm run format
: Format code with Prettiernpm run load-aws-data
: Load AWS product data into Pinecone
src/
├── config/ # Configuration files
│ ├── database.ts
│ └── index.ts
│
├── models/ # MongoDB models
│ ├── Customer.ts
│ ├── Event.ts
│ └── Message.ts
│
├── providers/ # External service providers
│ ├── together/
│ └── pinecone/
│
├── repositories/ # Data access layer
│ ├── Customer.ts
│ ├── Event.ts
│ └── Message.ts
│
├── scripts/ # Utility scripts
│ └── loadAwsProductData.ts
│
├── services/ # Business logic
│ ├── AIService.ts
│ ├── ConversationManager.ts
│ ├── EmbeddingService.ts
│ └── NodeService.ts
│
├── types/ # TypeScript types
│ ├── ai-provider.ts
│ ├── analysis.ts
│ ├── customer.ts
│ ├── events.ts
│ └── message.ts
│
├── utils/ # Utility functions
│ └── logger.ts
│
└── websocket/ # WebSocket handling
└── WebSocketManager.ts
The system implements a node-based conversation flow:
- Welcome Node
- Collect User Information
- Product Information
- Q&A Node
- Demo Scheduling
- End Conversation
Currently supports information about:
- Amazon EC2
- Amazon S3
- Amazon RDS
- Amazon DynamoDB
- AWS Lambda
- Secure WebSocket connections
- Environment-based configuration
- Input validation using Zod
- MongoDB security best practices
- API key management
Comprehensive logging system using Winston with:
- Console output
- File-based logging
- Error tracking
- Request/Response logging
- Performance monitoring