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
- 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.
The code you copy looks like this. YOUR_EMBED_KEY stands for your agent's own key, which the copied code already contains:
<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>- 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. - 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.comorhttps://*.example.com, then select Save domains. While the list is empty, the bubble works on any site.Limit the agent to your own domains. - Test the integration
Open your website and look for the Chat bubble in the corner. Click it and send a message.
- 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.qwryaistraight after the snippet.// 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
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
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
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
Best Practices
Performance Optimization
<!-- 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
- Check that you pasted the whole snippet, unchanged, on the page.
- Make sure the Chat bubble's Visibility toggle is on, in the Overview tab.
- If Specific domains is on, check that your site's address is in the list.
- Open your browser's developer console and look for errors.
- Try a private window: caching plugins and ad blockers can hide the bubble.
Events Not Firing
window.chatbotexists only after the widget script has loaded. Add listeners once it's there.- Check the event name's spelling and case, such as
messageReceived. - Use your browser's developer tools to check that the widget script loaded from
www.qwryai.com.