Install an AI agent on any website with one line of code
A single script tag installs the chat widget on a website, whatever tool runs it. Where to paste it, how to check it works, and what to do if nothing appears.
Widget and integration5 min read
For an agency, installation is often where a simple project gets complicated. The client’s site runs on a CMS you have never used, hosting access goes through another provider, and installing the smallest module takes three rounds of e-mails. An AI assistant that needs a heavy integration is unlikely to end up on many sites.
blabla.bot made the opposite choice: the widget installs with a single <script> tag, the same for every site. This article explains where to paste it, what it actually does, and how to check that everything works.
The line to paste
The embed code looks like this:
<script src="https://…/loader.js" data-bb-public-key="pk_…" async></script>
It carries two pieces of information:
- the script address, the same for every site;
- the site’s public key (
data-bb-public-key), which tells the widget which site, and therefore which agent, it belongs to.
The console gives you this code, ready to copy, with the right key. Paste it into the site’s pages, just before the closing </body> tag.
The async attribute tells the browser to download the script without holding up the page, then run it as soon as it is available. The site’s content renders as usual, even if the widget shows up a moment later.
What the line actually does
The script is deliberately small and depends on no library. It works in three stages.
- It shows the chat button, bottom right or bottom left depending on the setting. The button is isolated from the rest of the page (using what is called a Shadow DOM): the site’s styles do not distort it, and its own styles do not leak into the site.
- It opens the session on the first click. The chat window is only created when the visitor clicks, inside an iframe, a frame kept separate from the page. A visitor who never opens the chat starts no conversation.
- It checks the site address. The server compares the page’s address with the list of addresses allowed for that site. If it does not match exactly, the widget does not open.
That last point deserves a word. The public key is not a secret: by definition it is visible in the page’s code. The protection comes from the list of allowed addresses, which stops another site from copying your code and using the agent at your expense.
Where to paste the code
The principle never changes: find the place where the tool lets you add custom code to every page.
| Kind of site | Where to look |
|---|---|
| Custom-built site | The shared page template (footer, layout) |
| CMS with a theme | The theme settings, or a “custom code” area in the footer |
| Online site builder | The site settings, under custom code or integrations |
| Tag manager | A custom HTML tag fired on all pages |
Exact names vary from one tool to another and between versions. When in doubt, the tool’s documentation, under “add a script”, explains the steps. Dedicated extensions for some CMSs are among the ideas being considered, with no date: today the script tag is the way to install.
Check the installation in five steps
- Publish the page and open it in a private browsing window, to avoid the cache.
- Look for the button at the bottom of the screen, on the side set in the appearance settings.
- Click it: the window should open with the welcome message, if there is one.
- Ask a question whose answer you know is on the site, and check that the sources shown are the right ones.
- Test on mobile: the window must stay usable on a small screen.
If nothing appears
In the vast majority of cases, the cause is one of the following.
The address does not match. The check is exact: https://www.example.com and https://example.com are two different addresses, and so are http and https. Make sure the address the site is really served on is the one allowed for that site. The console shows it at installation time.
The code is not on the page. Some tools only inject code on some pages, or only after publishing. View the page source and search for data-bb-public-key.
A security policy blocks the script. If the site declares a content security policy (the Content-Security-Policy header), it must allow the script’s address in the script-src directive and the chat window’s address in frame-src. This is common on well-secured sites, and it is good news: you only need to add those two addresses.
The account is out of credits, or the site has reached its budget. In that case the widget opens, but when it is time to answer it says the assistant is taking a break, with no detail for the visitor, and may offer to leave a message for the team. The status shows up in your portfolio.
What installation does not lock in
You install once. After that, you change the agent from the console without touching the site:
- knowledge (adding or re-indexing pages and PDFs);
- behaviour (mission, tone, forbidden topics);
- appearance (colour, logo, position, welcome message, suggested questions);
- the AI option.
For appearance, visitors see the changes the next time they open the widget. That is a strong point with a client: you do not need new access to their site to improve their assistant.
A small extra for visitors
Once a conversation starts, the widget keeps it in the visitor’s browser, from page to page and after a reload. If that storage is blocked, for instance in strict private browsing, the widget works the same way, just without memory between pages.
In short
One line, pasted before </body>, installs the agent on a site, whatever tool runs it. The script is light, isolated from the page, and only opens on allowed addresses. If nothing appears, check the exact site address first, then that the code is present, then any security policy.
More questions about integration? The FAQ gathers the most common answers.
Sources
- WHATWG, HTML Living Standard, the script element’s
asyncattribute: https://html.spec.whatwg.org/multipage/scripting.html#attr-script-async - W3C, Content Security Policy Level 3: https://www.w3.org/TR/CSP3/
Tags
- widget
- integration
- script
- CMS
On the site
Read next
Widget and integration
Customise a chat widget's look without giving up accessibility
Brand colour, logo, position: how to dress a chat widget in a client's colours while keeping a contrast that every visitor can read, on desktop and on mobile.
· 5 min read
The product
Testing an AI agent before launch: the simulator and a method
How to test an AI agent before installing it: a simulator that reproduces the widget, an explanation panel, and a question set that covers the difficult cases.
· 5 min read
Agencies and white label
Managing all your clients' sites from a single console
Clients, sites, agents, statuses, consumption and budgets: how the blabla.bot console organises a multi-client portfolio, plus a weekly follow-up routine.
· 5 min read