# Chat Bubble Installation > Embed your QwryAI agent in your website or web app with one script, then control it from JavaScript The Chat bubble is the quickest way to put your agent on a website. One script adds a round button to the corner of every page; visitors click it to open the chat. The same script gives your code a JavaScript API, `window.qwryai`, for signing users in, opening the chat from your own buttons and reacting to messages. ## What You Can Do > [accordion] Basic Integration > > * **Simple embed:** add the Chat bubble to your site by pasting one snippet. > * **Identity verification:** tell the agent which signed-in user it's talking to, so it can personalize answers and run Actions for that user. > * **Widget control:** open, close and toggle the chat from your own buttons, or hide the floating button. > [accordion] Advanced Features > > * **Event listeners:** react when the chat opens, a visitor sends a message or the agent replies. > * **Actions:** run your own browser code and show your own forms inside the chat. > * **Welcome popup:** show the initial messages above the bubble after a delay. ## Quick Start Guide **1. Get your embed script** In your agent, open **Channels**, select **Manage** on the **Chat bubble** card, then open **Deploy** in the top-right corner and choose **Website widget**. ![The Deploy menu open under DEPLOY ON, listing Website widget, Website iframe, Shopify and WordPress.](annotated/01-deploy-menu.webp "Deploy › Website widget.") On the **Website bubble** sheet, select **Copy** under **Widget setup**. ![The Website bubble sheet with Send instructions via email, Copy prompt, the Specific domains toggle, and the Widget setup embed code with a Copy button.](annotated/02-widget-setup.webp "Copy the code under Widget setup.") The code you copy looks like this. `YOUR_EMBED_KEY` stands for your agent's own key, which the copied code already contains: ```html ``` > [!TIP] > > Not the one installing it? **Send instructions via email** sends the code and setup steps to a teammate, and **Copy prompt** copies instructions you can paste into an AI coding tool. **2. Add it to your website** Paste the code just before the closing `` tag on every page that should show the bubble. A shared layout or template is the best place. In a site builder, use its custom code or footer scripts setting. > [!TIP] > > The code waits until your page has finished loading before it fetches the chat, so it never slows your page down, wherever you paste it. **3. Allow your domains (optional)** Turn on **Specific domains** to let only your own sites load the agent. Enter each domain on its own line, such as `https://example.com` or `https://*.example.com`, then select **Save domains**. While the list is empty, the bubble works on any site. ![The Specific domains toggle with its description Only allow embedding the agent on specific domains, the Allowed domains box and the hint Enter each domain in a new line.](annotated/03-specific-domains.webp "Limit the agent to your own domains.") **4. Test the integration** Open your website and look for the Chat bubble in the corner. Click it and send a message. > [!TIP] > > Your agent answers from its data sources. If it doesn't show up, see [Troubleshooting](#troubleshooting). **5. Add advanced features (optional)** Use the API to sign users in, listen for events or control the chat. Calls made before the script has loaded wait in a queue and run once it's ready, so you can call `window.qwryai` straight after the snippet. ```javascript // Open the chat from your own "Help" button document.getElementById("help-button").addEventListener("click", () => { window.qwryai("open"); }); // Listen for the agent's replies once the bubble has loaded window.addEventListener("load", () => { const listen = () => window.chatbot ? window.chatbot.on("messageReceived", (message) => console.log("Agent said:", message.content)) : setTimeout(listen, 200); listen(); }); ``` ## JavaScript Embed Core Features > [tab] Identity Verification > > **Recognize signed-in users securely** > > Use it in apps and stores with user accounts to: > > * Tell the agent who it's talking to (name, email, user ID) > * Keep each user's conversations with their contact record > * Give client-side Actions the signed-in user's ID > > [Identity Verification Guide →](/docs/developer-guides/website-integration/identity-verification) > [tab] Event Listeners > > **React to chat events as they happen** > > Listen for: > > * Messages the visitor sends and replies the agent gives > * The chat opening and closing > * Client-side Action calls and results > > [Event Listeners Guide →](/docs/developer-guides/website-integration/chatbot-event-listeners) > [tab] Widget Control > > **Control the chat from your own code** > > * Open, close or toggle the chat > * Hide the floating button and use your own > * Send a message for the visitor or start a new chat > > [Widget Control Guide →](/docs/developer-guides/website-integration/chat-interface-control) > [tab] Client-Side Custom Actions > > **Run your own code from the conversation** > > * Actions that call your page's code and your backend > * Forms that collect structured details inside the chat > > [Client-Side Custom Actions Guide →](/docs/developer-guides/website-integration/client-side-custom-actions) > > [Client-Side Custom Forms Guide →](/docs/developer-guides/website-integration/client-side-custom-forms) ## Best Practices ### Performance Optimization > [!TIP] > > **The embed script never blocks your page.** It waits for the page's `load` event, then adds the widget script. You don't need `async` or `defer`. ```html ``` ### User Experience > [accordion] Mobile Optimization > > * Test the bubble on real phones, not just a narrow desktop window. > * Check that it doesn't cover your mobile navigation or a sticky checkout button. > * Under **Display › Content**, **Use different message for mobile** gives phones a shorter initial message, and **Show auto pop-up on mobile** decides whether the welcome popup appears there. > [accordion] Accessibility > > * Keep enough contrast between your accent color and its text when you change the **Style** settings. > * If you hide the floating button, make sure your own button can be reached with the keyboard and has a clear label. > [accordion] Context Awareness > > * Sign users in with identity verification so the agent knows who they are. > * Call `window.qwryai("startNewChat")` when a fresh conversation makes sense, such as after checkout. > * Call `window.qwryai("logout")` when the user signs out, so the next person on the device starts fresh. ### Security Considerations > [!WARNING] > > **Never put secrets or private data in your page's JavaScript.** Anyone can read it. Sign users in with a server-signed token through [identity verification](/docs/developer-guides/website-integration/identity-verification) instead of passing raw user details. ## Troubleshooting > [accordion] Widget Not Appearing > > 1. Check that you pasted the whole snippet, unchanged, on the page. > 2. Make sure the Chat bubble's **Visibility** toggle is on, in the **Overview** tab. > 3. If **Specific domains** is on, check that your site's address is in the list. > 4. Open your browser's developer console and look for errors. > 5. Try a private window: caching plugins and ad blockers can hide the bubble. > [accordion] Events Not Firing > > 1. `window.chatbot` exists only after the widget script has loaded. Add listeners once it's there. > 2. Check the event name's spelling and case, such as `messageReceived`. > 3. Use your browser's developer tools to check that the widget script loaded from `www.qwryai.com`. ## What's Next? > [card] Identity Verification | /docs/developer-guides/website-integration/identity-verification | Recognize signed-in users securely. > [card] REST API Integration | /docs/developer-guides/api-integration | Talk to your agent from your own backend. > [card] Client-Side Custom Actions | /docs/developer-guides/website-integration/client-side-custom-actions | Run your page's code from the conversation. > [card] Client-Side Custom Forms | /docs/developer-guides/website-integration/client-side-custom-forms | Show your own forms inside the chat.