Skip to content

Repository files navigation

πŸ€– OmniAssistant

AI-Powered Conversational Chatbot with Business Intelligence

An intelligent chatbot platform for pest control services featuring lead qualification, knowledge base retrieval, and comprehensive admin dashboard. Built with Next.js and Google Genkit for powerful AI conversations.

License: MIT Next.js TypeScript Genkit

Live Demo Β· Report Bug Β· Request Feature


πŸ“‘ Table of Contents


✨ Features

🎯 Core Features

  • AI-Powered Conversations: Intelligent chat using Google Gemini
  • Knowledge Base: Markdown-based knowledge retrieval
  • Lead Qualification: Smart form-based lead capture
  • Multi-Conversation: Handle multiple customer chats
  • Real-time Responses: Instant AI-generated replies
  • Context Awareness: Maintains conversation history

πŸ”’ Admin Features

  • Comprehensive Dashboard: Full business overview
  • Conversation Management: View and manage all chats
  • Lead Management: Track and qualify potential customers
  • Order Tracking: Monitor service orders and status
  • Knowledge Base Editor: Manage FAQ and resources
  • Analytics: Insights into customer interactions

🎬 Demo

Chat Interface

Customers interact with an intelligent AI assistant that can:

  • Answer pest control questions from the knowledge base
  • Qualify leads through conversational forms
  • Provide service information and pricing
  • Schedule appointments and consultations

Admin Dashboard

Business owners get access to:

  • Overview Page: Key metrics and recent activity
  • Conversations: All customer chat histories
  • Leads: Qualified prospects with contact information
  • Orders: Service requests and their status
  • Knowledge Base: Content management for FAQ

πŸ—οΈ Architecture

graph TB
    A[Customer Chat UI] -->|User Message| B[Next.js API Routes]
    B -->|AI Request| C[Genkit AI Flows]
    C -->|Query| D[Knowledge Base - Markdown]
    C -->|Generate| E[Google Gemini AI]
    E -->|Response| B
    B -->|Display| A
    F[Admin Dashboard] -->|Manage| G[Mock Data Store]
    C -->|Store| G
Loading

Key Components

Frontend (Next.js + React)

  • Server-side rendering for optimal performance
  • Beautiful UI with shadcn/ui components
  • Responsive design for all devices
  • Real-time chat interface

AI Layer (Genkit)

  • Conversation flow management
  • Knowledge base retrieval with embeddings
  • Lead qualification logic
  • Integration with Google Gemini

Backend (Next.js API Routes)

  • RESTful API endpoints
  • Server actions for mutations
  • Mock data storage (easily replaceable with DB)

πŸ›  Tech Stack

Frontend

Next.js React TypeScript TailwindCSS

AI & Backend

Genkit Google AI

UI Components

shadcn/ui Radix UI


πŸš€ Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js 20+ (Download)
  • npm or yarn
  • Google AI API Key (Get Key - Free tier available)

Installation

  1. Clone the repository
git clone https://github.com/mu7ammad-3li/OmniAssistant.git
cd OmniAssistant
  1. Install dependencies
npm install

Configuration

  1. Create environment file

Create a .env.local file in the root directory:

# Google AI (Gemini) Configuration
GOOGLE_GENAI_API_KEY=your-google-ai-api-key-here

# Application Configuration
NEXT_PUBLIC_APP_NAME=OmniAssistant
NEXT_PUBLIC_APP_URL=http://localhost:9002

# Optional: Development Settings
NODE_ENV=development

Getting Google AI API Key:

  1. Visit Google AI Studio

  2. Sign in with your Google account

  3. Click "Get API Key"

  4. Create a new API key

  5. Copy the key to your .env.local file

  6. Run the development server

Option 1: Next.js only

npm run dev

Option 2: Next.js + Genkit Dev UI

In separate terminals:

# Terminal 1: Next.js dev server
npm run dev

# Terminal 2: Genkit development UI (for AI flow testing)
npm run genkit:dev

The application will be running at:

  1. Build for production
npm run build
npm run start

πŸ“ Project Structure

