How to add an AI chatbot to a plain HTML website
Paste two script tags before </body> on every page and upload. Tested on a hand-coded site: placement, CSP headers, caching and phone checks.
To add an AI chatbot to a plain HTML website, paste the chatbot's script tags just before the closing </body> tag on every page, upload the files, then open the live site in a private window and ask the bot a question. On a static site generator, paste the tags once in the base layout instead of in every file.
Pasting takes two minutes. The trouble comes later: a page that never got the snippet, a host still serving the old HTML, a security header that blocks the script. We hit or tested each of those on a hand-coded site on 29 November 2026.
If your site runs on a builder, use the guide for it instead: WordPress or Webflow. This one is for sites that are just HTML files: hand-coded pages, sites exported from a design tool, and Eleventy, Hugo or Jekyll builds on GitHub Pages, Netlify or shared hosting.
We make Laddu Chat, so the snippet and the screenshots are ours. Placing the script before </body>, adding it to every page and testing on localhost work the same for most script-tag widgets. The CSP hosts, the config line and the console errors below are specific to Laddu Chat.
What do you need before you start?#
- Edit access to the HTML. A text editor and the files, or the repo your generator builds from.
- A way to publish. FTP, a
git pushthat triggers a deploy, or a drag-and-drop upload. - A bot with real sources. The widget only knows what you give it. Add your key pages first: home, services, prices, contact and FAQ, plus any PDFs your customers ask about. How website AI chatbots work explains why a bot with no sources makes things up.
- The snippet. No account yet? Create one free (details in the cost section below) and add your sources first. Then, in Laddu Chat, open the bot, go to Settings → Embed Scripts, check that Enable embedding on website is on, and click Copy Script. You get two tags:
<script>window.ladduConfig = { chatbotId: "<your-bot-id>" };</script>
<script src="https://chat.laddu-ai.com/embed.js" defer></script>
The first line tells the loader which bot to show. The second loads the widget.
Step 1: Where do you paste the chatbot embed code in HTML?#
Just before </body>, below your own content and scripts:
<footer>…</footer>
<!-- Chat widget -->
<script>window.ladduConfig = { chatbotId: "<your-bot-id>" };</script>
<script src="https://chat.laddu-ai.com/embed.js" defer></script>
</body>
</html>
Because embed.js has defer, the browser finishes parsing your HTML before the widget code runs, so the chatbot never holds up your page. We also pasted both tags inside <head> and the widget worked the same, because the loader has defer. MDN describes a deferred script as one that runs "after the document has been parsed". There's no reason to prefer <head> for a chat widget, though.
Two placement mistakes we reproduced:
- Loader above the config, without
defer. We put theembed.jstag first and removeddefer. The loader ran before the config line existed, and the console showedLaddu Chatbot: chatbotId is missing in window.ladduConfig. No launcher appeared. Withdeferleft on, either order worked, because a deferred script waits for the whole page. Paste the two lines exactly as copied and you avoid this. - Pasted twice. If a page already has the snippet in a shared include and you paste it again by hand, you only load extra code. Laddu Chat's loader checks whether it has already started and stops the second copy, but other vendors' loaders may not. Paste it once per page.
Don't put the tags inside another <script> block, and don't let an editor change the quotes to curly ones. If the snippet came through a chat app or email, paste it into a plain text editor first.
Step 2: How do you add the snippet to every page of a static site?#
The widget only appears on pages that contain the snippet. On our test site the home page had it and menu.html didn't. Clicking from one to the other made the launcher disappear, which looks like a bug to a visitor.
Hand-coded sites. Paste the snippet into every .html file. To find the files you missed, run this in the site folder:
grep -rL "chat.laddu-ai.com/embed.js" --include="*.html" .
It lists every HTML file that doesn't load the widget. Skip pages that don't need a chatbot, such as a thank-you page.
Static site generators. Paste the snippet once in the layout that every page shares, just before </body>:
| Generator | Usual file |
|---|---|
| Eleventy | the base layout in _includes/, e.g. _includes/base.njk |
| Hugo | layouts/_default/baseof.html |
| Jekyll | _layouts/default.html |
Rebuild and deploy, then check a page that uses a different layout, such as a blog post or a landing page. Pages with their own layout won't get the widget unless that layout has the snippet too.
HTML exported from a design tool. If you export the site again later, the export overwrites your edited files and the snippet disappears. Add pasting the snippet to your export checklist, or use the tool's own custom-code setting if it has one.
Step 3: How do you test the chatbot before and after you upload?#
Before upload. Serve the folder locally:
cd my-site
python3 -m http.server 8000
Then open http://localhost:8000 in your browser. We did this with Laddu's own site bot: the launcher appeared bottom right, the welcome message popped up about a second after the widget loaded, and the bot answered a test question. Opening index.html straight from disk (a file:// address) worked too. Each test answer uses one credit, the same as a visitor's.

