How to Add an AI Chatbot to WordPress (Plugin or Code Snippet)

There are two ways to put a HolderChat bot on a WordPress site: the Connector plugin, or the plain embed snippet in your footer. Both show the same chat button. The real difference is how the bot learns your content and keeps it current. This guide helps you pick one, set it up, and fix the two things that most often break a chat widget on WordPress: page caching and JavaScript optimisation.

Mint illustration: WP Admin with the Connector plugin or a footer snippet, a cache setting with the chat script excluded, and a web page with an open chat window
Plugin or snippet: both end with one chat script on every page. Your cache settings decide whether visitors see it.

Plugin or snippet: pick by how the bot learns

HolderChat Connector pluginEmbed snippet
Where the bot gets its knowledgeYour published pages and posts, sent from WordPressA website source you add in the dashboard (crawl), plus files
After you edit a pageSynced automatically; one rebuild about 90 seconds after the last change (adjustable)Re-parse the website source, then click Rebuild Bot
Choosing what the bot readsContent tree in the plugin’s Setup tabPage selection when you add the website source
Managing the botInside WP Admin, or on holderchat.com after linkingOn holderchat.com
Bots per siteOne per WordPress domainAny bot you choose
Best forSites where WordPress pages are the main source of answersBots that also serve other sites, use a lot of files, or where you cannot install plugins

Use one method, not both. The loader starts once per page and reads the first matching tag, so a second tag only makes it unclear which bot is answering.

Option 1: the HolderChat Connector plugin

  1. Download the ZIP from the WordPress plugin page. In WP Admin go to Plugins → Add New → Upload Plugin, choose the file, then Install Now and Activate. It needs WordPress 5.8 or later and PHP 7.4 or later.
  2. Open HolderChat → Setup. Read the external service notice: your page content is sent to holderchat.com to build the bot.
  3. Under Content to sync, untick what the bot should not learn from (see the next section). Turn on AI chunking only if you have long pages; it gives better answers on them but takes longer.
  4. Click Create Chatbot and wait for the success message. The plugin uploads your content in batches of 75 pages and starts a rebuild. When the status is Active, the chat button is on your site.
  5. Optional but useful: Settings → Link to HolderChat account, so the bot also shows up in your holderchat.com dashboard.

You do not paste any code. The plugin adds this tag before </body> on every front-end page (it is the same tag you will find in the source of holderchat.com):

<script id="holderchat-connector-widget-js" async defer src="https://holderchat.com/dynamic/get.js?token=YOUR_TOKEN&ver=1.0.1"></script>

After setup, edits to published pages sync on their own. Several quick edits lead to one rebuild after the debounce window (90 seconds by default, 30–600 in Settings), and a daily delta sync catches anything that was missed. Details: WordPress Sync and Rebuild Timing.

What not to sync

The bot answers from what you give it, so leave out pages that only confuse it:

  • Cart, checkout, “my account” and thank-you pages. They have almost no text and nothing a visitor would ask about.
  • Pages built only from shortcodes or page-builder widgets that output no real text. The plugin converts the page HTML to plain text; if there is little text, there is little to learn.
  • Old offers, landing-page variants and drafts you kept published by mistake. If two pages disagree, the bot may quote the wrong one.

How the content tree works: WordPress Content Selection. For writing pages that answer well, see Write Website Pages an AI Chatbot Can Answer From.

Option 2: the embed snippet

Create a bot in the HolderChat dashboard, add your site under Knowledge Sources → Add Website, pick the pages, and click Rebuild Bot. Then copy the snippet from Widget Appearance → Embed on your website:

<script src="https://holderchat.com/dynamic/get.js?token=YOUR_TOKEN" async></script>

Put it on every page in one of these places:

  • A code-snippets plugin with a site-wide footer field (WPCode and similar). It survives theme updates and theme changes.
  • A block theme’s footer: Appearance → Editor → Patterns → Footer, add a Custom HTML block, paste, save.
  • A child theme, with a few lines of PHP. Do not edit the parent theme; the next update overwrites it.
<?php
// Child theme functions.php, or a PHP snippet in a code-snippets plugin.
// Prints the HolderChat script embed before </body> on every front-end page.
add_action( 'wp_footer', function () {
    echo '<script src="https://holderchat.com/dynamic/get.js?token=YOUR_TOKEN" async></script>' . "\n";
} );

Do not paste the snippet into a normal Paragraph block. WordPress shows it as text, or strips it, and it only runs on that one page. On WordPress.com, whether you can add scripts and plugins depends on your plan.

With the snippet, the bot does not see WordPress edits by itself. After changing important pages, re-parse the website source in Knowledge Sources and rebuild.

Show the chat only where it helps

A chat button on the checkout page can cover the “Place order” button on small screens and pull attention away from paying. With the plugin, remove its script on the pages you choose. The script handle below is the one the plugin registers:

