=== iChatAssist ===
Contributors: fareeddaar
Tags: chatbot, chat, ai chatbot, lead generation, live chat
Requires at least: 7.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A chat assistant that answers visitor questions, walks them through a short enquiry and saves every lead to your dashboard. AI answers are optional.

== Description ==

iChatAssist adds a chat bubble to your site that turns visitors' questions into leads you can follow up.

* **Works without AI.** A guided enquiry asks for the service, budget and timeline, then a short description and the visitor's contact details. Quick answers you write yourself ("hours, open | We are open Monday to Friday...") reply to common questions instantly.
* **Optional AI answers.** iChatAssist uses the AI Client built into WordPress, so it works with whichever AI provider you connect in Settings → Connectors. The plugin never asks for or stores API keys. With a provider connected, the assistant answers any typed question. It only uses facts from your site: what you write about your business, your pricing, your quick answers and, if you allow it, your published pages. When a visitor is ready to talk, it shows the contact form. If the AI is unavailable, the quick answers take over.
* **Leads are never lost.** Every enquiry, with the full chat conversation, is saved under iChatAssist → Leads before any email is sent. You also get an email notification, and you can send visitors a copy.
* **WhatsApp button.** Add your number to let visitors continue the conversation on WhatsApp.
* **Fits your site.** Light or dark style, your accent color, your avatar or site icon, bottom left or right, full screen on phones. It is keyboard accessible and respects reduced motion.
* **Open it from anywhere.** Any link to `#chat` opens the chat, for example a "Chat with us" item in your menu.
* **Privacy friendly.** No tracking and no third-party scripts. Visitor IP addresses are never stored; a short hash is kept for up to an hour to limit abuse. Leads work with the WordPress personal data export and erase tools.

== Installation ==

1. Upload the plugin through Plugins → Add New → Upload Plugin, or install it from the plugin directory, then activate it.
2. Go to iChatAssist → Settings. Describe your business, add your pricing and quick answers, and set the services, budgets and timelines for the guided enquiry.
3. Optional: for AI answers, connect an AI provider in Settings → Connectors, then tick "AI answers" in iChatAssist → Settings. AI answers are off by default.

== Frequently Asked Questions ==

= Do I need AI? =

No. AI answers are off by default, and the chat uses the guided enquiry and your quick answers. Turning AI on only adds AI replies to free-typed questions.

= How do I turn on AI answers? =

AI answers are off by default. Connect an AI provider (for example Anthropic, Google or OpenAI) in Settings → Connectors, then tick "AI answers" in iChatAssist → Settings and save. Nothing is sent to an AI provider until you do. You can switch AI answers off again at any time.

= Which model is used? =

The WordPress AI Client chooses a model from the provider you connected that supports text generation.

= How do I keep AI costs down? =

Replies are short (400 tokens at most), only the last 12 messages are sent, and each visitor can send 40 messages an hour. You can change these limits with the `ichatassist_max_tokens` and `ichatassist_rate_limit` filters.

= Can I hide the chat on some pages? =

Yes, with a filter: `add_filter( 'ichatassist_show', function ( $show ) { return ! is_page( 'checkout' ); } );`

= Can I add more facts for the AI? =

Use "Extra facts for the AI" in the settings, or the `ichatassist_knowledge` filter to add lines from code (for example, products from your shop).

= My site is behind Cloudflare or another proxy. =

Every visitor will appear to come from the proxy's IP, so they share one rate limit. Pass the real visitor IP using the header your proxy sets:
`add_filter( 'ichatassist_client_ip', function ( $ip ) { return isset( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) : $ip; } );`
Only do this when your server can be reached only through the proxy.

= Does it work with page caching? =

Yes. The chat loads the same for every visitor and talks to the site through the REST API, so cached pages work.

= What happens to my leads if I delete the plugin? =

They are kept, unless you tick "Delete settings and all saved leads when the plugin is deleted" in the settings first.

== External services ==

This plugin does not connect to any AI service itself. AI answers go through the WordPress AI Client (part of WordPress since 7.0), which sends them to the AI provider the site administrator connected in Settings → Connectors. That provider's terms and privacy policy apply. "AI answers" is off by default: nothing is sent to an AI provider until the site administrator turns it on in iChatAssist → Settings, and nothing is sent when no provider is connected.

What is sent and when: each time a visitor types a question in the chat, the site sends the last messages of that conversation (up to 12, each shortened to 1,200 characters) together with instructions and the site facts. These facts are the business name and tagline, the business description, pricing, services, quick answers and extra facts from the settings, and, if the "Site pages" option is on, the title, link and opening text of published pages. Contact details that visitors type into the lead form are not sent to the AI provider.

The optional WhatsApp button is a plain link to https://wa.me/. Nothing is sent to WhatsApp unless a visitor clicks it; their browser then opens WhatsApp with a prefilled message. WhatsApp terms: https://www.whatsapp.com/legal/terms-of-service Privacy policy: https://www.whatsapp.com/legal/privacy-policy

== Screenshots ==

1. The chat button and teaser bubble on your site.
2. The chat opens with your greeting, a guided enquiry button and quick questions.
3. An AI answer built from your own pricing, with buttons to share details or chat on WhatsApp.
4. The guided enquiry asks for the service, budget and timeline in a few taps.
5. The lead form collects the visitor's name, email and website.
6. The visitor gets a confirmation, and the lead is saved to your dashboard.
7. The dark style.

== Changelog ==

= 1.0.1 =
* AI answers are now off by default and must be turned on in the settings.

= 1.0.0 =
* First release.
