Smart AI Chatbot
Advanced AI chatbot with Gemini and ChatGPT integration, content scraping, and product recommendations.
by AI Developer · github.com/itshassanraza/wordpress-ai-chatbot-plugin
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/itshassanraza/wordpress-ai-chatbot-plugin/archive/refs/heads/main.zipSmart AI Chatbot - WordPress Plugin
Requires: WordPress with PHP support Optional: WooCommerce for product recommendations
An advanced AI-powered chatbot plugin for WordPress with Google Gemini and OpenAI ChatGPT integration, content-aware responses, WooCommerce product recommendations, and built-in analytics.
Features
AI Provider Support
| Provider | Models |
|---|---|
| Google Gemini | Gemini 2.0 Flash (Free), Gemini 2.0 Pro |
| OpenAI | GPT-4o, GPT-4 Turbo, GPT-3.5 Turbo |
Core Capabilities
- Conversational AI — Real-time chat powered by Gemini or ChatGPT
- Page-Specific Context — Automatically analyzes the current page content to deliver relevant, contextual answers
- Suggested Queries — Displays smart default and page-specific suggested questions to guide users
- WooCommerce Integration — Extracts product details, prices, and attributes for recommendations
- Session Management — Tracks conversations with unique session IDs
- FAQ System — Add custom business Q&A pairs for consistent, accurate responses
- Auto-Open — Chatbot can automatically open after a configurable delay
- Suggested Popup — Floating popup with suggested queries when the chatbot is minimized
- Typing Indicator — Visual feedback while waiting for AI responses
- Message History — Full conversation thread maintained within each session
Customization
- Custom primary color via color picker
- Adjustable position (bottom-left or bottom-right)
- Configurable width (250–600px) and height (300–800px)
- Adjustable spacing from screen edges
- Custom chatbot name, welcome message, and placeholder text
- Toggle "Powered by" branding on/off
- Live preview in admin settings
Analytics & Reporting
- Total conversations and unique sessions counters
- Average conversations per session
- 30-day conversation trend chart
- Top 10 most common questions
- Top 10 most active pages
- Recent conversations with expandable full answers
- CSV export of analytics data
Advanced Controls
- Page Exclusion — Hide the chatbot from specific pages using wildcard patterns (e.g.,
/product/*) - User Role Restrictions — Control chatbot visibility by WordPress user role (including guests)
- Data Management — Clear all conversation history from the admin panel
- Export/Import Settings — Backup and restore your full configuration as a JSON file
- Mobile Responsive — Fully functional on all device sizes
Installation
- Download or clone this repository into your WordPress
wp-content/plugins/directory:wp-content/plugins/Smart-AI-Chatbot-Plugin/ - Go to WordPress Admin → Plugins and activate Smart AI Chatbot.
- Navigate to Smart Chatbot → Settings in the admin sidebar.
- Enter your API key (Google Gemini or OpenAI) and select your preferred AI model.
- Configure appearance and behavior to your liking.
- The chatbot will automatically appear on your site's frontend.
Configuration
Settings Tabs
General
| Setting | Description |
|---|---|
| API Key | Your Google Gemini or OpenAI API key |
| AI Model | Choose from Gemini 2.0 Flash, Gemini 2.0 Pro, GPT-4o, GPT-4 Turbo, or GPT-3.5 Turbo |
| Chatbot Name | Display name shown in the chat header (default: "AI Assistant") |
| Welcome Message | First message the user sees when opening the chatbot |
| Placeholder Text | Input field placeholder text |
| Auto Open | Automatically open the chatbot for new visitors |
| Auto Open Delay | Delay in seconds before auto-opening (1–60s) |
Appearance
| Setting | Description |
|---|---|
| Primary Color | Main theme color for the chatbot UI |
| Position | Bottom-left or bottom-right of the screen |
| Width | Chatbot widget width (250–600px) |
| Height | Chatbot widget height (300–800px) |
| Bottom Spacing | Distance from the bottom edge (0–100px) |
| Side Spacing | Distance from the side edge (0–100px) |
| Show Branding | Toggle the "Powered by" attribution text |
A live preview panel updates in real time as you adjust appearance settings.
Content
| Setting | Description |
|---|---|
| Default Suggested Queries | Pre-written queries shown to users (one per line) |
| Generate Page-Specific Queries | Auto-generate contextual suggestions per page type |
| Contact Information | Business contact details for the AI to reference |
| Additional Business Info | Extra context about your business for better responses |
| FAQs | Link to the dedicated FAQ management page |
Advanced
| Setting | Description |
|---|---|
| Excluded Pages | Wildcard patterns to hide the chatbot (e.g., /checkout/*) |
| User Roles | Restrict visibility to specific WordPress roles |
| Clear Data | Delete all stored conversation data |
| Export Settings | Download current configuration as JSON |
| Import Settings | Restore configuration from a JSON file |
FAQ Management
Navigate to Smart Chatbot → FAQs to manage your business-specific questions and answers.
Format:
Question: What are your business hours?
Answer: We are open Monday to Friday, 9 AM to 5 PM.
Question: Do you offer free shipping?
Answer: Yes, free shipping is available on orders over $50.
FAQs are included as context in AI prompts, ensuring consistent and accurate responses for common questions.
Analytics
Navigate to Smart Chatbot → Analytics to view chatbot performance:
- Summary Cards — Total conversations, unique sessions, and avg. conversations per session
- Trend Chart — Visual 30-day conversation history using Chart.js
- Top Questions — The 10 most frequently asked questions
- Top Pages — The 10 pages with the most chatbot interactions
- Recent Conversations — Latest Q&A exchanges with expandable details
- Export — Download all analytics data as CSV
- Clear — Remove all analytics data
Page-Specific Context
The chatbot automatically detects the page type and tailors its suggested queries:
| Page Type | Example Suggestions |
|---|---|
| Product (WooCommerce) | "Tell me more about [product]", features, current offers |
| Blog Post | "Summarize [title]", key points, related articles |
| Page | "What is [title] about?", explanations |
| Archive / Category | "What can I find here?", popular content |
| Search Results | "Find top results for [query]" |
| Homepage | "What is [site name]?", services, contact info |
File Structure
Smart-AI-Chatbot-Plugin/
├── smart-ai-chatbot.php # Main plugin file — hooks, init, AJAX handlers, AI API calls
├── admin/
│ ├── settings.php # Tabbed admin settings page with live preview
│ ├── analytics.php # Analytics dashboard with charts and data tables
│ └── faqs.php # FAQ editor and help documentation
├── assets/
│ ├── css/
│ │ ├── admin.css # Admin panel styling
│ │ └── frontend.css # Chatbot widget styling and animations
│ └── js/
│ ├── admin.js # Admin event handlers, color picker, import/export
│ └── frontend.js # Frontend chatbot UI logic, AJAX, session management
├── components/
│ └── ui/
│ └── chart.js # Chart.js integration for analytics
└── templates/
└── chatbot.php # Frontend HTML template for the chatbot widget
Database
The plugin creates a custom table {prefix}_smart_chatbot_conversations on activation:
| Column | Type | Description |
|---|---|---|
| id | mediumint | Primary key (auto-increment) |
| user_id | mediumint | WordPress user ID (if logged in) |
| session_id | varchar(255) | Unique visitor session identifier |
| question | text | User's question |
| answer | text | AI's response |
| page_url | varchar(255) | URL where the question was asked |
| page_title | varchar(255) | Title of the page |
| created_at | datetime | Timestamp of the interaction |
The table is automatically dropped when the plugin is uninstalled.
Security
- Nonce verification on all AJAX requests
- Capability checks (
manage_options) for all admin operations - Input sanitization using
sanitize_text_field(),sanitize_hex_color(), andsanitize_textarea_field() - Output escaping with
esc_attr()andesc_html()
Dependencies
| Dependency | Source |
|---|---|
| jQuery & jQuery UI | WordPress core (bundled) |
| WP Color Picker | WordPress core (bundled) |
| Chart.js 3.7.1 | CDN (cdn.jsdelivr.net) |
| WooCommerce | Optional — enables product recommendations |
Hooks & Filters
Actions
| Hook | Purpose |
|---|---|
plugins_loaded |
Plugin initialization |
activate_{plugin} |
Create database table on activation |
deactivate_{plugin} |
Cleanup on deactivation |
uninstall_{plugin} |
Drop tables and delete options |
AJAX Endpoints
| Action | Access | Purpose |
|---|---|---|
smart_chatbot_get_chat |
Public + Logged-in | Process chat messages |
smart_chatbot_save_settings |
Admin only | Save plugin settings |
smart_chatbot_clear_analytics |
Admin only | Clear analytics data |
smart_chatbot_clear_data |
Admin only | Delete all chatbot data |
License
This plugin is licensed for use with WordPress.