<?php
// With the HolderChat Connector plugin: keep the widget off checkout and account pages.
add_action( 'wp_enqueue_scripts', function () {
    $hide = ( function_exists( 'is_checkout' ) && ( is_checkout() || is_account_page() ) )
         || is_page( array( 'members', 'thank-you' ) ); // your own page slugs

    if ( $hide ) {
        wp_dequeue_script( 'holderchat-connector-widget' );
    }
}, 20 ); // after the plugin, which enqueues at the default priority 10

With the snippet, check the page before you print the tag:

<?php
// Snippet method: same rule, applied before printing the tag.
add_action( 'wp_footer', function () {
    if ( function_exists( 'is_checkout' ) && ( is_checkout() || is_account_page() ) ) {
        return;
    }
    echo '<script src="https://holderchat.com/dynamic/get.js?token=YOUR_TOKEN" async></script>' . "\n";
} );

is_checkout() and is_account_page() are WooCommerce functions; the function_exists check keeps the code safe on sites without WooCommerce. You can switch the widget off for the whole site under HolderChat → Settings → Show chat widget on frontend without uninstalling anything.

For what a store bot should answer and what to send to a person, see AI chatbot for online stores.

Caching and optimisation plugins: why the button goes missing

When the chat button is missing on a WordPress site, a performance tool is often the cause, not the chat itself. To fix them it helps to know one detail of the loader. get.js finds its settings by looking for a <script> tag whose src contains /dynamic/get.js. From that URL it reads your bot token and the server address. (We checked this in the current loader code on 26 November 2026.) That leads to three rules:

OptimisationWhat happens to the chatWhat to do
Page cache (and CDN cache)Visitors get the old HTML without the tag. You see the button because you are logged in and caches usually skip logged-in users.Purge the plugin cache and the CDN or host cache after setup, then check in a private window.
Delay JavaScript until interactionThe button appears only after the visitor scrolls, taps or moves the mouse.Fine if speed scores matter more. If you want the button at once, exclude /dynamic/get.js from the delay.
Combine external scripts, or host third-party scripts locallyThe loader runs from a different URL, cannot find its tag, and has no token. No widget appears.Exclude /dynamic/get.js from combining and local hosting. Leave the tag as it is.

Where to enter the exclusion:

  • WP Rocket: File Optimization → Delay JavaScript execution → Excluded JavaScript Files. For a tag you added yourself, WP Rocket also skips scripts that carry a nowprocket attribute.
  • LiteSpeed Cache: Page Optimization → Tuning → JS Deferred/Delayed Excludes (used when Load JS Deferred is set to Deferred or Delayed), and JS Excludes if you turned on JS Combine External and Inline.
  • Other tools have a similar “exclude scripts” field. The string to enter is the same everywhere:
/dynamic/get.js

Save, purge all caches, and test again logged out.

Using a cookie-consent plugin that blocks scripts until consent? Then the button appears only after the visitor accepts. That is expected. The script embed sets two cookies for session continuity, holderchat_user_id and holderchat_talk_id (see Embedding the Chatbot Widget), and the plugin suggests privacy policy text under Settings → Privacy. Anonymisation options: Privacy Settings.

Check it like a visitor

  • Open the site in a private window, logged out, with ad blockers off. The chat button should appear in the corner.
  • View the page source and search for /dynamic/get.js. You want exactly one match, with your token in the URL.
  • If the tag is in the source but no button appears, open the browser console. A blocked script or a 4xx error names the cause.
  • Ask two or three questions that a real customer asks, and check that the answers come from your pages.
  • Open a checkout or account page if you hid the widget there, and confirm it is gone.
  • For a full pre-launch list, see Test Your Website Chatbot Before You Go Live.

FAQ

Does the plugin slow down my WordPress site?

The widget script loads with async and defer in the footer, so it does not block the page from rendering. Content sync runs in the background on save, not when visitors load a page. Measure your own pages with PageSpeed Insights before and after.

Can I use the iframe embed on WordPress?

Yes, with the snippet method. Replace get.js with /dynamic/iframe.js?token=YOUR_TOKEN from Widget Appearance. It isolates the widget from your theme and is the method to use if you need custom CSS or JavaScript for it. The plugin uses the standard script embed.

I use Elementor or another page builder. Where does the snippet go?

Prefer a site-wide footer (code-snippets plugin or child theme) over an HTML widget on single pages. With the plugin, the builder does not matter, but check that the pages contain real text the bot can read.

What happens if I deactivate the plugin?

The widget and auto-sync stop on your site. The bot and its data stay on HolderChat. Uninstalling removes the connection settings from WordPress, not the bot.

Can one site have two bots, for example for sales and support?

The plugin connects one bot per WordPress domain. If you need a different bot on some pages, use the snippet method and print a different token on those pages, as in the conditional example above.

Ready to try it on your site? Install the Connector plugin if WordPress is where your answers live, or create a bot and paste the snippet. Stuck with a cache plugin we did not mention? Ask the chat on this page.