Embed the widget
Add the AskAnyDocs widget with one script tag, then optionally pass user identity through `window.AskAnyDocsUser` so escalations and integrations include useful contact context.
Adding the AskAnyDocs widget to your website takes one script tag. Once it is live, visitors see a floating chat button that opens your AI documentation assistant without leaving the page.
Before you embed
Before placing the widget on a production website, confirm that:
- knowledge sources are indexed
- the bot answers common product or support questions
- widget name, color, avatar, starter question, and source-link settings are saved
- fallback or escalation behavior is configured if needed
- your website domain is listed as an allowed domain
- integrations are configured if escalations should create tickets, CRM records, notifications, or live chat handoffs
If you are embedding the widget inside a logged-in product, also decide whether to pass user data to the widget. That makes escalations more useful because support tools can receive the user's email, name, or account ID.
Embed in three steps
1. Open your bot's Widget settings
In the dashboard, go to your bot and open the Widget tab. Customize the color, avatar, button icon, button position, button text, initial message, source links, branding, and fallback link.
2. Copy the embed snippet
The Widget tab shows a ready-to-use <script> tag with your bot ID already filled in. Copy the snippet from the dashboard so you always use the current bot ID.
3. Paste it before </body>
Add the snippet to every page where you want the widget to appear. The defer attribute prevents the script from blocking page load.
<script src="https://app.askanydocs.com/widget/BOT_ID.js" defer></script>
Pass logged-in user data
If your website or SaaS product knows who the current user is, define window.AskAnyDocsUser before loading the widget script.
<script>
window.AskAnyDocsUser = {
id: "acct_12345",
email: "alex@example.com",
name: "Alex Morgan",
phone: "+15551234567"
};
</script>
<script src="https://app.askanydocs.com/widget/BOT_ID.js" defer></script>
Supported user fields are:
| Field | Description |
|---|---|
id |
Your internal user, account, or customer ID |
email |
User email address |
name |
User display name |
phone |
User phone number |
The widget also records page and browser context such as current page URL, referrer, language, timezone, screen size, viewport size, IP-derived country code, and user agent. User fields are attached to the conversation metadata and can be used by escalation integrations.
When user data is required for escalation
Webhook, notification, helpdesk, CRM, and live chat integrations are most useful when the conversation includes a user email or identity. AskAnyDocs can ask the visitor for an email during escalation if it does not already have one, but logged-in products should pass known user data up front.
For example:
- Helpdesk integrations can create a ticket for the correct customer.
- CRM integrations can create or update a contact/person.
- Slack, Telegram, Discord, Teams, or email notifications can include the user's contact details.
- Live chat handoff can identify the visitor in the connected chat provider.
Read Integrations and escalation for the supported providers.
Allowed domains
The widget only works on origins you explicitly approve. This prevents your bot from being embedded on sites you do not control.
Configure allowed domains in bot settings before going live. If a request comes from an unlisted origin, the chat returns 403 and the widget stays hidden.
Source links
If source links are enabled in widget settings, AskAnyDocs can return links to relevant source pages when the selected knowledge chunks are strong enough. This helps visitors continue reading the original documentation after receiving a short answer.
Source links are most useful for website, sitemap, URL list, Google Drive, Notion, and other sources that have clear URLs. For uploaded files, link behavior depends on the source metadata available after ingestion.
Testing after installation
After embedding the snippet, open the page in a browser and check:
- the floating button appears
- the widget opens and closes normally
- the starter message is visible
- the first answer is relevant
- source links appear when expected
- user data is present in escalations if you pass
window.AskAnyDocsUser - the widget works on desktop and mobile
- the browser console has no blocked-domain or script errors
Test from the final production domain, not only from a local development URL. Domain restrictions can behave differently across environments.
Common embed issues
If the widget does not appear, check the allowed domain, script URL, browser console, and whether the snippet is loaded on the current page template. If the widget appears but answers poorly, review indexed sources rather than the embed code.
Related articles
Getting started
Start here if you are setting up AskAnyDocs for the first time. This guide explains the complete workflow: creating a bot, adding knowledge sources, checking indexing quality, configuring the widget, and preparing your assistant for a live website.
Create your first bot
The bot creation wizard guides you from basic company information to resources and preview settings. This article explains what each step does and how to make choices that improve answer quality.
Add website, documents, videos, and cloud sources
AskAnyDocs can index website pages, sitemap URLs, exact URL lists, uploaded files, YouTube transcripts, Google Drive files, Notion pages, and manual Q&A pairs. This guide explains when to use each source and which file formats are supported.