=== AI Chatbot Free Models – Customer Support, Live Chat, Virtual Assistant ===
Contributors: NewCodeByte
Requires at least: 5.0
Requires PHP: 7.4
Tested up to: 6.9
Stable tag: 1.6.7
Tags: ai chatbot, chatbot, live chat, virtual assistant, customer support
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Add an AI Chatbot to your WordPress site for instant live chat or customer support. Featuring GPT, Claude, Llama and 70+ free models.

== Description ==

**Important Notice for Users Updating to Version 1.6.6+**

The latest update improves the plugin's file structure for better performance. As a result, the default paths for some images (like the chatbot icon and avatars) have changed.

If you notice that the chatbot button or avatars are not appearing after the update, it is almost certainly due to your browser or website's cache.

Solution: Please perform a "hard refresh" in your browser (Ctrl+F5 on Windows/Linux, Cmd+Shift+R on Mac). If you use a caching plugin (like WP Rocket, LiteSpeed, WP Fastest Cache etc.), please purge all caches from your plugin's settings. This will solve the issue.

AI Chatbot Free Models empowers you to integrate a cutting-edge AI chatbot into your WordPress website! Unlock the potential of over 400 AI models through OpenRouter.ai, including industry-leading options like ChatGPT, Claude, Grok 4 and Google Gemini 2.5 Pro, as well as powerful open-source alternatives such as Llama, Mistral, and DeepSeek! Choose from a wide array of both free and premium models to perfectly match your needs and budget.
Unlike many other plugins, all management and customization happen entirely within your WordPress backend, no need to visit external sites for configuration. The only account required is to obtain your free API key.