OmniAssistant/
β”œβ”€β”€ πŸ“‚ src/                          # Source code
β”‚   β”œβ”€β”€ πŸ“‚ app/                      # Next.js app directory
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ admin/               # Admin dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“‚ conversations/  # Conversation management
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“‚ leads/          # Lead management
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“‚ orders/         # Order management
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“‚ kb/             # Knowledge base editor
β”‚   β”‚   β”‚   β”œβ”€β”€ layout.tsx         # Admin layout
β”‚   β”‚   β”‚   └── page.tsx           # Dashboard overview
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ api/                 # API routes
β”‚   β”‚   β”‚   └── πŸ“‚ genkit/         # Genkit API endpoints
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ chat/                # Customer chat interface
β”‚   β”‚   β”‚   └── page.tsx           # Chat page
β”‚   β”‚   β”œβ”€β”€ layout.tsx              # Root layout
β”‚   β”‚   β”œβ”€β”€ page.tsx                # Home page
β”‚   β”‚   └── globals.css             # Global styles
β”‚   β”œβ”€β”€ πŸ“‚ ai/                       # Genkit AI flows
β”‚   β”‚   β”œβ”€β”€ conversation-flow.ts    # Main conversation AI
β”‚   β”‚   β”œβ”€β”€ lead-qualification.ts   # Lead capture flow
β”‚   β”‚   β”œβ”€β”€ knowledge-retrieval.ts  # KB search flow
β”‚   β”‚   β”œβ”€β”€ dev.ts                  # Genkit dev server
β”‚   β”‚   └── index.ts                # AI exports
β”‚   β”œβ”€β”€ πŸ“‚ components/               # React components
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ ui/                  # shadcn/ui components
β”‚   β”‚   β”‚   β”œβ”€β”€ button.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ card.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ dialog.tsx
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ chat/                # Chat components
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatMessage.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatInput.tsx
β”‚   β”‚   β”‚   └── ChatInterface.tsx
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ admin/               # Admin components
β”‚   β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ StatCard.tsx
β”‚   β”‚   β”‚   └── DataTable.tsx
β”‚   β”‚   └── πŸ“‚ forms/               # Form components
β”‚   β”‚       └── LeadQualificationForm.tsx
β”‚   β”œβ”€β”€ πŸ“‚ hooks/                    # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ useChat.ts
β”‚   β”‚   └── useConversations.ts
β”‚   β”œβ”€β”€ πŸ“‚ kb/                       # Knowledge base (Markdown)
β”‚   β”‚   β”œβ”€β”€ pest-identification.md
β”‚   β”‚   β”œβ”€β”€ treatment-methods.md
β”‚   β”‚   β”œβ”€β”€ prevention-tips.md
β”‚   β”‚   └── pricing-info.md
β”‚   β”œβ”€β”€ πŸ“‚ lib/                      # Utilities
β”‚   β”‚   β”œβ”€β”€ mock-data.ts            # Mock data store
β”‚   β”‚   └── utils.ts                # Helper functions
β”‚   └── πŸ“‚ types/                    # TypeScript types
β”‚       β”œβ”€β”€ conversation.ts
β”‚       β”œβ”€β”€ lead.ts
β”‚       └── order.ts
β”œβ”€β”€ πŸ“‚ public/                       # Static assets
β”œβ”€β”€ .env.local                       # Environment variables (create this)
β”œβ”€β”€ .env.example                     # Environment template
β”œβ”€β”€ .gitignore                       # Git ignore rules
β”œβ”€β”€ next.config.js                   # Next.js configuration
β”œβ”€β”€ package.json                     # Dependencies and scripts
β”œβ”€β”€ tailwind.config.ts               # Tailwind configuration
β”œβ”€β”€ tsconfig.json                    # TypeScript configuration
└── README.md                        # This file

πŸ€– AI Flows

OmniAssistant uses Google Genkit to power three main AI flows:

1. Conversation Flow (conversation-flow.ts)

Handles general customer conversations:

  • Understands pest control questions
  • Retrieves relevant information from knowledge base
  • Maintains conversation context
  • Provides helpful, natural responses

2. Lead Qualification (lead-qualification.ts)

Intelligently qualifies potential customers:

  • Asks relevant qualifying questions
  • Captures contact information
  • Assesses urgency and service needs
  • Stores lead data for follow-up

3. Knowledge Retrieval (knowledge-retrieval.ts)

Searches the knowledge base:

  • Converts Markdown files to embeddings
  • Performs semantic search
  • Returns relevant content chunks
  • Integrates with conversation flow

Testing AI Flows

Use the Genkit Dev UI to test AI flows in isolation:

npm run genkit:dev

Visit http://localhost:4000 to interact with individual flows.


πŸ“Š Admin Dashboard

The admin dashboard provides complete business management:

Dashboard Overview

  • Total Conversations: Count of customer chats
  • Active Leads: Qualified prospects
  • Pending Orders: Service requests awaiting action
  • Recent Activity: Latest conversations and leads

Conversations Page

  • View all customer conversations
  • Search and filter by customer or date
  • See full conversation history
  • Mark conversations as resolved

Leads Page

  • Manage qualified leads
  • Contact information and needs
  • Lead source and qualification status
  • Export leads as CSV

Orders Page

  • Track service orders
  • Update order status
  • View customer details
  • Manage fulfillment

Knowledge Base

  • Edit Markdown knowledge base files
  • Add new FAQ entries
  • Organize content by category
  • Preview changes

πŸ“œ Available Scripts

# Development server (Next.js only)
npm run dev

# Genkit AI flow development UI
npm run genkit:dev

# Genkit with auto-reload (watch mode)
npm run genkit:watch

# Build for production
npm run build

# Start production server
npm run start

# Lint code
npm run lint

# Type check
npm run typecheck

🌐 Deployment

Deploy to Vercel (Recommended)

  1. Install Vercel CLI
npm install -g vercel
  1. Set environment variables in Vercel dashboard
GOOGLE_GENAI_API_KEY=your-api-key
  1. Deploy
vercel

Deploy to Other Platforms

Netlify:

npm run build
# Deploy the .next folder

Docker:

FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
CMD ["npm", "start"]

πŸ”„ Replacing Mock Data

The project currently uses mock data for demonstration. To integrate with a real database:

  1. Choose a database (PostgreSQL, MongoDB, Firebase, etc.)
  2. Install database client
npm install prisma @prisma/client  # Example for Prisma
  1. Replace mock functions in src/lib/mock-data.ts
  2. Update API routes to use real database queries
  3. Add authentication for admin dashboard

🀝 Contributing

Contributions are what make the open-source community amazing! Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

Distributed under the MIT License. See LICENSE for more information.


πŸ“§ Contact

Muhammad Ali

Project Link: https://github.com/mu7ammad-3li/OmniAssistant


πŸ™ Acknowledgments


Built with ❀️ by Muhammad Ali

Intelligent Conversations, Powered by AI

⬆ Back to Top

About

AI-powered chatbot (Next.js + Genkit)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages