=== DadsFam Live Chat ===
Contributors: dadsfam
Tags: live chat, chatbot, help desk, customer support, woocommerce
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 3.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Free live chat and help centre with a built-in AI assistant that runs on your own server, answers from your site and learns from your team.

== Description ==

DadsFam Live Chat puts a modern chat window on your site, gives your team a proper Inbox to answer from, and adds a help centre — with an AI assistant built in that looks after visitors whenever nobody is around.

Everything runs on your own WordPress site. There is no account to create, no cloud service, no API key and no monthly fee. Conversations are stored only in your own database, and nothing is sent to an outside service.

= The built-in AI assistant =

The assistant runs entirely inside your WordPress, on your own server. It does not use OpenAI, ChatGPT, Claude or any other outside service, there is no API key, and nothing about your visitors or their conversations leaves your site. It costs nothing to run.

* **It reads your site.** Pages, posts, products and help articles — you choose which. It keeps up by itself whenever you save a change.
* **It understands questions however they are typed.** Spelling mistakes are corrected against the words your own site uses, words are matched by their roots ("delivered", "delivery", "deliveries"; "bit" and "bitten"), and it knows everyday words that mean the same thing (courier and delivery, kids and children, Amex and American Express). Chat spelling and South African English are fine too: "hoe much 4 a big dog per nite", "can I fetch my dogs on Sunday?".
* **It works things out instead of just matching words.** "If I cancel 10 days before, do I get my money back?" finds your rule for 7 to 14 days. "We'll only get there at 11pm" finds what you say about arriving after 20:00. "My clutch is slipping. How long will you need the car?" finds the clutch row of a long price table and answers with just that row. "What's your cheapest room?" compares the prices in your table.
* **It answers with the exact sentences that matter,** not a whole page, and adds a link to read more. Ask two things at once ("What time is check-in? Is breakfast included?") and it answers both.
* **It never guesses.** When it is not sure, it says so, offers a person, or takes the visitor's email for your team. You choose how sure it must be.
* **WooCommerce aware.** It answers "do you have…" and "anything under R500?" with product cards showing live prices and stock, and checks order status safely: the order number and the email address it was placed with must both match.
* **It knows the basics** — your opening hours (including "are you open on Saturday?"), phone, email and address, even if they are only written on your pages — and hands over to a person whenever a visitor asks, or seems unhappy.
* **It learns.** Questions it could not answer are collected for you to answer once. Answers your team gives in chats are picked up for your approval (or straight away once two chats get the same answer). Visitors' 👍 and 👎 push good answers up and poor ones down, and it works out new word links by itself from what visitors found helpful.
* **It shows its working.** The AI Assistant screen has a test chat that shows how it understood a question, what it found and how sure it was.

How it works, for the curious: questions are broken into word roots, corrected, and expanded with related words; every passage of your site is ranked the way search engines rank pages, with extra weight where the words asked appear together and where amounts, times and dates fit; and the best-matching sentences are picked out to form the answer. It is not a large language model, so it cannot make things up — every answer comes from your own site or from what you taught it.

You decide when it talks: only when your team is away (the default), first on every chat with people on request, or never — just suggesting replies to your team.

= Live chat your visitors will like =

* A clean chat window that matches your brand colour, in light or dark, on desktop and phone.
* Home, Messages and Help tabs: a greeting, who is online, instant answers from your help articles and the conversation itself.
* Quick-reply buttons, "Seen" receipts, typing indicators, emoji, ratings, transcripts by email and a leave-a-message form when nobody is around.
* Chats carry on across pages and tabs, and survive a dropped connection.
* It costs nothing until it is used: the chat bubble loads without a single request to your server.
* Draws itself in its own sealed-off area, so your theme's styles cannot break it — and it cannot break your theme.

= An Inbox your team will actually enjoy =

* Waiting, My chats, All live chats, With your AI, Messages and History.
* Reply suggestions from your saved answers, your site and your saved replies, right above the reply box.
* Type / for saved replies. Private notes inside the conversation. Transfers, tags and keyboard shortcuts.
* The visitor's details beside the chat: the page they are on, the pages they visited, their device, their earlier chats and their WooCommerce orders.
* Take over from the AI assistant at any time, and teach it with one click from any reply you send.
* Sound and desktop alerts, dark mode, and it works properly on a phone.
* A "Chat Agent" role for staff who should answer chats without being able to edit your site.

= A help centre =

* A help centre at an address you choose (yourdomain.com/help/ by default): a search box that answers as people type, your topics, the most helpful articles and every article, laid out to suit your theme.
* Put the same help centre on any page with the "Help Centre" block or the `[dadsfam_help_center]` shortcode.
* "Was this helpful?" on every article, related articles, and the same articles inside the chat window.
* A "Chat Button" block and `[dadsfam_chat_button]` shortcode. Any link to `#chat` opens the chat too.

= It looks after itself =

* An hourly check repairs missing database tables, sets forgotten "online" team members to away, tidies stuck chats and keeps the assistant's knowledge fresh.
* If a security plugin or your host blocks the WordPress REST API, the chat switches to a backup connection by itself.
* The Health screen checks everything in plain English and fixes most problems with one click.

