How-to

How to Add an AI Chatbot to WordPress in 2026: Plugin or Script Tag

Two honest ways to do it: the official PopABot plugin with a Chatbot ID, or one async script tag. Five methods ranked, the three things that actually break it (caching, JS optimisers, CSP), and how to show the widget on some pages but not others.

Key takeaways

  • Two ways in: install the official PopABot plugin from wordpress.org and paste a Chatbot ID, or drop one async script tag into your footer. Both end up in the same place.
  • The plugin is the easier route because it clears WP Super Cache, W3 Total Cache, LiteSpeed and WP Fastest Cache when settings change, and has page targeting built in.
  • If you go the script-tag route, put it in a site-wide footer snippet managed by a code-snippets plugin: that survives theme updates and theme switches because it lives in the database, not a theme file.
  • If nothing appears, it is almost always caching. Purge the plugin cache, the host cache, Cloudflare and your browser, then view source to confirm the tag is in the HTML.
  • Aggressive JavaScript optimisers (delay, combine, Rocket Loader) break third-party widgets. Exclude the chatbot domain rather than disabling optimisation site-wide.

Adding an AI chatbot to WordPress takes about two minutes. There are two honest ways to do it: install the official plugin and paste a Chatbot ID, or drop a single <script> tag into your footer. Both end up in the same place. The plugin is easier and handles caching for you; the script tag works anywhere and needs nothing installed.

Below: five install methods ranked, the three things that actually go wrong, and how to make the widget appear on some pages but not others.

The snippet

Once you've built a chatbot, the dashboard gives you a deployment snippet that looks like this:

<script src="https://www.popabot.com/deploy/YOUR_CHATBOT_ID" async></script>

One tag. It loads asynchronously, so it does not block rendering and does not hurt your Core Web Vitals the way an inline chat bundle would. It goes anywhere in the page, though before the closing </body> tag is conventional. Copy it from the deploy dialog on your chatbot; do not retype the ID.

Five ways to add it, ranked

Method 1: the official PopABot plugin (recommended)

Search "PopABot" in Plugins → Add New, or install it from wordpress.org/plugins/popabot. It requires WordPress 5.0+ and PHP 7.4+.

  1. Install and activate the plugin
  2. Open its settings and paste your Chatbot ID from the PopABot dashboard
  3. Choose where it appears: all pages, all pages except a list, or only specific pages (wildcards work)
  4. Save

Three reasons this is the method to pick if you are not sure. It handles the caching problem for you: changing settings clears WP Super Cache, W3 Total Cache, LiteSpeed and WP Fastest Cache automatically, which is the single most common reason a manually pasted snippet appears to do nothing. Page targeting is built in, so you do not need a second plugin or a conditional tag to keep the widget off your checkout. And the appearance settings (theme, primary colour, logo, avatar) are in the same screen.

Worth being straight about what it is: the plugin is a connector, not the chatbot. You build and train the bot on PopABot, and the plugin puts it on your site. A PopABot account is required, and the free Starter plan is enough to get it running.

Method 2: a code-snippets plugin

This is the method that survives theme updates, theme switches, and the next person who edits your site. Install any reputable snippet manager (WPCode, Code Snippets, Header Footer Code Manager, or whatever your host bundles), create a new snippet, set its location to site-wide footer, paste the tag, activate.

  1. Plugins → Add New → search for a header/footer snippet plugin → install and activate
  2. Open its settings and find the footer or "before </body>" box
  3. Paste the script tag
  4. Save, then hard-refresh your homepage (Ctrl+Shift+R / Cmd+Shift+R)

Why this wins: the snippet lives in the database, not in a theme file. Updating your theme, or switching from one to another, does not delete it.

Method 3: your theme's built-in header/footer scripts box

Most modern commercial themes (Astra, GeneratePress, Kadence, Blocksy, Divi, Avada) have a "Custom Code", "Header/Footer Scripts", or "Code Injection" panel in the Customizer or theme options. If yours does, use it. It is the same benefit as method 2 with one fewer plugin. The catch: the setting belongs to that theme, so it disappears if you change themes. Note that down somewhere.

