Skip to content
QwryAI
Documentation
Pages

Website Integration

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

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.
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.

    Deploy › Website widget.

On the Website bubble sheet, select Copy under Widget setup.

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
<script>
(function(){if(!window.qwryai||window.qwryai("getState")!=="initialized"){window.qwryai=(...arguments)=>{if(!window.qwryai.q){window.qwryai.q=[]}window.qwryai.q.push(arguments)};window.qwryai=new Proxy(window.qwryai,{get(target,prop){if(prop==="q"){return target.q}return(...args)=>target(prop,...args)}})}const onLoad=function(){const script=document.createElement("script");script.src="https://www.qwryai.com/widget/script/YOUR_EMBED_KEY";document.body.appendChild(script)};if(document.readyState==="complete"){onLoad()}else{window.addEventListener("load",onLoad)}})();
</script>
  1. Add it to your website

    Paste the code just before the closing </body> 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.

  2. 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.

    Limit the agent to your own domains.
  3. Test the integration

    Open your website and look for the Chat bubble in the corner. Click it and send a message.

  4. 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

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 →

Best Practices

Performance Optimization

HTML
<!-- Paste the copied code here, just before </body> -->
<script>
  // Your QwryAI embed code: it loads after the page has finished loading
</script>
</body>

User Experience

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.
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.
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

Troubleshooting

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.
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?

Explore the documentation