Skip to content

HTML chatbot code for your website.

The chatbot code for an HTML website is one line: a script tag you paste just before the closing </body> tag. ChatBento builds the chat bubble and window for you, trains the chatbot on your site's pages, docs and Q&As, and emails you when a visitor needs a person. It works on hand-written HTML, static site generators and any host that serves HTML files, with no server code on your side.

Paste your site address

Plans from $14 a month. Cancel anytime. Skip to the install steps

Install on Any website (HTML) in 6 steps

Where it goes: Just before </body>, on every page (or once in your shared layout or footer template)

  1. 1

    In ChatBento, create a chatbot and enter your website's address. It reads your published pages through your links and sitemap.

  2. 2

    In ChatBento, open your chatbot, go to Install and copy the one-line snippet.

  3. 3

    Open your HTML page, or your site's shared layout or footer template if it has one.

  4. 4

    Paste the snippet just before the closing </body> tag, after your own content.

  5. 5

    Save, then deploy or upload the changed files to your host.

  6. 6

    Open your live site in a new tab and click the chat bubble in the corner to test it.

The snippet (copy yours from the Install tab, where your bot ID is filled in)

<script src="https://chatbento.com/widget.js" data-bot-id="YOUR_BOT_ID" async></script>

index.html: where it goes

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Your site</title>
  </head>
  <body>
    <!-- your page content -->

    <script src="https://chatbento.com/widget.js" data-bot-id="YOUR_BOT_ID" async></script>
  </body>
</html>

Loads without blocking your page

The script is about 9 KB compressed and has the async attribute, so the browser keeps rendering your page while it loads. If the tag ends up on a page twice, the widget still loads only once.

Content Security Policy

If your site sends a Content-Security-Policy header, allow https://chatbento.com in script-src (to load the widget) and in connect-src (for chat requests).

Using a framework?

React, Next.js, Astro, Nuxt, Gatsby and Docusaurus have their own guides with code for that framework. Site builders such as WordPress, Webflow and Wix have a footer setting instead.

Other ways to add it to Any website (HTML)

Open it from your own button

You want a “Chat with us” button or link on the page, in addition to the bubble in the corner.

  1. Add the snippet as above.
  2. Call window.ChatBento.open() from your button or link. close() and toggle() work the same way.
  3. The widget creates window.ChatBento once it has loaded, so check that it exists first, as in the code below.

Any HTML page with the snippet

<button type="button" onclick="window.ChatBento && window.ChatBento.open()">
  Chat with us
</button>

Static site generators

Your site is built with Hugo, Jekyll, Eleventy or another generator that shares one base layout.

  1. Open the base layout every page uses, for example layouts/_default/baseof.html in Hugo or _layouts/default.html in Jekyll.
  2. Paste the snippet just before </body> and rebuild the site.
  3. Every generated page now includes the chatbot, so there's nothing to repeat page by page.

A multi-page site without templates

Your site is a folder of separate .html files with no shared layout.

  1. Paste the snippet before </body> in each page where you want the chatbot. Leave it out of pages where you don't.
  2. Upload the changed files.
  3. The widget loads again on each page, but the conversation is kept in the visitor's browser, so it carries on from page to page on the same domain. It starts fresh after a day without activity.

What the chatbot does on your site

Answers from your content

Trained on your pages, docs and Q&As. It says so when it doesn't know, instead of guessing.

Hands off to you

When a visitor needs a person, it collects their email and sends you the conversation.

Priced for small sites

Plans from $14/month, flat: up to 80% less than Chatbase, with no per-seat fees.

Comparing tools? See ChatBento vs Chatbase and pricing.

Build a chatbot in HTML and JavaScript, or paste one line?

You can write a chatbot from scratch in HTML, CSS and JavaScript, and tutorials show how. Here's what that involves next to the ChatBento script, so you can pick the one that fits.

What you write
Your own HTML/JS chatbot: The chat window's HTML, CSS and JavaScript, plus the logic behind every answer
ChatBento script: One script tag; the bubble and chat window are built for you
Where answers come from
Your own HTML/JS chatbot: Rules or keyword matching you code, or an AI model you call from your own server
ChatBento script: Your site's pages, docs and Q&As, which ChatBento reads and answers from
API keys
Your own HTML/JS chatbot: An AI model's key has to stay on a server, never in page JavaScript
ChatBento script: None in your page; the snippet only carries a public bot ID
Styles
Your own HTML/JS chatbot: Your site's CSS and the chat's CSS share the page and can clash
ChatBento script: Rendered in a shadow DOM, so styles don't leak either way
When it can't answer
Your own HTML/JS chatbot: Whatever you build
ChatBento script: Collects the visitor's email and sends you the conversation
Conversations
Your own HTML/JS chatbot: Stored wherever you build storage, if at all
ChatBento script: Kept in your ChatBento inbox
Control over the design
Your own HTML/JS chatbot: Every pixel
ChatBento script: Colors, avatar, greeting and corner, set in the dashboard

Any website (HTML) questions. Answered.

What is the HTML code for a chatbot on my website?

One line: <script src="https://chatbento.com/widget.js" data-bot-id="YOUR_BOT_ID" async></script>. Copy it from your chatbot's Install tab in ChatBento, where your bot ID is already filled in, and paste it before </body>.

Where do I paste the chatbot code in my HTML?

Just before the closing </body> tag, after your page content. Add it to every page where the chatbot should appear, or once in a shared layout or footer template if your site has one.

Can I open the chatbot from my own button or link?

Yes. Call window.ChatBento.open() from an onclick handler. window.ChatBento.close() and window.ChatBento.toggle() also work. The object appears once the widget has loaded, so check it exists before calling it.

Do I need a server or a backend to add a chatbot to a static HTML site?

No. The script loads from chatbento.com and talks to ChatBento's servers, so it works on static hosting that only serves HTML files. You don't write any server code or store any API keys.

Will the chatbot's styles clash with my CSS?

No. The widget renders inside its own shadow DOM, so your stylesheets can't change it and its styles can't leak into your page.

Will it slow down my website?

It shouldn't. The script is about 9 KB compressed and loads asynchronously, so your page renders first. The chat window stays hidden until a visitor opens it.

Can I stop other sites from using my chatbot?

Yes. List your domains under Allowed websites in the Install tab. Requests from any other site are refused, so nobody else can use up your messages.

How much does ChatBento cost?

ChatBento has three plans: Hobby at $14/month, Standard at $30/month and Pro at $100/month. Every plan starts with a 7-day free trial (card required), and you can cancel anytime from your dashboard.

Add AI support to your site. Live in minutes.

Paste your site address

Build and test free, no card. Then 7 days free on your site, from $14 a month after. See pricing