The widget in our screenshots is Laddu's own site bot, which is why it introduces itself as Laddu's assistant. Yours shows your own welcome message and suggested questions.
After upload. Open the live site in a private window, so you don't see a copy your browser kept. Then:
- Check the launcher appears on the home page and on two or three other pages.
- Open it and ask something your sources answer, such as your opening hours or your main price.
- Ask something they don't cover. The bot should say it doesn't know. If it guesses instead, add a short text source that answers that exact question, then ask again.
- Open the browser console (F12 on Windows, Option+Command+J in Chrome on a Mac) and look for red errors that mention the chatbot.
Four questions catch most problems before a customer does: "What do you do?", "How much is [your main product]?", "Do you [something you don't offer]?" and "Can someone call me back?". The last one only works if you've turned on lead fields. The Webflow guide has an 8-question version with a fix for each failure.
Do you need to set allowed domains for the chatbot?#
Not with Laddu Chat. It has no allowed-domains list, so the widget loads on any page that carries the snippet, including localhost, www and non-www addresses, and preview hosts. The switch you control is Enable embedding on website in Settings → Embed Scripts: turn it off and the widget stops loading everywhere it's pasted. That's also why our localhost test worked with no setup.
Why doesn't the chatbot show after you upload the site?#
If the launcher doesn't appear after you publish, check these in order:
- You're looking at a cached copy. GitHub Pages served
pages.github.comwithcache-control: max-age=600when we checked on 29 November 2026, so a browser can show the old HTML for up to 10 minutes after a deploy. Use a private window or wait. If you put a CDN in front of your host and told it to cache HTML, purge its cache after you deploy. - The page doesn't have the snippet. Run the
grepcommand above against the files you uploaded, not your working copy. - The tags got damaged. View the page source (Ctrl+U, or Option+Command+U on a Mac) and search for
embed.js. Both tags should be there, complete, in the copied order. - Embedding is off. Check Enable embedding on website in Settings → Embed Scripts.
- A security header blocks it. If the console shows "violates the following Content Security Policy directive", see the next section.
Does a Content Security Policy block the chatbot?#
Yes, if the site sends one that doesn't allow the widget. A Content Security Policy (CSP) is a header, or a <meta http-equiv="Content-Security-Policy"> tag, that lists where scripts, frames and connections may come from. Hand-coded sites often add one after a security scan.
We tested three policies on our page:
| Policy | Result |
|---|---|
default-src 'self' only | Blocked. The console showed the inline config line and embed.js both refused. No launcher |
| Widget hosts allowed, config line still inline | Blocked. chatbotId is missing in window.ladduConfig. No launcher |
| Widget hosts allowed, config line moved to a file on our own domain | Worked: launcher, chat window and answers |
The second row is the one to watch. The Laddu Chat hosts are only half of the fix. The first snippet line is an inline script, and MDN notes that blocking inline scripts is one of the main things a CSP is for. So a policy that allows chat.laddu-ai.com but nothing inline still stops the widget.
The cleanest fix is to move the config line into its own file on your site. Create /laddu-config.js containing:
window.ladduConfig = { chatbotId: "<your-bot-id>" };
Then replace the first snippet line on each page with:
<script src="/laddu-config.js"></script>
<script src="https://chat.laddu-ai.com/embed.js" defer></script>
Leave defer off the config file. Then send a policy that includes these directives, alongside whatever your site already needs:
Content-Security-Policy: default-src 'self'; script-src 'self' https://chat.laddu-ai.com; connect-src 'self' https://chat-api.laddu-ai.com; frame-src https://chat.laddu-ai.com; style-src 'self' 'unsafe-inline'
style-src 'unsafe-inline' is there because the loader adds the launcher's styles inline. The loader fetches no fonts, images or other hosts, so those directives plus the config line are the whole list. The chat window itself runs in an iframe served from chat.laddu-ai.com, so your policy doesn't apply inside it. If you'd rather keep the config line inline, add its SHA-256 hash or a nonce to script-src instead. We tested the hash and it worked, but you have to recompute it if the line changes.
How do you check the chatbot on a phone?#
At 768 px wide or less, the chat window opens full screen and the launcher hides while it's open. Visitors close it with the minimise button at the top right of the chat header. We checked this at 390 px, an iPhone-sized viewport:

