This is a prototype AI agent system initially designed for solar panel installation companies but adaptable to virtually any industry through reconfiguration of its knowledge base and tools. The system enables customers to interact with different specialized AI agents through a chatbot interface, with the goal of reducing sales cycles and customer acquisition costs.
Based on prototype testing, systems like this could potentially deliver:
- 60% reduction in lead qualification time
- 45% decrease in cost per qualified lead
- 3x improvement in conversion rates from inquiry to appointment
The DemoSolar AI Agent System implements a multi-agent architecture that leverages Azure AI services:
flowchart TD
subgraph subGraph0["Multi-Agent System"]
Orchestrator["Orchestration Agent"]
API["Backend API"]
CS["Customer Support Agent"]
SA["Solar Assessment Agent"]
PA["Proposal Agent"]
CRM["CRM Agent"]
KB[("Knowledge Base")]
WebSearch["Web Search"]
Tools["External Tools"]
Offers[("Proposals/Offers")]
Appointments[("Appointments")]
end
subgraph subGraph1["Feedback System"]
FC["Feedback Collection"]
User("User")
FeedbackDB[("Feedback Storage")]
end
subgraph subGraph2["Azure Services"]
AzSearch["Azure AI Search"]
BraveAPI["Brave Search API"]
AzOpenAI["Azure OpenAI"]
CosmosDB[("Azure Cosmos DB")]
end
User <--> Frontend["Frontend UI"]
Frontend <--> API
API --> Orchestrator
Orchestrator --> CS & SA & PA & CRM & AzOpenAI
CS --> KB & WebSearch
SA --> Tools
PA --> Offers
CRM --> Appointments
User --> FC
FC --> FeedbackDB
KB --> AzSearch
WebSearch --> BraveAPI
Tools --> AzOpenAI
CosmosDB --> Appointments & Offers & FeedbackDB
Orchestrator:::primary
API:::secondary
WebSearch:::utility
FC:::utility
AzSearch:::azure
AzOpenAI:::azure
CosmosDB:::azure
Frontend:::secondary
classDef primary fill:#f9f,stroke:#333,stroke-width:2px
classDef secondary fill:#bbf,stroke:#333,stroke-width:1px
classDef azure fill:#bfb,stroke:#333,stroke-width:1px
classDef utility fill:#ffb,stroke:#333,stroke-width:1px
style Orchestrator fill:#FFFFFF,color:#000000
style API fill:#FFFFFF,color:#000000
style WebSearch color:#000000
style FC color:#000000
style AzSearch color:#000000
style AzOpenAI color:#000000
style CosmosDB color:#000000
style Frontend fill:#FFFFFF,color:#000000
style subGraph0 color:#000000
The system architecture follows a multi-agent design:
- Customer: Interacts with the system through a web interface
- Frontend UI: React-based user interface with chatbot component
- Backend API: Express server handling communication between frontend and agents
- Orchestration Agent: Central coordinator that routes requests to specialized agents
- Customer Support Agent: Handles educational queries using knowledge base and web search
- Assessment Agent: Evaluates customer requirements and property details
- Proposal Agent: Generates quotes and recommendations based on assessment data
- CRM Agent: Manages appointment scheduling and customer information
- Azure OpenAI: Powers all agent intelligence and natural language processing
- Azure AI Search: Provides knowledge retrieval for the Customer Support Agent
- Azure Cosmos DB: Persistent storage for all system data (proposals, appointments, etc.)
- Brave Search API: External service for web search capability
This architecture enables seamless handoffs between specialized agents while maintaining conversation context, creating a smooth customer experience from initial inquiry through consultation scheduling.
While currently configured for solar installation companies, this system can be readily adapted to various industries by:
-
Replacing the Knowledge Base: Upload industry-specific documents to Azure AI Search to create a new vector database for the RAG (Retrieval-Augmented Generation) system
-
Customizing Agent Roles: Adapt the specialized agents to match industry-specific needs:
- Education Agent β Product/service information
- Assessment Agent β Requirements gathering
- Proposal Agent β Quote/recommendation generation
- CRM Agent β Customer relationship management
-
Modifying Tool Integration: Connect to industry-specific tools and APIs
Industry | Knowledge Base | Assessment Focus | Proposal Focus | CRM Focus |
---|---|---|---|---|
Financial Services | Investment options, financial products | Financial goals, risk tolerance | Portfolio recommendations | Advisor meetings |
Healthcare | Medical information, services | Symptoms, medical history | Treatment options | Practitioner appointments |
Real Estate | Property information, market data | Housing needs, budget | Property recommendations | Agent showings |
Education | Course catalogs, programs | Learning goals, background | Program recommendations | Advisor meetings |
The system implements several key AI agent design patterns from Microsoft's "AI Agents for Beginners" course:
The solution employs multiple specialized agents that collaborate to provide a comprehensive service:
- Orchestration Agent: Routes user queries to specialized agents and manages conversation flow
- Customer Support Agent: Provides educational information using RAG
- Assessment Agent: Evaluates customer needs and requirements
- Proposal Agent: Generates customized quotes and recommendations
- CRM Agent: Manages appointment scheduling and customer information
The Customer Support Agent uses a RAG implementation to provide informed responses:
- Knowledge Retrieval: Searches Azure AI Search vector database for relevant information
- Web Search Fallback: When knowledge base is insufficient, uses Brave Search API
- Iterative Refinement: Evaluates search results and refines queries for better answers
- Self-Correction: Validates information before presenting it to users
Agents use specialized tools to perform actions beyond text generation:
- Document Processing: For analyzing relevant documents
- External APIs: For retrieving additional data
- CRM Integration: For appointment booking and data management
- Web Search: For retrieving up-to-date information when needed
The system implements approval workflows and user confirmation for critical decisions:
- Editable Confirmations: Users can review and adjust details
- Confidence Indicators: Transparency in how certain the system is about information
- Approval Workflows: For significant steps like quote generation
The agents use step-by-step planning to break down complex tasks:
- Assessment Planning: Structured approach for collecting information
- Proposal Generation: Systematic creation of recommendations
- Appointment Scheduling: Guided workflow for booking consultations
Agents can evaluate their own reasoning process:
- Self-Verification: Checking calculations and recommendations
- Reasoning Explanations: Providing justification for conclusions
- Confidence Scoring: Indicating certainty levels for responses
- Reflection Loops: Reconsideration of answer quality
The system uses a system message framework to maintain consistent agent behavior:
- Templatized System Prompts: For reproducible agent responses
- Persona Definitions: To maintain distinctive voice for each agent
- Clear Responsibility Boundaries: To prevent overlap between agents
The system implements several Responsible AI features:
- Confidence Scores: Each agent response includes a confidence rating
- Reasoning Explanations: Agents explain their reasoning for recommendations
- Source Citations: Knowledge-based responses include sources
- User Feedback Collection: System collects and stores feedback for potential improvement
- Transparency: Clear explanation of data usage and agent capabilities
This project leverages several key Microsoft Azure services that enable its adaptive capabilities:
-
Azure OpenAI Service: Powers all agents using GPT-4o-mini, enabling natural language understanding, response generation, and function calling capabilities.
-
Azure Cosmos DB: Serves as the data store with specialized containers for:
- Conversations: Stores chat history
- Assessments: Captures customer requirements
- Proposals: Stores generated quotes and recommendations
- Appointments: Manages consultation scheduling
- Users: Stores customer information
- Feedback: Collects user feedback
-
Azure AI Search: Enables semantic search over a vector database for the knowledge base, allowing the Customer Support Agent to retrieve relevant information for responses. This component enables easy adaptation to new industries by simply replacing the knowledge documents.
The project is organized as a fullstack JavaScript/TypeScript application:
demosolar/
βββ frontend/ # React frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ styles/ # CSS files
β β βββ ...
β βββ ...
βββ backend/ # Node.js/Express backend
βββ src/
β βββ agents/ # AI agent modules
β β βββ orchestrationAgent.ts # Central routing agent
β β βββ customerSupportAgent.ts # Educational support
β β βββ solarAssessmentAgent.ts # Needs evaluation
β β βββ proposalAgent.ts # Quote generation
β β βββ crmAgent.ts # Appointment scheduling
β β βββ systemPrompts.ts # Agent prompts and templates
β βββ routes/ # API routes
β βββ models/ # Type definitions
β βββ utils/ # Utility functions
β β βββ azureOpenAI.ts # OpenAI integration
β β βββ azureSearch.ts # AI Search integration
β β βββ cosmosDB.ts # Cosmos DB integration
β β βββ webSearch.ts # Brave Search integration
β β βββ responsibleAI.ts # AI confidence and reasoning utilities
β βββ index.ts # Server entry point
βββ ...
- Homepage: Showcases services and benefits
- Chatbot: Floating chat interface for customer interactions with:
- Response Confidence: Visual indicators for answer reliability
- Feedback Collection: Users can rate responses and provide comments
- Multilingual Support: Handles both English and Dutch
- Dashboard: Admin view of quotes, appointments, and customer interactions
- Mock Login: Simple demonstration login (no real authentication)
- AI Agent System: Routes customer inquiries to specialized agents
- Customer Support Agent: Answers common questions using RAG + web search
- Assessment Agent: Evaluates customer needs and requirements
- Proposal Agent: Generates customized recommendations and quotes
- CRM Agent: Schedules consultation appointments and manages customer data
- API Endpoints:
/api/ask
: Main endpoint for chatbot queries/api/crm/...
: Endpoints for the dashboard/api/feedback
: Endpoint for collecting user feedback
- Stateful Conversation: Maintains context across multiple turns
- Agentic RAG: Knowledge retrieval with web search fallback
- Human-in-the-Loop: Confirmation interfaces allowing users to review and edit details
- Appointment Booking: Workflow with date recognition and validation
- Feedback Collection: Storage for potential future improvements
The AI-powered proposal generation interface showing personalized solar system recommendations with detailed specifications and cost estimates.
The appointment booking system that handles consultation scheduling with natural language date recognition.
The CRM dashboard displaying customer interactions, quotes, and appointment management for sales teams.
- Node.js (v18 or later recommended)
- npm (usually comes with Node.js)
- Git
- An Azure account with access to OpenAI, Cosmos DB, and AI Search services.
- A Brave Search API Key (optional, for web search fallback) - Free tier available.
-
Clone the repository:
git clone https://github.com/JoshuaLevi/DemoSolar cd DemoSolar
-
Install Backend Dependencies:
cd backend npm install
-
Install Frontend Dependencies:
cd ../frontend npm install
-
Configure Backend Environment Variables:
- Navigate back to the
backend
directory:cd ../backend
- Create a
.env
file by copying the example:cp .env.example .env
(If.env.example
doesn't exist, create.env
manually). - Edit the
.env
file and fill in your specific Azure credentials:# Azure OpenAI AZURE_OPENAI_ENDPOINT="YOUR_AZURE_OPENAI_ENDPOINT" AZURE_OPENAI_API_KEY="YOUR_AZURE_OPENAI_API_KEY" AZURE_OPENAI_DEPLOYMENT="YOUR_GPT_DEPLOYMENT_NAME" # e.g., gpt-4o-mini AZURE_OPENAI_API_VERSION="2024-04-01-preview" # Or your API version # Azure AI Search (for RAG) AZURE_SEARCH_ENDPOINT="YOUR_AZURE_SEARCH_ENDPOINT" AZURE_SEARCH_API_KEY="YOUR_AZURE_SEARCH_ADMIN_KEY" AZURE_SEARCH_INDEX_NAME="YOUR_SEARCH_INDEX_NAME" # e.g., demosolar-knowledgebase # Azure Cosmos DB AZURE_COSMOSDB_ENDPOINT="YOUR_COSMOS_DB_ENDPOINT" AZURE_COSMOSDB_KEY="YOUR_COSMOS_DB_PRIMARY_KEY" AZURE_COSMOSDB_DATABASE="YOUR_DATABASE_NAME" # e.g., demosolar_db # Ensure containers exist: conversations, assessments, proposals, appointments, users, feedback # Partition keys (examples): /conversationId, /id, /userEmail, /id, /email, /conversationId # Brave Search API (Optional - for web search fallback) BRAVE_API_KEY="YOUR_BRAVE_SEARCH_API_KEY" # Server Port (Optional) PORT=5001
- Important: Ensure your Azure Cosmos DB instance has the following containers created with appropriate partition keys (examples provided above):
conversations
,assessments
,proposals
,appointments
,users
,feedback
. - Important: Ensure your Azure AI Search index (
AZURE_SEARCH_INDEX_NAME
) exists and is populated with data for the RAG functionality.
- Navigate back to the
-
Start the Backend Server:
- Make sure you are in the
backend
directory. - Run the development server:
npm run dev
- The backend should now be running, typically on port 5001.
- Make sure you are in the
-
Start the Frontend Server:
- Open a new terminal window/tab.
- Navigate to the
frontend
directory:cd ../frontend
(adjust path if needed). - Run the development server:
npm start
- This will usually open the application automatically in your default browser at
http://localhost:3000
.
-
Access the Application:
- Open your browser and navigate to
http://localhost:3000
if it didn't open automatically. - You should see the homepage and the chatbot interface.
- Open your browser and navigate to
- Visit the homepage and interact with the chatbot
- Ask questions about products or services
- Get a personalized assessment
- Request a quote or recommendation
- Schedule a consultation appointment
- Provide feedback on agent responses
- Click "Login" in the navbar (any username/password combination works)
- View the dashboard with tabs for:
- Quotes: See all generated quotes
- Appointments: View scheduled consultations
- Interactions: Review all customer conversations
- Assessment data: Track customer evaluations
This solution offers several advantages:
- Multi-agent architecture with specialized roles and clear handoff protocols
- Agentic RAG implementation with iterative query refinement and web search fallback
- Industry-adaptable design through knowledge base replacement and tool reconfiguration
- Human-in-the-loop design with approval workflows for critical decisions
- Azure service integration leveraging Microsoft's AI and cloud ecosystem
- Planning and metacognition patterns for improved reasoning and self-verification
- Feedback collection system for continuous improvement
This project is licensed under the MIT License - see the LICENSE file for details.