=== FrontDesk Chat ===
Contributors: frontdeskchatapp
Tags: booking, appointment booking, scheduling, calendar, chat
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Add your FrontDesk booking page to WordPress: inline, as a popup link or button, or a floating button. Loads only after visitor consent.

== Description ==

FrontDesk Chat is an AI front desk that answers visitor questions and books appointments. This plugin puts your FrontDesk booking page on your WordPress site:

* **Inline booking page.** Place it anywhere with the `[frontdeskchat]` shortcode or the "FrontDesk Chat" block.
* **Text link or button.** The booking page opens in an overlay when a visitor clicks.
* **Floating booking button.** An optional button on every page. It is off by default.
* **Chat.** You can show your chat page the same way, or choose the chat bubble as the floating button.

**An account is required.** You create your desk at [frontdeskchat.com](https://frontdeskchat.com). The plugin itself is free.

**Nothing loads until the visitor consents.** The plugin only prints empty placeholders and a small script. It contacts FrontDesk Chat after your consent manager tells it the visitor agreed. Until then there are no requests to FrontDesk Chat, no FrontDesk Chat scripts and no FrontDesk Chat browser storage. See "Visitor consent" below.

== Installation ==

1. Install the plugin from Plugins > Add New, or upload it to `/wp-content/plugins/frontdeskchat`, then activate it.
2. Go to Settings > FrontDesk Chat and paste your desk id. You find it at the end of your booking link (`https://frontdeskchat.com/book/<desk id>`), or as the `data-desk` value under Share > Embed bot in your FrontDesk Chat dashboard.
3. Optional: choose a Floating button (the booking button, or the chat bubble) and set its text, colors and position.
4. Add the consent line described below, so everything appears for visitors who agree.

== Visitor consent ==

Add this line where your cookie or consent manager runs after a visitor accepts:

`window.fdchatConsentGranted = true; document.dispatchEvent( new Event( 'fdchat_consent_granted' ) );`

If the flag is already set when the page loads (a returning visitor), everything loads straight away.

== Usage ==

Turn on quick booking for your desk in the FrontDesk Chat dashboard first. Then add a shortcode to any page or post.

Inline booking page:

`[frontdeskchat]`

Text link that opens the booking page:

`[frontdeskchat display="text" text="Book a call"]`

Button (text and colors are optional):

`[frontdeskchat display="button" text="Book now" color="#16a34a" text_color="#ffffff"]`

These use the desk id from Settings. To use another desk, add `desk="..."`.

Chat page: copy the page link from Share > Link in your dashboard.

`[frontdeskchat view="chat" url="https://frontdeskchat.com/handle/slug"]`

`display` works for the chat page too ("inline", "text" or "button"). The same options are in the block editor: add the "FrontDesk Chat" block.

== Frequently Asked Questions ==

= Why does nothing show on my site? =

Check these in order: the consent line runs after a visitor accepts; for a booking shortcode, a desk id is saved in Settings (or the shortcode has `desk="..."`) and quick booking is on for the desk; for a chat page shortcode, `url` is a valid chat page link; for the floating button, a desk id is saved and Floating button is not set to Off. If no consent signal arrives, nothing loads by design.

= Does it work with my cookie plugin? =

The plugin does not read the WordPress Consent API, so a consent plugin does nothing until you add the consent line above to it.

= What if a visitor withdraws consent? =

Withdrawal is not handled while the page is open. Scripts that already loaded stay until the next page load.

== External services ==

This plugin connects your visitors' browsers to the FrontDesk Chat service (https://frontdeskchat.com). Your WordPress server never contacts the service: the plugin's PHP makes no requests.

**What it loads, and when.** Only after the visitor consents:

* `https://cdn.frontdeskchat.com` serves two scripts. `embed.js` draws the booking and chat pages, the text link, the button and the floating booking button; it loads when a shortcode or block is on the page, or when the floating booking button is on. `widget.js` is the chat bubble; it loads only when Floating button is set to Chat bubble.
* `https://frontdeskchat.com` serves the booking page (`/book/<desk id>`) and the chat page (`/<handle>/<slug>`), shown in iframes.
* `https://app.frontdeskchat.com` serves the chat window (`/embed/chat`), shown in an iframe, only when the chat bubble is on.

**What is sent to the service.** Standard request data (IP address, browser details, referrer) and the desk id. The booking page submits what the visitor enters: name, email, answers to your questions, the chosen date and time and their time zone, plus a Cloudflare Turnstile check token. The chat sends the visitor's messages and time zone. The chat bubble also sends the address and host of the page the visitor is on, when the page changes. The service stores a hash of the IP address with a chat conversation.

**What is stored in the visitor's browser.**

* `embed.js` stores nothing and sets no cookies.
* On your site, the chat bubble script stores `localStorage` keys `fdc:open:<desk id>` (whether the chat is open), `fdc:teaser:<desk id>` (whether the greeting was dismissed) and `fdc:session:<desk id>` (the conversation session token). It sets no cookies.
* FrontDesk's own app runs inside the iframes, on its own origins (`frontdeskchat.com` and `app.frontdeskchat.com`). There it stores a `localStorage` key `fdc-auth` (an empty sign-in state for visitors). The chat window also stores `fd_visitor:<desk id>` (a random visitor id created on the first chat and sent to the service when a chat starts) and `fd_csat_<desk id>` (whether the satisfaction survey was answered).

**Other services used inside FrontDesk Chat pages.** An anti-abuse check from Cloudflare Turnstile (`challenges.cloudflare.com`) runs in the chat and booking pages. FrontDesk Chat pages also send a Cloudflare web analytics beacon (a request to `/cdn-cgi/rum`) and may send error reports; see the privacy policy.

Terms of service: https://frontdeskchat.com/policy/terms/
Privacy policy: https://frontdeskchat.com/policy/privacy/

== Changelog ==

= 1.0.0 =
* Initial release.
