How to Add an AI Chatbot to WordPress (2026 Step-by-Step)
Add an AI chatbot to your WordPress site with one script tag. Covers WPCode, block themes, caching plugins and how to test its answers first.
By Jahidul Hossain MekatUpdated 9 min read
On this page
To add an AI chatbot to WordPress, copy your chatbot’s one-line script, install the free WPCode plugin, paste the line into Code Snippets → Header & Footer → Footer and click Save Changes. You don’t edit your theme, and it works on block themes too. Then clear your cache, open your site in a private window and ask something your site doesn’t answer: a good chatbot says it doesn’t know instead of guessing.
What do you need before you start?
Three things, and about five minutes:
- An Administrator login. On a normal WordPress site only Administrators can install plugins. On a Multisite network only the Super Admin can (WordPress roles and capabilities).
- A plan that allows scripts, if your site is on WordPress.com. Plugins and custom JavaScript need a paid plan, Personal or higher; free sites can’t add them (plugins, custom code).
- Your chatbot’s script. It’s one line that starts with
<script. With Site Can Talk, paste your web address to sign up, and the Add it to your website panel in your dashboard has a Copy code button. The line looks like this:<script async src="https://…/w.js" data-site="your-site-id"></script>
These steps fit any self-hosted WordPress site, the platform behind 39.6% of all websites (W3Techs, 20 October 2026). Not on WordPress? Here’s the Squarespace version of this guide and the Wix version.
How do you add an AI chatbot with WPCode?
Install WPCode, paste the script into its Footer box, save, clear your cache and check: five steps, no theme edits. WPCode is a free plugin for adding code to WordPress. Its WordPress.org page lists more than 3 million active installations and a last update on 8 October 2026 (WPCode). The Footer box prints your code “just above the closing </body> tag” on every page (WPCode docs).
- Install WPCode. In your dashboard, go to Plugins → Add Plugin (Add New Plugin or Add New on older versions). Search for “WPCode”, click Install Now, then Activate.
- Open the footer box. Go to Code Snippets → Header & Footer. You’ll see three boxes: Header, Body and Footer.
- Paste the script into Footer. Paste the whole line, from
<scriptto</script>, then click Save Changes. - Clear your cache. WPCode itself reminds you to “clear your site cache if you use a caching plugin.” Clear your host’s cache and any CDN too.
- Check it as a visitor. Open your site in a private window, on your computer and on your phone. The chat button should appear on every page.
We checked these menu names against the code of WordPress 7.1.3, the current version, and against WPCode’s own docs in October 2026.
Can you add a chatbot to WordPress without a plugin?
Yes, on a block theme: paste the script into your site’s footer in the Site Editor. Developers can use a child theme instead.
Block themes: the Site Editor
- Go to Appearance → Editor. This menu only appears when a block theme is active.
- Click Patterns, then Template Parts, and open Footer.
- Add a Custom HTML block (type
/htmland press Enter), click Edit HTML, paste the script and click Update. - Click Save.
Two catches. WordPress strips the <script> tag if whoever saves the block may not post unfiltered HTML: on a normal site that’s anyone below Editor, on a Multisite network anyone but the Super Admin (Custom HTML block, roles). And the footer belongs to your theme, so a theme switch means pasting the script again. WPCode doesn’t depend on your theme, which is why we recommend it.
Developers: a child theme
Print the line from the wp_footer hook in a child theme’s functions.php, so parent-theme updates don’t wipe it (Theme Handbook):
add_action( 'wp_footer', function () {
echo '<script async src="https://…/w.js" data-site="your-site-id"></script>';
} );Should you use a chatbot plugin instead?
A plugin can run the chatbot inside WordPress on your own AI account; a script-tag chatbot runs on its maker’s servers. AI Engine is an example of the first kind: a chatbot plugin with 90,000+ active installations that connects to OpenAI, Anthropic, Google and others with your own API keys, and keeps conversations on your own site (WordPress.org, updated 17 October 2026).
| What differs | Plugin that runs the AI | Script-tag chatbot |
|---|---|---|
| Where it runs | Inside your WordPress site | On the chatbot maker’s servers |
| What you set up | The plugin, plus an API key from an AI company | One pasted line; settings live in the maker’s dashboard |
| Who you pay | The AI company, for what you use | The chatbot maker |
| Upkeep | One more plugin to keep updated | Nothing beyond WPCode, if you use it |
| If you leave WordPress | Set it up again on the new platform | The same line works on any platform that accepts a script |
If a chat service’s WordPress plugin only adds its script to your pages, it belongs in the second column.
Site Can Talk (we make it) is the script-tag kind. It answers only from your pages and the notes you add, and when the answer isn’t there it says so and offers to take the visitor’s details. It can take visitors to the right page, chats by text with voice on tap, and emails you every lead on any plan, with WhatsApp alerts from Growth up. At a plan limit it turns into a contact form instead of disappearing. See how it works and the plans.
How do you check it works and doesn’t make things up?
Ask it five questions before you tell anyone it’s there:
- A price that’s on your site. The answer should match the page exactly.
- Something your site doesn’t cover. It should say it doesn’t know and offer to take your details.
- A discount you don’t offer. It must not invent one.
- A question about a competitor. It should stick to your business.
- The same question in a second language your customers use (see our guide for Bangla and English sites).
Our guide to choosing an AI chatbot for a small business website explains what each question catches. It matters because you answer for what your chatbot says. In February 2024 a Canadian tribunal ordered Air Canada to pay a passenger C$812.02 after its website chatbot gave wrong information about bereavement fares, and rejected the airline’s suggestion that the chatbot was responsible for its own actions:
“It should be obvious to Air Canada that it is responsible for all the information on its website.”
Then, on your phone, tap the mic if voice is on, ask where your prices are to see if it takes you there, and leave a test enquiry to check the lead reaches your inbox. Site Can Talk’s dashboard also switches from Waiting for the first visit to Installed once the chat loads. After that, speed is on you: our guide for real estate websites shows why the first reply wins.
Why isn’t my chatbot showing on WordPress?
Either visitors are getting an old cached copy of your page, or something on the page stops the script: a speed plugin, a consent plugin, a page rule or a security header. Check them in this order:
- An old cached page. Clear your caching plugin, your host’s cache and any CDN, then reload in a private window.
- Delayed JavaScript. Speed plugins can hold every script until the first scroll, tap or key press, so the button appears late. Exclude the chatbot’s script (table below).
- A cookie-consent plugin. If the button appears only after you click Accept, your consent plugin is holding the script back. Check its list of blocked scripts.
- Page rules. In Site Can Talk, check Settings → Where it shows.
- A different address. The chat only runs on the addresses under Websites allowed to use it. Add a staging copy or second domain there.
- A security header. If a security plugin sends a Content Security Policy, it must allow your chatbot’s domain. Ask whoever set it up.
How to stop speed plugins delaying the chatbot
WP Rocket’s Delay JavaScript execution works by “delaying the loading of all JavaScript files and inline scripts until there is a user interaction” (WP Rocket docs, updated 11 March 2026). LiteSpeed Cache and Perfmatters have the same kind of setting. In each, add w.js (or your own chatbot’s script file) to the exclusion box. We checked each plugin’s documentation in October 2026:
| Plugin | Setting that delays scripts | Where to exclude the chatbot |
|---|---|---|
| WP Rocket | File Optimization tab → Delay JavaScript execution | Excluded JavaScript Files |
| LiteSpeed Cache | Page Optimization → JS Settings → Load JS Deferred, set to Delayed | Page Optimization → Tuning → JS Deferred/Delayed Excludes |
| Perfmatters | JavaScript → Delay JavaScript, with Delay all scripts | Excluded from Delay |
All three match part of a file name or address, so w.js is enough. Save, clear the cache and check again. Also using LiteSpeed’s JS Combine External and Inline? Add w.js to JS Excludes too: the chatbot reads its site ID from its own script tag, so it stops working if merged into a combined file.
Will a chatbot slow down your WordPress site?
Not noticeably, if its script is small and loads with async. Site Can Talk’s script measured 10.7 KB compressed on 20 October 2026, and the page never waits for it. The voice part, about 2 KB more, loads only when a visitor taps to talk. That’s also why excluding it from delayed JavaScript costs you little. The chat sits in its own sealed-off box on the page, so your theme’s styles can’t break it and it can’t restyle your theme.
Check any chatbot, ours included: run the same page through PageSpeed Insights before and after installing.
Does it work with WooCommerce and multilingual sites?
Yes. On a WooCommerce shop the chatbot answers from your product and policy pages, so put delivery times, returns and payment options there. To keep checkout free of distractions, set Site Can Talk’s Where it shows to Every page except these and add your checkout address, such as /checkout*.
With WPML or Polylang, each language version of a page has its own address, so the chatbot reads it as a separate page. Site Can Talk reads up to 100 pages per site, which a two-language site with 50 pages in each language fills. Under Settings → Voice and languages, pick your main language and the others it may reply in; a visitor who writes in a language you didn’t allow gets your main one.
Questions
Does WordPress have a chatbot?
Not for your visitors. WordPress 7.0 (May 2026) added a Connectors screen for AI services and an optional AI plugin with editor tools for titles, excerpts, images and alt text. To answer visitors, you add a chatbot plugin or a chatbot script.
How do I add a script to the footer in WordPress?
Install the free WPCode plugin, go to Code Snippets → Header & Footer, paste the script into Footer and click Save Changes. On a block theme you can instead put a Custom HTML block in the Footer template part (Appearance → Editor → Patterns).
Can I add an AI chatbot to WordPress for free?
Yes. WPCode is free, and Site Can Talk’s free plan covers one website with 200 chat messages and 10 voice minutes a month, and leads by email. Paid plans start at $19 a month. At a plan limit the chat turns into a contact form, so enquiries still reach you.
Do I need a WordPress chatbot plugin?
No. A script-tag chatbot only needs somewhere to paste one line, which WPCode or a block theme’s footer gives you. A plugin that runs the AI inside WordPress makes sense if you want everything on your own server and your own AI account.
Does the chatbot set cookies?
Site Can Talk’s script sets no cookies of its own. It keeps a random visitor ID in the browser’s local storage and the conversation in session storage, and runs a Cloudflare Turnstile bot check when a chat starts. Mention it in your privacy notice and your consent tool.
About the author
Jahidul is the founder of Site Can Talk, the AI chat and voice agent that answers a business's website visitors from its own pages and sends every lead to the owner.
Jahidul Hossain Mekat on LinkedInSources
- W3Techs, 20 Oct 2026Usage statistics of content management systems
- WordPress.org Plugin Directory, updated 8 Oct 2026WPCode – Insert Headers and Footers + Custom Code Snippets
- WPCode docsUsing the Global Header & Footer settings
- WordPress.org Documentation, updated 14 Sep 2026Site Editor
- WordPress.org Documentation, updated 15 Jun 2026Custom HTML
- WordPress.org Documentation, updated 2 Sep 2026Roles and Capabilities
- WordPress Theme HandbookChild Themes
- WordPress.org, 19 May 2026WordPress 7.0
- WordPress.com Support, reviewed 20 Oct 2026Install a plugin on a WordPress.com site
- WordPress.com Support, reviewed 5 Oct 2026Add code to your WordPress site
- WP Rocket Knowledge Base, updated 11 Mar 2026Delay JavaScript execution
- LiteSpeed Cache for WordPress documentationPage Optimization
- Perfmatters docs, updated 1 Oct 2026How to delay JavaScript until user interaction in WordPress
- WordPress.org Plugin Directory, updated 17 Oct 2026AI Engine – The Chatbot, AI Framework & MCP for WordPress
- Civil Resolution Tribunal of British Columbia, 14 Feb 2024Moffatt v. Air Canada, 2024 BCCRT 149
- GooglePageSpeed Insights