= Safe and private =

* Bots are stopped with signed tickets, a hidden trap field and rate limits. Blocklists understand IP ranges (IPv4 and IPv6), email domains and words, and throwaway email addresses can be refused.
* Visitors' IP addresses cannot be faked to get around a block, and you can shorten or not store IP addresses at all.
* Finished chats can be deleted automatically after the number of days you choose.
* Works with WordPress's own Export and Erase Personal Data tools and suggests privacy-policy wording.
* Works alongside DadsFam AntiSpam when it is installed, so its blocklists and checks apply to chats too.

= For developers =

* AI tools connected to WordPress through the Abilities API (WordPress 6.9 and later) can read and answer chats, check health and teach the assistant.
* Open the chat from your own code with `DadsFamLiveChat.open()`.
* Filter where the widget shows with `dadsfam_live_chat_show_widget`.

= A word about PRO =

Right, let me be straight with you, because I hate being sold to as much as you do.

There is no PRO version of Live Chat. Everything above is free and it stays free. The AI assistant, the Inbox, the help centre, the WooCommerce product answers and order checks, saved replies, transcripts and the rest are not premium features, and if I put them behind a paywall I would be taking the mickey. No trial, no locked buttons, no "upgrade to unlock" anywhere.

I am a dad in Cape Town, and I built this because my own shops needed a chat that did not cost a fortune every month or send my customers' conversations to somebody else's server. That is the honest reason. Not "unlock your potential", not "supercharge your workflow".

So if it does everything you need, brilliant. Genuinely. Use it, and I hope it saves you a few late-night messages. The rest of what I build is at plugins.dadsfam.co.za.

Either way, thanks for using something I built. — Zak, DadsFam

== Installation ==

1. In WordPress, go to Plugins → Add New, search for "DadsFam Live Chat", then Install and Activate. (Or upload the ZIP under Plugins → Add New → Upload Plugin.)
2. Open **Live Chat** in the admin menu. The chat bubble is already live on your site.
3. Open the **Inbox** and switch yourself **Online** to take chats.
4. Under **Live Chat → AI Assistant**, tell the assistant about your business and try it out. It has already started reading your site.
5. Make it yours under **Live Chat → Settings** — brand colour, greeting, opening hours and email alerts.

== Frequently Asked Questions ==

= Does the AI assistant send my data to OpenAI, ChatGPT or anyone else? =

No. The assistant runs inside your own WordPress. It reads your own pages, products and help articles, understands questions with a language engine built into the plugin, and does all its work on your own server. There is no outside AI service, no API key and no fee.

= How do I switch the AI assistant off? =

Untick "Switch the AI assistant on" under Live Chat → AI Assistant. To keep it off whatever the settings say, add `define( 'DADSFAM_LIVE_CHAT_AI_OFF', true );` to wp-config.php. Live chat, the Inbox and the help centre carry on exactly as before.

= Is it a real AI? =

It is a language-understanding and search engine built for one job: answering questions from your own content. It corrects spelling, understands word forms and related words, ranks every passage of your site and picks out the sentences that answer the question — and it learns from your team and your visitors. It is not a large language model, which is exactly why it never invents answers.

= What does it do when it doesn't know? =

It says so honestly. If someone from your team is online it offers to bring them in; if not, it takes the visitor's email so you can reply, and adds the question to Knowledge → To teach so you can answer it once for good.

= Do I need WooCommerce? =

No. With WooCommerce active the assistant also answers product questions with live prices and stock, and checks order status, and the Inbox shows each visitor's orders.

= Will it slow my site down? =

No. The chat script loads after your page has finished, and the bubble is drawn without asking your server anything. The server is only contacted once a visitor opens the chat or already has a conversation going.

= Does it work with caching plugins? =

Yes. The chat talks to your site through its own connection that tells every page cache, CDN and browser never to cache it. If you change the chat's settings and do not see the change, clear your page cache once.

= My security plugin blocks the REST API. Will chat still work? =

Yes. If the REST API is blocked, the chat and the Inbox switch to a backup connection by themselves, and Health tells you it happened.

= Who can answer chats? =

Administrators, Editors and Shop Managers by default, plus anyone you give the "Chat Agent" role. Choose which roles under Settings → Availability.

= Can I change how the help centre looks? =

Yes. With a block theme, the help centre and its articles are templates you can edit like any other in Appearance → Editor → Templates ("Help centre" and "Help article"). With a classic theme, the help centre uses your theme's header and footer; add an `archive-dadsfam_help.php` template to your theme if you want to replace it. The help centre's colour follows the chat's brand colour.

= Can I put a chat button on a page? =

Yes. Use the "Chat Button" block, the `[dadsfam_chat_button text="Chat with us"]` shortcode, or link any text or button to `#chat`.

= What happens to my chats from version 2? =

They move across automatically when you update, along with your settings and saved replies. Version 2's leftover files are removed, and the old tables are only removed once every conversation is confirmed as moved.

= Email alerts are not arriving. =

Open Live Chat → Health and press "Send a test". If the test never arrives, your server cannot send email reliably — an SMTP plugin fixes that.