Three things to check on a real phone after you publish:
- What's in the bottom-right corner. The launcher is a 60 px circle, 20 px from the bottom and right edges, and you can't move it. A cookie banner, a "Call us" button or a back-to-top arrow in that corner will overlap it. Move your element.
- The welcome message. It pops up above the launcher about a second after the widget loads and can cover part of your content on a small screen, as it covers the "Custom cakes" card in our screenshot. Visitors can close it with the ×, and it stays closed for the rest of their visit. Keep the message short so the bubble stays small.
- Your own fixed elements. The widget sits above almost everything on the page. If your sticky header uses a very high
z-index, check the two don't fight on scroll.
What does Laddu Chat cost on a static site?#
If your site sits on a free static host, Laddu Chat is the only bill. 100 free credits, no card; paid plans start at $20 a month. Free bots can go on your site and show a small Laddu AI badge, and the 100 free credits reset each month.
| Plan | Monthly | Bots | Answers a month | Badge |
|---|---|---|---|---|
| Free | $0 | 1 | 100 | Shown, or removed with the $24 a month add-on |
| Starter | $20 | 1 | 2,500 | Shown, or removed with the $24 a month add-on |
| Growth | $75 | 3 | 10,000 shared | Removed |
| Scale | $250 | 50 | 40,000 shared | Removed |
One answer uses one credit, however long it is, and credits are shared by every bot on the account. Visitors who open the widget and ask nothing cost nothing. Full details are on the pricing page.
If you build static sites for clients, Growth covers three client sites without the badge for $75 a month, about $25 a site. Selling a chatbot to web design clients covers how to price it.
What it won't do, so you can decide before you paste anything:
- Sources are added one at a time. Train it on web pages (add each URL), PDFs up to 10MB, and pasted text. There's no whole-site import, so a 40-page static site means picking the pages that answer real questions.
- No automatic refresh. When you change a price in your HTML, click Recrawl on that source, then Retrain, or the bot keeps the old one.
- No live chat or human handoff. When the bot doesn't know, it says so instead of guessing and points visitors to your Support Email, or offers to take their details if you turn on lead fields. Set a Support Email so visitors have somewhere to go. If you need a person to take over live conversations, use a live chat tool instead.
- Leads go to your inbox, not a CRM. Turn on lead fields (name, email or phone) and set a Support Email in Configure, and every plan captures leads and emails them to you; Growth and Scale add a Leads dashboard and CSV export. There's no Zapier, HubSpot or webhook connection. Website chatbot lead capture covers what to ask for.
- No position, font or CSS settings. You set colours, the welcome message, suggested questions and an avatar.
If that fits, create a free account, add your key pages, paste the two tags and run the four test questions from Step 3.
Sources#
- MDN Web Docs, "
<script>: The Script element":deferscripts run "after the document has been parsed", in the order they appear, anddeferhas no effect withoutsrc. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script (checked 29 November 2026) - MDN Web Docs, "Content-Security-Policy: script-src directive": inline scripts are allowed only with
'unsafe-inline', a nonce or a hash;default-srcis the fallback whenscript-srcis absent. https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/script-src (checked 29 November 2026) - MDN Web Docs, "Content-Security-Policy: frame-src directive": falls back to
child-src, thendefault-src. https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/frame-src (checked 29 November 2026) - GitHub Pages caching: response header
cache-control: max-age=600on https://pages.github.com/ (measured withcurl -Ion 29 November 2026). - Our embed test, 29 November 2026: a hand-coded test page served with
python3 -m http.serveron localhost and opened as afile://URL in Chromium, using the production Laddu Chat widget. Placement in<body>and<head>, script order with and withoutdefer, three Content Security Policies, a page without the snippet, and phone checks at 390 px. - Laddu Chat plans, credits, badge, sources, embed steps, lead capture and limits: Laddu Chat product facts, verified against the product code on 26 and 28 November 2026. Live plans: /pricing
- Laddu Chat reply when the bot doesn't know (says so, points to the Support Email, offers to take details when lead fields are on): Laddu Chat product facts, "When the bot can't answer" section, verified against the production code on 29 November 2026.
- Laddu Chat embed widget (CSP directives and the inline config line, no allowed-domains list, launcher size and position, full screen at 768 px or less, welcome message): Laddu Chat product facts, "Embed widget" section, verified against the production
embed.jsand the product code on 29 November 2026.
Frequently asked questions#
Where do I paste chatbot code in an HTML website?
Just before the closing </body> tag, after your own content and scripts. Inside <head> also works if the script tag that loads the widget has the defer attribute. Keep the chatbot's tags in the order the vendor gives them: in our test, moving Laddu Chat's loader above its config line without defer stopped the widget from loading.
Do I have to add the chatbot code to every HTML page?
On a hand-coded site, yes. Each .html file is its own page, and the widget only appears on pages that contain the snippet. If you use a static site generator such as Eleventy, Hugo or Jekyll, paste it once in the base layout that every page uses instead.
Can I test a website chatbot on localhost before I upload the site?
With Laddu Chat, yes. In our test the widget loaded and answered on a page served by python3 -m http.server on localhost, and also when we opened the .html file straight from disk. Laddu Chat has no allowed-domains list, so there's nothing to set up first.
Why is my chatbot not showing on my HTML site?
The usual causes, in order: the page you're looking at doesn't contain the snippet, the browser or host is still serving the old HTML, the script tags were cut off or swapped when you pasted them, a Content Security Policy blocks them, or embedding is switched off for the bot. Open the browser console: a blocked script or a missing chatbot ID shows up there as a red error.
Does a chatbot widget work on a site with a Content Security Policy?
Yes, once you allow it. For Laddu Chat that means script-src https://chat.laddu-ai.com, connect-src https://chat-api.laddu-ai.com, frame-src https://chat.laddu-ai.com and style-src 'unsafe-inline', plus a way to run the inline config line: a hash, a nonce, or moving that line into a .js file on your own domain. Without that last part, the widget fails with 'chatbotId is missing'.
How much does it cost to add an AI chatbot to a static website?
On a free static host, the chatbot is the only bill. On Laddu Chat: 100 free credits, no card; paid plans start at $20 a month. Free and Starter bots show a small Laddu AI badge. You can remove it with a $24 a month add-on, or move to Growth ($75 a month, three bots), which includes badge removal. One answer uses one credit. Prices in USD.