Content-Aware Chatbot (Claude Integration)
A proof-of-concept WordPress plugin that adds a simple chatbot interface powered by Claude AI. Responds to user input with context-aware answers based on page content.
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/amalter/claude-chatbot-plugin/archive/refs/heads/main.zipClaude Chatbot Plugin (Proof of Concept)
⚠️ Security Warning: This plugin is not production-ready. See warnings below.
Overview
This is a proof-of-concept WordPress plugin that integrates with the Claude API to create a simple, content-aware chatbot interface.
The chatbot attempts to provide contextually aware responses by leveraging the site's content and Anthropic's Claude API. It was built to explore:
- The process of integrating AI models into WordPress
- How to structure a lightweight chat interface in a plugin
- The use of prompt engineering in development
- The capabilities and limitations of using AI-generated code as a baseline
📖 Read more about the process and what I learned on my blog.
⚠️ Security Warning
This project is not secure and should not be used in production environments without significant hardening. Known issues include:
- ❌ No input validation or sanitization
- ❌ No authentication or access controls
- ❌ API keys stored insecurely
- ❌ Potential for data exposure and misuse
It is intended for learning and experimentation only. Use at your own risk.
Features
- Embeds a chat interface via a front-end container and script injection
- Basic front-end interface for user interaction
- AJAX-powered communication with a custom PHP endpoint
- API integration with Claude (Chat Completions endpoint)
- Rough implementation of content awareness (e.g., passing page content as part of the prompt)
Tech Stack
- PHP (WordPress plugin framework)
- JavaScript (front-end chat + AJAX)
- HTML/CSS (chat UI)
- Claude API (Anthropic)
Getting Started
- Clone or download this repo into your WordPress
wp-content/pluginsdirectory. - Activate the plugin in your WP admin.
- Go to plugin settings WP admin > Settings > Chat Bot Settings to add your Anthropic API Key
Note: This setup is intentionally simple and insecure — do not deploy without serious modification.
🔧 Future Improvements
- [ ] Sanitize and validate all user input
- [ ] Implement nonce-based verification for AJAX requests
- [ ] Move API keys to environment variables or use WordPress secrets management
- [ ] Add user authentication and permission checks (e.g., only show chatbot to certain roles)
- [ ] Escape output to prevent XSS vulnerabilities
- [ ] Refactor for shortcode support
- [ ] Improve error handling and user feedback in the UI
- [ ] Make front-end styles and markup more customizable (via filters or templates)
- [ ] Add session context or memory for ongoing conversations
- [ ] Log or store anonymized chat data for learning purposes (with opt-in)
- [ ] Write unit and integration tests
- [ ] Optimize prompt strategy for better contextual accuracy
License
This code is provided as-is, without warranty of any kind. It is intended for educational use only.
Credits
Built with the help of:
Author
Amber Alter
amberalter.com