Method 4: functions.php in a child theme

For developers, or for sites already running a child theme. Add this to the child theme's functions.php:

add_action( 'wp_footer', function () {
    ?>
    <script src="https://www.popabot.com/deploy/YOUR_CHATBOT_ID" async></script>
    <?php
}, 100 );

Two rules if you go this route. It must be a child theme, or the next theme update wipes it. And edit the file over SFTP or in your IDE, not in Appearance → Theme File Editor: a syntax error saved there can lock you out of your own admin.

Method 5: a Custom HTML block on a single page

Only worth it when you want the chatbot on exactly one page, for example a campaign landing page. Edit the page, add a Custom HTML block at the bottom, paste the tag. It will not appear anywhere else. For anything site-wide, use method 1 or 2.


The three things that actually go wrong

1. You installed it and nothing appears

Ninety percent of the time this is caching, not the snippet. In order:

  1. Purge your caching plugin (WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Super Cache). Then purge your host's cache too, which is a separate thing on SiteGround, Kinsta, WP Engine and most managed hosts.
  2. Purge Cloudflare if you use it. "Purge everything" from the Caching tab.
  3. Hard-refresh your own browser, or check in a private window. Your browser is the last cache in the chain and the easiest one to forget.
  4. View source (Ctrl+U) and search for popabot. If the tag is not in the HTML, the snippet is not being output and the problem is where you pasted it. If the tag is there, the problem is the next section.

2. A JavaScript optimiser is mangling the script

Aggressive "optimise JavaScript" features can defer, combine or delay third-party scripts in ways that break them. The usual suspects: WP Rocket's "Delay JavaScript execution" and "Combine JavaScript files", LiteSpeed's "JS Combine" and "Load JS Deferred", Autoptimize's "Aggregate JS-files", and Cloudflare Rocket Loader.

The fix is to exclude the chatbot script rather than to turn the whole optimiser off. Every one of those plugins has an exclusion list; add popabot.com to it. If you want to keep delay-JS for speed, note that a delayed chat widget only loads after the first user interaction, which is often an acceptable trade: the bubble appears a fraction of a second after the first scroll.

3. A security plugin or CSP is blocking it

If your site sends a Content-Security-Policy header (some security plugins add one, as do some managed hosts), an external script from a new domain will be blocked outright. Open your browser console: a CSP violation says so explicitly. Add the chatbot domain to your script-src and connect-src directives. Firewall plugins like Wordfence rarely interfere with outbound script tags, but their "block unknown scripts" style options do, so check there if the console is clean but nothing renders.

Showing the chatbot on some pages but not others

Three approaches, depending on how you installed it.

  • The PopABot plugin's own page targeting. All pages, all pages except a list, or only specific pages, with wildcard support. If you used method 1, this is already there and you need nothing else.
  • Conditional logic in a snippet plugin. Most snippet managers let you set display rules: only on posts, only on a page ID, everywhere except the checkout. This is the no-code answer and it covers most cases.
  • Conditional tags in your child theme. Wrap the output in a check, for example if ( ! is_page( 'contact' ) ) { … } or if ( is_singular( 'product' ) ) { … }. Precise, and free.

A common WooCommerce pattern: run the chatbot everywhere except cart and checkout, so it never distracts someone mid-purchase. If you sell through WooCommerce, note that PopABot also has a direct WooCommerce integration on Essential and above, so the bot can answer from your real product catalogue rather than from a scrape of your shop pages.

Does it slow WordPress down?

The tag is async, so it does not block HTML parsing or first paint. The widget's own assets load after the page is interactive. In practice the measurable cost is a small amount of main-thread work after load, not a Largest Contentful Paint regression.

Two things that do help if you're chasing a perfect score: keep the widget off pages where it has no job (checkout, thank-you pages), and if your optimiser offers "delay until interaction", use it rather than excluding the script from optimisation altogether.

The part most people skip: give it your content

