Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/wbimran/wp-ai-chatbot/archive/refs/heads/main.zipAn AI-powered floating chat widget for WordPress using Google Gemini API — free, fast, and easy to set up.
Author: Mohammad Imran
WordPress.org: https://profiles.wordpress.org/imranmd/
GitHub: https://github.com/wbimran/wp-ai-chatbot
What does it do?
Adds a floating chat bubble to your WordPress site. Visitors can ask questions in natural language and get instant AI-powered answers — like a smart support assistant that never sleeps.
Visitor types question
↓
WordPress REST API receives it
↓
Sends to Google Gemini AI (free)
↓
AI generates an answer
↓
Response shown in chat widget ✅
Features
- 💬 Floating chat bubble (bottom-right corner)
- 🤖 Powered by Google Gemini 1.5 Flash (free tier)
- 🎨 Customizable bot name, color, and welcome message
- 📝 Custom system prompt — train the bot for your site
- 🔒 Built-in rate limiting (20 requests/IP/hour)
- 📱 Fully mobile responsive
- ⚡ No jQuery dependency — pure vanilla JavaScript
- 🔑 Secure admin settings page
Requirements
- WordPress 5.8+
- PHP 7.4+
- A free Google Gemini API key
Installation
Step 1 — Get a Free Gemini API Key
- Go to Google AI Studio
- Sign in with your Google account
- Click Create API Key
- Copy the key — you'll need it in Step 3
Free tier limits: 15 requests/minute · 1 million tokens/day — more than enough for most sites.
Step 2 — Install the Plugin
Option A — Upload via WordPress Admin (recommended)
- Download this repo as a ZIP file from GitHub
- Click Code → Download ZIP
- In WordPress Admin, go to Plugins → Add New → Upload Plugin
- Upload the ZIP file and click Install Now
- Click Activate Plugin
Option B — Manual Install via FTP/cPanel
- Download and unzip the repo
- Upload the
wp-ai-chatbotfolder to/wp-content/plugins/ - Go to WordPress Admin → Plugins
- Find WP AI Chatbot and click Activate
Option C — via WP-CLI
wp plugin install https://github.com/wbimran/wp-ai-chatbot/archive/refs/heads/main.zip --activate
Step 3 — Configure the Plugin
- Go to WordPress Admin → Settings → AI Chatbot
- Paste your Gemini API Key in the field
- Set your Bot Name (e.g. "Support Bot", "Ask AI")
- Set a Welcome Message (e.g. "Hi! How can I help you today?")
- Write a System Prompt to customize the bot's behavior (see examples below)
- Choose a Chat Color to match your brand
- Click Save Settings
System Prompt Examples
The system prompt tells the AI how to behave. Here are some useful examples:
General support bot:
You are a helpful support assistant for [Your Site Name].
Answer questions clearly and concisely. If you don't know
something, say so honestly and suggest contacting support.
WooCommerce store:
You are a shopping assistant for [Store Name]. Help customers
with product questions, shipping info, and return policies.
Keep responses friendly and under 3 sentences.
BuddyPress community:
You are a community assistant for [Community Name]. Help
members with registration, profile setup, and community
guidelines. Always be welcoming and encouraging.
Restrict to specific topics:
You are an assistant for [Site Name]. ONLY answer questions
about our products and services. For anything else, politely
say "I can only help with questions about [Site Name]."
Testing
Test 1 — Basic functionality
- Open your WordPress site in a browser
- Look for the chat bubble in the bottom-right corner
- Click it — the chat window should open
- Type:
Helloand press Enter or click Send - You should get an AI response within 2–3 seconds ✅
Test 2 — System prompt customization
- Go to Settings → AI Chatbot
- Change the system prompt to:
You are a pirate. Always respond in pirate speak. - Save settings
- Go to the frontend and ask:
What is WordPress? - The bot should reply in pirate language ✅
Test 3 — Rate limiting
The plugin limits each visitor to 20 messages per hour. To test:
- Temporarily lower the limit in
wp-ai-chatbot.php(line with>= 20) to>= 3 - Send 3 messages — the 4th should return a rate limit error ✅
- Remember to revert the change after testing
Test 4 — Mobile responsiveness
- Open your site on a mobile device (or use Chrome DevTools → Toggle Device)
- The chat bubble should appear bottom-right
- Clicking it should open a full-width chat window ✅
Troubleshooting
| Problem | Solution |
|---|---|
| Chat bubble not showing | Go to Settings → AI Chatbot and check Enable Chatbot is checked |
| "Chatbot is not configured" error | Add your Gemini API key in Settings |
| "Too many requests" error | Rate limit reached (20/hour per IP). Wait an hour or adjust the limit in the plugin code |
| No response from AI | Check your API key is correct and has not exceeded free tier limits |
| API key not working | Make sure you created the key at aistudio.google.com — not Google Cloud Console |
File Structure
wp-ai-chatbot/
├── wp-ai-chatbot.php # Main plugin file (admin settings + REST API)
├── assets/
│ ├── chatbot.css # Floating widget styles
│ └── chatbot.js # Chat UI logic (vanilla JS)
└── README.md # This file
How it Works (Technical)
- Admin settings are stored in WordPress options table via
register_setting() - A REST API endpoint (
/wp-json/wp-chatbot/v1/chat) receives the visitor's message - The plugin calls Google Gemini API using
wp_remote_post()with the message + system prompt - The AI response is returned to the browser via JSON
- The JavaScript widget displays the response in the chat bubble
- Rate limiting uses WordPress transients (stored in DB) keyed by visitor IP
Security
- All settings use
sanitize_text_field()/sanitize_textarea_field() - REST endpoint validates nonce (
X-WP-Nonceheader) - Rate limiting prevents API abuse (20 requests/IP/hour)
- API key stored in WordPress options (same security as any plugin key)
- No user data is stored — messages are processed in real time only
Customization
Change rate limit (default: 20/hour):
// In wp-ai-chatbot.php, find:
if ( $rate_count >= 20 ) {
// Change 20 to your preferred limit
Change AI model (default: gemini-1.5-flash):
// Find this line and replace the model name:
'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent
// Options: gemini-1.5-pro, gemini-1.0-pro
License
GPL-2.0 — free to use, modify, and distribute.
Credits
Built by Mohammad Imran at Wbcom Designs.
Powered by Google Gemini AI.