How to Add an AI Chatbot to a Custom HTML Website
A step-by-step developer guide on embedding an autonomous, knowledge-grounded AI customer support assistant into static HTML5 websites, Bootstrap templates, and static site generators (Jekyll, Hugo, Astro).
Static HTML websites deliver unmatched speed, security, and low hosting costs. Whether your site is built with plain HTML/CSS, Tailwind, Bootstrap, or compiled via static site generators, adding an intelligent conversational agent shouldn't require bloated npm packages, complex backend proxies, or framework migrations.
Knogents provides a pure, vanilla JavaScript loader (embed.js) minified to under 12KB. It mounts asynchronously into your DOM, communicates with Neon pgvector vector stores via secure APIs, and renders with zero styling conflicts against your page CSS.
Paste this snippet immediately before the closing </body> tag on your HTML pages:
<!-- Knogents Autonomous Support Agent -->
<script
src="https://knogents.com/embed.js"
data-bot-id="YOUR_BOT_ID"
data-display-mode="floating"
async
></script>Step-by-Step Installation Walkthrough
Create Your Assistant and Ingest Website Data
Log in to your Knogents dashboard and click Create Chatbot. Enter your bot name and navigate to the Knowledge Base tab. You can train your assistant using two simple sources:
- Website Sitemaps: Enter your sitemap URL (e.g.
https://example.com/sitemap.xml) to automatically crawl and index all public pages. - Files & Spreadsheets: Upload product spec PDFs, company FAQ documents, or Excel/CSV pricing tables.
Knogents chunks the content semantically, extracts headers, and indexes embeddings in under 2 minutes.
Retrieve Your Bot ID and Embed Script
Click the Deploy tab in the navigation bar. You will find your unique Bot ID (e.g., bot_abc123xyz) and the ready-to-copy HTML code block.
Embed Before </body> in Your HTML File
Open your project in VS Code, Sublime, or any text editor. Locate your index.html (or shared footer include in Jekyll/Hugo). Paste the script right before the closing </body> tag:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Business Website</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<header><h1>Welcome to Acme Corp</h1></header>
<main><p>High-quality engineering solutions.</p></main>
<!-- Knogents Chatbot Embed -->
<script
src="https://knogents.com/embed.js"
data-bot-id="bot_98fbc12a"
data-display-mode="floating"
data-position="right"
async
></script>
</body>
</html>Configure Display Mode: Floating vs. Inline Container
Knogents supports two native display configurations:
Renders a discreet circular launcher button in the bottom corner of the viewport. Clicking it expands the chat window.
data-display-mode="floating"Renders the conversational interface directly inside an element on your contact or support page.
<div id="rag-inline-bot"></div>Testing Locally over an HTTP Server
When testing locally, do not open the HTML file directly by double-clicking it (file:///C:/Users/.../index.html). Browsers restrict cross-origin script execution and network requests from file URIs. Instead, run a quick local HTTP server from your project folder:
# Using Node.js npx:
npx serve .
# Or using Python 3:
python -m http.server 8000Open http://localhost:8000 in your browser. The assistant launcher will appear in the bottom-right corner!
Google Core Web Vitals & Performance Impact
Adding third-party scripts often degrades Google Lighthouse performance scores. Knogents is engineered specifically to eliminate performance penalties:
async attribute ensures browser HTML parsing is never interrupted.Content Security Policy (CSP) Directives
If your HTML web server (Apache, Nginx, or Netlify/Vercel headers) serves a restrictive Content Security Policy, add the following domain directives to permit widget initialization and API communication:
Content-Security-Policy:
script-src 'self' https://knogents.com;
connect-src 'self' https://knogents.com;
style-src 'self' 'unsafe-inline';
img-src 'self' https://knogents.com data:;Frequently Asked Questions
Can I change the launcher position to the bottom-left?
Yes. Simply add data-position="left" to your embed script tag. The widget launcher will automatically dock on the bottom-left margin of the viewport.
Does Knogents work with static site generators like Jekyll, Hugo, and Astro?
Yes. In Jekyll, place the script in _includes/footer.html. In Hugo, place it in layouts/partials/footer.html. In Astro, place it in your base layout template right before </body>.
How do I style the chatbot colors to match my HTML theme?
You can set your primary brand hex color directly in the Knogents dashboard under Chatbot Settings, or supply data-accent-color="#0d9488" as an attribute on the script tag.
Deploy Your Chatbot in 3 Minutes
Create your free Knogents assistant, crawl your HTML website or sitemap, and copy your embed snippet today.