Installing the snippet is the easy half. A chatbot on a WordPress site with no training data is a support ticket generator. Before you publish, point a website dataset at your own domain and let it crawl your pages, then add a Q&A dataset for the things your site never says out loud (hours, service area, prices, turnaround). The free plan crawls up to 100 pages per website dataset, Essential 500, Pro 2,000, which covers most WordPress sites including a good-sized blog.

If your site changes often, Pro adds automatic dataset refresh so new posts and updated pages flow into the bot on a schedule instead of you re-crawling by hand. There is a full walkthrough in how to train an AI chatbot on your business data.

Ten-minute checklist

  1. Build the chatbot and add at least one dataset (your site URL)
  2. Install the PopABot plugin and paste your Chatbot ID — or, if you prefer no extra plugin, copy the deploy snippet from the dashboard into a footer snippet, site-wide
  3. Purge plugin cache, host cache, and Cloudflare (the plugin does the first of these for you)
  4. View source and confirm the tag is in the HTML
  5. Exclude the script from JS combining/delaying if your optimiser is aggressive
  6. Test on a phone, not just desktop
  7. Ask it your five most common customer questions and fix any weak answers in the dataset
  8. Set display rules if you want it off checkout or admin-facing pages
  9. Check the conversations view after a week and feed the gaps back in

Frequently asked questions

How do I add an AI chatbot to WordPress without a plugin?

Paste a single async script tag into your theme's header/footer code box, or into a child theme's functions.php hooked to wp_footer. Most modern themes (Astra, GeneratePress, Kadence, Blocksy, Divi, Avada) have a custom code panel in the Customizer for exactly this. No chatbot plugin is required because the widget loads from one external script.

Where should the chatbot script go in WordPress?

In a site-wide footer snippet managed by a code-snippets plugin (WPCode, Code Snippets, Header Footer Code Manager). That location survives theme updates and theme switches because the snippet lives in the database rather than in a theme file. A theme's own code box is the next best option, but the setting disappears if you change themes.

I added the chatbot script but nothing appears. Why?

Almost always caching. Purge your caching plugin (WP Rocket, LiteSpeed, W3 Total Cache, WP Super Cache), then your host cache, which is separate on SiteGround, Kinsta and WP Engine, then Cloudflare, then hard-refresh your browser. Then view source and search for the script domain: if the tag is missing from the HTML, the snippet is not being output; if it is present, a JavaScript optimiser or a Content-Security-Policy header is blocking it.

Does a chatbot slow down WordPress or hurt Core Web Vitals?

The tag is async, so it does not block HTML parsing or first paint, and the widget's assets load after the page is interactive. The measurable cost is a small amount of main-thread work after load, not an LCP regression. To minimise it, keep the widget off pages where it has no job (cart, checkout, thank-you pages) and use your optimiser's "delay until interaction" option rather than excluding the script from optimisation entirely.

Why does WP Rocket or LiteSpeed break my chatbot?

Features like "Delay JavaScript execution", "Combine JavaScript files", Autoptimize's JS aggregation and Cloudflare Rocket Loader rewrite or postpone third-party scripts in ways that break them. The fix is to add the chatbot domain to that plugin's exclusion list rather than disabling optimisation site-wide. Delay-JS is often still fine: the bubble simply appears after the visitor's first scroll or tap.

How do I show the chatbot on some WordPress pages but not others?

Two ways. Use your snippet plugin's conditional display rules (only on posts, only on a page ID, everywhere except checkout), which needs no code. Or wrap the output in a WordPress conditional tag in your child theme, such as is_page(), is_singular() or ! is_checkout(). A common WooCommerce pattern is to run the bot everywhere except cart and checkout so it never distracts a buyer mid-purchase.

Is there an official PopABot WordPress plugin?

Yes. PopABot is on the WordPress.org plugin directory at wordpress.org/plugins/popabot, and it requires WordPress 5.0+ and PHP 7.4+. You install it, paste your Chatbot ID from the dashboard, and choose which pages the widget appears on. It also clears WP Super Cache, W3 Total Cache, LiteSpeed and WP Fastest Cache when settings change, which removes the most common reason a chat widget appears to do nothing. The plugin is a connector: you build and train the chatbot on PopABot, and the plugin puts it on your site, so a PopABot account is required.