Minimal WordPress chatbot using LLMs via API, ready to paste via Code Snippets.
A lightweight, self-contained AI chatbot for WordPress — combining frontend UI and backend logic in one PHP file. Easily connect it to LLMs like OpenRouter or Together AI via API.
- 💬 Chatbot UI + logic in a single PHP file
- 📱 mobile responsive
- 🧠 Supports any LLM API (OpenRouter, Together AI, etc.)
- 🔄 Memory for conversation ( Ai can remember user replies)
- ✍️ Customize system prompt and model behavior
- ⚡ No installation — simply copy-paste to WordPress
- 🧩 Minimal dependencies, fast setup
- Open the PHP file in VS Code or any text editor.
- Add your API credentials:
$api_key = 'your-api-key'; $model = 'your-model-name';
- Add the URL endpoint for your API Provider:
$response = wp_remote_post('https:// your-endpoint-here';
- Customize the system prompt inside the file to guide the assistant’s behavior.
- Copy the entire PHP code into your WordPress site using a plugin like:
✅ Code Snippets – WordPress Plugin
❗ Or embed it directly in your theme (functions.php) — not recommended for beginners
- ✨ Save and activate — the chatbot will appear on your site! 🥳
🧩 Customization
🔧 System Prompt – Personalize the chatbot's role, tone, and intent
🔄 Model Switching – Swap LLMs by changing the $model variable
🎨 Style/UI – Modify inline HTML/CSS directly in the file
🛠 Requirements
-
A WordPress website
-
API key from a supported AI provider (e.g., OpenRouter, Together AI)
-
The Code Snippets plugin (or manual theme editing)
📌 Notes
-
Everything is contained in one PHP file — no JS or CSS dependencies
-
Ideal for minimal deployments, demos, or fast LLM integrations into WordPress
-
You can further extend with webhooks, logging, or chat history
📜 License
-This project is open-source under the MIT License.
🤝 Contributions
- Feel free to open issues, suggest features, or submit pull requests. Let’s build smarter web experiences together!