Looking for a platform-independent version?  
This chatbot is also available as a standalone version for use in non-WordPress websites (HTML, PHP, etc.).  
[Get it on GitHub](https://github.com/NewCodeByte/chatbot-ai-free-models)

## Use Cases

Here are several practical ways to use Chatbot AI Free Models on your WordPress website:

- **24/7 Customer Support**  
  Provide instant answers to visitors at any time, improving engagement and reducing support workload.

- **Lead Generation Assistant**  
  Qualify visitors and collect contact information through conversational interaction.

- **Product Recommendation Bot**  
  Help users find suitable products or services using natural language queries.

- **Content Navigation Helper**  
  Guide users to the right blog posts, categories, or pages based on their questions.

- **Automated Live Chat for Immediate Engagement**
  Deploy an automated assistant that mimics a live chat operator. It can greet visitors, answer initial questions, and guide them, ensuring every user feels supported.

- **Knowledge Base Access**  
  Offer a conversational interface to your FAQ, help articles, or documentation.

- **Idea Generation for Writers and Bloggers**  
  Suggest article topics, headlines, or summaries directly within your website.

- **Multilingual Support**  
  Serve users in multiple languages by selecting models with multilingual capabilities.

- **Chatbot-Powered Helpdesk**
  Turn your chatbot into a powerful first-line helpdesk. It provides instant, automated support 24/7 and captures visitor details with an optional pre-chat form.

- **Free AI Integration**  
  Use free models from OpenRouter without additional costs or complex setup.

== Installation ==

1.  Do not install this plugin directly via manual upload. Please use only the official WordPress.org directory.
2.  Activate the plugin through the 'Plugins' screen in WordPress.
3.  Go to the "Chatbot" settings page in the WordPress admin menu to configure the plugin.

== Configuration – Setting up your AI Chatbot ==

1.  Get a Free API Key from OpenRouter.ai (Yes, it's free!). OpenRouter offers access to over 400 models, including ChatGPT, Claude, DeepSeek, Gemini, and many others, all at competitive prices!
2.  Enter your OpenRouter API Key in the "Settings" tab.
3.  Choose an AI Model. Free models have the suffix ":free" at the end of their name. Note that all models are accessed THROUGH OpenRouter, regardless of the original provider.
4.  Provide context about your website in the "Information for responses" field.
5.  Customize the chatbot's appearance in the "Style" and "Images" tabs.
6.  Click "Save settings". Remember to refresh your website (Ctrl+F5 or Cmd+Shift+R) after saving, otherwise the changes may not be displayed correctly due to caching.

== Message and IP Saving ==

You can enable or disable the saving of chat messages and user IP addresses in the "Messages" tab of the settings page. Message saving is disabled by default for privacy reasons. If enabled, all chat messages and IP addresses will be stored securely within **the plugin's dedicated database**.

Using a dedicated database offers several advantages:

*   Simplified Management: All chatbot-related data is contained in a single location, making it easier to manage and maintain.
*   Reduced Impact: Storing data separately minimizes the impact on your website's core database performance.

**Important:** If you choose to enable message and IP saving, you **MUST** update your website's privacy policy to reflect this data collection practice and inform your users accordingly. You are responsible for complying with all applicable privacy laws.

== Enabling "Powered by NewCodeByte" ==
Enabling "Powered by NewCodeByte" helps me support the development of this free plugin. If you enjoy Chatbot AI Free Models, please consider enabling it!
If you'd prefer not to display the "Powered by NewCodeByte" link, you can support me with a donation on Buy Me a Coffee via Buy Me a Coffee.
All donations are greatly appreciated and will help me continue to improve and maintain this plugin.

== Frequently Asked Questions ==

**Q: The chatbot isn't working or responding after updating the plugin. What should I do?**

**A:** This is an issue that can occur in rare cases after an update, especially if the new version includes changes to the internal database structure (as was the case in version 1.6).

WordPress's update process sometimes doesn't fully execute all the necessary steps to adapt the plugin's database to the new changes. Fortunately, there's a simple and quick fix that will resolve the problem in most cases: **manually deactivate and reactivate the plugin**.

Follow these steps:

1.  Log in to your WordPress admin dashboard.
2.  Navigate to the **Plugins > Installed Plugins** section.
3.  Find the "**Chatbot AI Free Models**" plugin in the list of installed plugins.
4.  Below the plugin name, you will see a **Deactivate** link. Click on it.
5.  Once the plugin has been successfully deactivated, the link will change to **Activate**. Click on it to reactivate the plugin.

This action will force the complete execution of all activation and update scripts included with the plugin, including those for the database. Once reactivated, check your frontend site and the chatbot settings page again. The issue should be resolved, and the chatbot should function correctly.

If the problem persists after following these steps, please contact support and provide a detailed description of the issue and the steps you have already tried.

**Q: Where do I get an API key?**
A: You can get a free API key from OpenRouter.ai.

**Q: How do I change the look of the chatbot?**
A: You can customize the chatbot's appearance in the "Style" and "Images" tabs on the settings page.

**Q: The chatbot isn't responding. What do I do?**
A: First, check your API key and make sure it's valid.
A: Second, check the OpenRouter status page to see if there are any known issues with the API.
A: Third, if the issue persists, try switching to a different model. Free models can sometimes experience high traffic and connection problems, so experimenting with alternative models might resolve the issue.

**Q: How do I know if there are new messages?**
A: Yes, the plugin includes an automatic notification system to alert you of new, unread conversations. Here’s how it works:

* **Notification Badge in the Menu:** When a user starts a new conversation, a **red notification badge** with a number will appear next to the 'Chatbot' menu item in your WordPress admin sidebar. This number does not represent individual messages, but rather the **total number of conversations** that contain at least one unread message.

* **Detailed Tooltip:** If you hover your mouse over the "Chatbot" menu item, a tooltip will provide more details (e.g., "You have 2 unread conversations").

* **Highlighting in the Table:** Once you navigate to the 'Messages' tab, unread conversations are easy to spot because the entire row is displayed in **bold text**.

* **How to Mark as Read:** To mark a conversation as 'read' and decrease the notification counter, simply **click on the conversation's row** to view its messages. The action is automatic, and the bold styling will disappear.

== External Services ==

Chatbot AI Free Models allows you to connect your site to AI services via OpenRouter. You need your own API key and must comply with their Terms of Service and Privacy Policy.

The plugin developer is not responsible for any issues or damages resulting from the use of the plugin or AI-generated content. Make sure your usage complies with the laws of your country. All data stays on your server, it's your responsibility to keep it secure.

*   **OpenRouter Terms of Service and Privacy Policy:**
    *   **Terms of Service:** [https://openrouter.ai/terms](https://openrouter.ai/terms)
    *   **Privacy Policy:** [https://openrouter.ai/privacy](https://openrouter.ai/privacy)

== Changelog ==

= 1.6.7 =
* Enhancement: The conversation history is now managed via sessionStorage, making it more robust and independent from PHP sessions.
* Enhancement: Session storage keys are now unique to each site, preventing chat history from being shared across different sites on the same domain (e.g., in a local development environment).
* Enhancement: Improved CSS for chat bubbles to ensure consistent height and layout across different browsers and themes.
* Fix: Corrected a critical caching issue that prevented styles and scripts from loading for non-logged-in users on sites with aggressive server-side caching.
* Fix: Resolved a bug where the first message of a new conversation would not appear in the admin panel until a second message was sent.
* Fix: Corrected all remaining incorrect asset paths (images, sounds) following the code refactoring.
* Fix: The chatbot widget button and proactive message no longer appear when the shortcode display mode is active.

= 1.6.6 =
* Security Fix: Hardened the CSV export function to prevent formula injection. All fields are now sanitized to neutralize potentially malicious input. Props to Wordfence for the responsible disclosure.
* Dev: Complete code refactoring for better performance, maintainability, and scalability. The plugin is now fully object-oriented and follows modern WordPress standards.
* Enhancement: The CSS for the embedded shortcode view has been completely redesigned for a more professional and integrated look.
* Fix: The chatbot widget button no longer appears incorrectly when the shortcode display mode is selected.
* Fix: Resolved a critical bug that prevented new conversations from being displayed in the admin panel after updating from a previous version.
* Fix: The unread message notification counter is now correctly cleared upon plugin uninstallation.
* Fix: Corrected all asset paths (CSS, JS, images) to work with the new modular file structure.
* Tweak: Separated frontend and backend CSS files to ensure only necessary styles are loaded.

= 1.6.4 =
* New: Unread conversation notifications! A red badge will now appear on the 'Chatbot' admin menu item, showing the count of unread conversations.
* New: Conversation IDs are now clean and sequential (e.g., Chat_1, Chat_2) instead of the long, timestamp-based string.
* Enhancement: The admin message list has been improved. Unread conversations are now highlighted in bold for easy identification.
* Enhancement: Added a descriptive tooltip to the admin menu badge, showing the exact number of unread conversations on hover.
* Dev: Major refactor of the database schema. A new conversations table has been introduced to manage conversations more robustly and enable sequential IDs.

= 1.6.3 =
* New: Added a "Display Mode" option to show the chatbot either as a floating widget or embedded directly into a page/post using the `[newcodebyte_chatbot]` shortcode.
* Tweak: The CSS has been hardened to prevent layout issues caused by aggressive themes or other plugins.

= 1.6.2 =
* Feature: The chatbot's position can now be set to the bottom-left or bottom-right corner via the Style settings, improving compatibility with themes and other widgets.
* Feature: The API Key field now masks the input (shows dots) and includes a toggle button to show/hide the key for better security and usability.
* Tweak: The API Key input field now dynamically resizes to fit the entire key, preventing it from being cut off.
* Tweak: The admin conversation view has been restyled for better readability, with full-width message bands and improved spacing.
* Fix: Resolved a major stability issue where conversations would fail to save on certain hosting environments (like AlterVista) due to session handling conflicts.
* Fix: Corrected a CSS conflict that prevented the chat button from moving to the selected position on both desktop and mobile views.
* Fix: Addressed a layout bug on mobile devices where the chat window would be partially cut off.
* Fix: Resolved a JavaScript error that displayed an [object Object] alert after deleting messages.

= 1.6.1 =
* Tweak: The proactive message bubble now automatically resizes to fit the text content, improving its appearance.
* Tweak: The text formatting (line breaks) in the proactive message is now correctly displayed.
* Fix: Corrected a CSS issue that could cause the chat button to appear distorted or deformed on some themes after the recent update.
* Added a new "NewCodeByte Plugins" tab to display a list of other plugins by NewCodeByte.

= 1.6 =
* New Feature: Added an optional Pre-Chat Form to collect user's name and email before the conversation starts. This can be enabled in the "Settings" tab.
* New Feature: Added a proactive welcome message bubble that appears next to the chat button to encourage user engagement. The text and appearance delay can be customized in the "Settings" tab.
* Major Improvement: The "Messages" tab in the admin panel has been completely redesigned. Messages are now grouped by conversation for a much clearer and more professional overview.
* Improvement: The conversation view in the admin panel now displays the user's provided name or email instead of the generic "User" label, making it easier to identify conversations.
* Improvement: The conversation view in the admin panel now uses the same custom colors chosen for the frontend chat, ensuring a consistent design experience.
* Improvement: The database schema has been updated to store conversation data more efficiently, including a unique conversation ID and user details. An automatic update script ensures a seamless transition for existing users.
* Improvement: The conversation export feature has been updated to export data grouped by conversation, making the exported files (TXT, CSV, MD, HTML) significantly more useful and organized.
* Tweak: The file naming convention for exported conversations is now simpler and more user-friendly (e.g., `conversations_YYYY-MM-DD.txt`).
* Tweak: Added a `cursor: pointer` to the conversation list in the admin panel to improve usability and indicate that a conversation is clickable.
* Tweak: Added an option to customize the height of the chat window in the "Style" tab.
* Fix: Ensured the uninstall process is complete, removing all plugin options and data from the database for a clean removal.
* Under the Hood: Refactored the plugin's code to improve security, stability, and adherence to WordPress best practices.

= 1.5 =
* Upgraded: Introduced conversation history for a more intelligent and context-aware chatbot experience.

= 1.4 =
* Fixed: Fixed mobile chat window display Issues on different screen sizes.

= 1.3 =
* Fixed: Bug fix release: Various bugs and security fix.

= 1.2 =
* Fixed: Bug fix release: Security fix for message exporting.

= 1.1 =
* Fixed: Resolved an issue where checkbox settings for "Show Powered by NewCodeByte" and "Save Messages" could not be toggled off after being enabled.

= 1.0 =
*   Initial release of Chatbot AI Free Models.
    * Added basic chatbot functionality using OpenRouter.ai.
    *  Implemented settings page for configuration.
    *  Added options for customizing the chatbot's appearance.
    * Added message and IP saving functionality.
    * Added "Powered by NewCodeByte" attribution.

== Screenshots ==

1. The settings page for Chatbot AI Free Models. (assets/screenshot-1.png)
2. The chatbot in action on a website. (assets/screenshot-2.png)

== Donate link ==

You can support the development of Chatbot AI Free Models by making a donation via [https://www.buymeacoffee.com/codebytewp](https://www.buymeacoffee.com/codebytewp).

== License and Usage ==

Chatbot AI Free Models is provided free of charge for both personal and commercial use. You are allowed to distribute the plugin in its original, unmodified form.

This plugin is created and maintained by NewCodeByte.

== Author ==

NewCodeByte

== Disclaimer and Legal Information ==

This plugin is provided "as is" and without any warranty, express or implied. NewCodeByte is not liable for any damages or losses arising from its use. While this plugin is provided free of charge for personal or commercial use, the "Powered by NewCodeByte" link helps support its development. This plugin is licensed under the GPLv2 (or later) license, and you are free to use, modify, and distribute it according to the terms of that license.  You are solely responsible for ensuring that your use of this plugin complies with all applicable laws and regulations.

== Privacy ==

This plugin handles user data in the following ways:

1. Chat Messages
- Messages are stored only when explicitly enabled by the site administrator
- Messages are stored in a dedicated, secure database
- Messages can be exported or deleted through the admin interface
- No message content is shared with third parties except OpenRouter for processing

2. User Data Collection
- IP addresses (when message saving is enabled)
- Chat message content
- No personal identification information is collected
- No cookies are used by the plugin itself

3. Data Retention
- Messages and IPs are stored until manually deleted by the administrator
- No automatic data deletion is performed
- Administrators can delete all stored data at any time

4. GDPR Compliance
- Users should be informed about data collection
- Site administrators must update their privacy policy
- Data export and deletion tools are provided
- Clear process for handling data subject requests

== Contact ==

If you need support: <a href="https://newcodebyte.altervista.org">https://newcodebyte.altervista.org</a>