= What happens if I delete the plugin? =

Your chats, settings, help articles and everything the assistant learned are kept, in case you reinstall — unless you switch on "Delete everything when the plugin is deleted" under Settings → Privacy & data.

== Screenshots ==

1. The chat window on your site, with the AI assistant answering from your own pages.
2. Product questions answered with live prices and stock.
3. The team Inbox: the conversation, reply suggestions and the visitor's details and orders.
4. The Dashboard answers "is my chat working?" at a glance.
5. AI Assistant: when it talks, its personality, and a test chat that shows how it decided.
6. Knowledge: questions the assistant could not answer, ready to teach once.
7. Settings, with a live preview of the chat window.
8. Health: every check in plain English, with one-click fixes.
9. The help centre on your site, with instant answers as people type.

== External services ==

This plugin does not connect to any service of its own. It has no home-phoning, no analytics and no licence checks. The AI assistant, the chat and the help centre all run on your own WordPress site, and conversations are stored only in your own database.

Two things are worth knowing:

* The Health screen checks that chat can connect by making one request from your site to its own REST API address (a "loopback" request). It is sent to your own domain and nothing is sent anywhere else.
* Team members' pictures in the Inbox come from WordPress's own avatar setting, which uses Gravatar by default. You can change or switch this off under Settings → Discussion. The plugin itself sends nothing to Gravatar.

== Changelog ==

= 3.0.0 =
A complete rebuild.

* New: a built-in AI assistant that runs on your own server — no ChatGPT, no outside service, no fees. It reads your pages, products and help articles, understands questions however they are typed (spelling mistakes too), and answers with the exact sentences that matter, with a link to read more.
* New: the assistant answers product questions with live prices and stock, checks order status safely (order number and email must match), knows your opening hours and contact details, and hands over to a person when asked or when it is not sure. It never guesses.
* New: the assistant works things out rather than just matching words — amounts, times and dates in a question are checked against the rules on your pages ("10 days before" finds your "7 to 14 days" rule, "8 months ago" is inside a 12-month warranty, "9pm" is after hours), the row of a table a question names is found even in a long price list, a message that tells a story before it asks is read for its question, prices in your tables are compared for "cheapest" questions, and two questions in one message each get an answer.
* New: the assistant learns by itself. Questions it could not answer are collected for you to answer once; answers your team gives in chats are learned (after your OK, or straight away when the team gives the same answer twice); and visitors' 👍/👎 push good answers up and poor ones down.
* New: a brand-new Inbox with Waiting, My chats, All live chats, With your AI, Messages and History; reply suggestions; private notes inside the conversation; the visitor's pages, earlier chats and WooCommerce orders beside the chat; transfers, tags, keyboard shortcuts, dark mode, sound and desktop alerts. It works properly on phones.
* New: a new chat window for visitors with Home, Messages and Help tabs, help articles inside the chat, instant answers as they search, quick-reply buttons, "Seen" receipts, ratings, transcripts and a leave-a-message form. Your theme's styles can no longer break it, and it no longer slows pages down.
* New: a help centre — its own page at /help/ with instant answers as people type, help articles with topics, the same help centre on any page (block or shortcode), "Was this helpful?" votes and related articles.
* New: Dashboard, AI Assistant, Knowledge, Settings (with a live preview), Health and Help & Support screens, all in plain English.
* New: opening hours, going "away" automatically when you close the Inbox, a polite busy message, a "Chat Agent" role for staff, and a choice of which roles can answer chats.
* New: it looks after itself — an hourly check repairs missing tables, sets forgotten "online" people to away, tidies stuck chats and keeps the assistant's knowledge fresh. If a security plugin blocks the chat's connection, a backup connection takes over by itself.
* New: AI assistants you connect to WordPress (through the Abilities API in WordPress 6.9 and later) can read and answer chats, run health checks and teach the built-in assistant.
* Improved: safer — visitors' secret chat keys are stored scrambled, bots are stopped with signed tickets, IP addresses cannot be faked to dodge a block, and blocklists understand IPv6 ranges.
* Improved: privacy — works with WordPress's Export and Erase Personal Data tools, can shorten or skip IP addresses, deletes old chats automatically and suggests privacy-policy wording.
* Changed: the separate fast endpoint (chat-fast.php) is gone; chat now uses WordPress's own REST API with a built-in backup route.
* Updating: your chats, settings and saved replies from version 2 move across automatically, and the old files are cleaned up.

= 2.0.4 =
* Mobile polish: the iPhone keyboard no longer hides the message box, pop-ups no longer stack on top of each other, and buttons no longer stay highlighted after a tap.

= 2.0.3 =
* Fixed: the History button now works on phones.

= 2.0.2 =
* Fixed: the staff portal now works on iPhone.

= 2.0.1 =
* Fixed: the chat queue now works on a second device at the same time.

= 2.0.0 =
* First free release: faster, safer and fixed for mobile.

== Upgrade Notice ==

= 3.0.0 =
A complete rebuild with a built-in AI assistant, a new Inbox and a help centre. Your chats, settings and saved replies move across automatically.
