Add an AI chatbot to WordPress, trained on your content

Train an AI chatbot on your pages, PDFs and text, then paste a two-tag snippet into WordPress. Steps for block and classic themes, plus the cost.

To add an AI chatbot to WordPress that answers from your own content, build a hosted bot, give it your pages, PDFs and text as sources, then paste its two-tag script snippet into the Footer field of a header and footer plugin such as WPCode. That works on block and classic themes and survives theme updates.

Steps 1 to 3 happen in the chatbot dashboard; Step 4 is the WordPress part. Already have a snippet? Skip to Step 4. We make Laddu Chat and use it below; the placement rules and test script work for any snippet-based chatbot.

What does "trained on your content" mean for a WordPress chatbot?#

Nobody retrains an AI model on your site. The bot keeps a searchable copy of the sources you give it, finds the passages that match a visitor's question, and writes the answer from them. So:

  • The bot only knows what you add. No returns policy source, no good returns answer.
  • Sources go stale. Change a price and the bot keeps the old copy until you refresh that source.

In Laddu Chat you train your bot on web pages (add each URL), PDFs up to 10MB, and pasted text.

The limit: there's no sitemap or whole-site import. Each URL adds one page, so a 50-page site means 50 URLs, and a 300-post blog means 300. If the bot must answer from every post, a plugin that reads your WordPress database (compared below) may suit you better. Otherwise add the pages people ask about first: pricing, main services, booking, contact and refund terms.

Plugin or snippet: which should you use?#

A chatbot plugin runs inside WordPress and talks to an AI service. A hosted chatbot is built elsewhere and added with a script snippet. Pick a plugin for one content-heavy site where the bot must answer from hundreds of posts. Pick a hosted snippet if you look after several client sites, some not on WordPress, and don't want another PHP plugin in every care plan.

What matters to youChatbot plugin (runs in WordPress)Hosted chatbot + snippet
Where the bot is builtwp-adminThe vendor's dashboard
UpdatesAnother plugin to keep updatedVendor updates the widget; only the header and footer plugin (if used) to update
What runs on your serverThe plugin's PHP codeNothing; the widget loads in the visitor's browser
Reading your contentSome read posts and pages from your databaseYou add sources (Laddu Chat: one URL per page, PDFs, pasted text)
Moving to another toolUninstall; check for leftover settings or dataDelete two script tags
Same bot on a non-WordPress siteNoYes, the same snippet works on any site
Client handoverThe client's admins can change plugin settingsThe client never touches the bot unless you share the dashboard
AI costsVaries; some need your own AI provider key, billed separatelyOne subscription, counted in the vendor's credits

Where should the snippet go? Block themes vs classic themes#

The "edit footer.php" advice in older guides only fits classic themes.

Classic themeBlock theme
RecommendedHeader and footer plugin → Footer fieldHeader and footer plugin → Footer field
Without a pluginChild theme footer.php, just before </body>, or functions.php with the wp_footer hookChild theme functions.php with the wp_footer hook
Theme File Editor locationAppearance → Theme File EditorTools → Theme File Editor
Paste into the footer template there?Only in a child theme's footer.phpNo. Site Editor changes in the database override the file, and a theme update overwrites it
Site Editor option–Footer template part → Custom HTML block. Works, but belongs to that theme
What breaks itEditing the parent theme: an update overwrites itSame, and switching themes drops a Site Editor change

WordPress's documentation puts the file editors under Tools for block themes and under Appearance for classic themes, and warns: "if the theme you edit is updated, your changes will be overwritten". So if the Theme File Editor is under Tools, it's a block theme. The plugin route works the same on both, which is why we recommend it.

Step 1: How do you train the chatbot on your WordPress pages?#

Create a free Laddu Chat account (100 free credits, no card) and add sources in roughly this order:

Sources checklist for a typical business site

  • Home page
  • Each services or product page (one URL each)
  • Pricing page, or a pasted-text price list if prices aren't on the site
  • Contact page: address, phone, opening hours, service area
  • FAQ page
  • Booking, delivery or ordering page: how it works and lead times
  • Policies: returns, refunds, cancellations, warranty
  • About page (who you are, credentials, years in business)
  • PDFs people ask about: brochure, menu, price list, product manual (with selectable text, up to 10MB each)
  • Pasted text for answers that aren't written down anywhere yet: "Do you work weekends?", "Do you take card payments?"

Leave out old blog posts that mention prices or offers: if a 2019 post with old rates is a source, the bot can quote them.

Step 2: How do you make the chat widget match your WordPress theme?#

  • Colours: use the theme's button and header hex codes for the brand, header and launcher colours.
  • Launcher position: it can't be moved. After embedding, check on a phone that it doesn't cover the mobile menu, a call button, a cookie banner or a floating WhatsApp button; if it does, move the other element.
  • Welcome message: up to 500 characters. "Hi! Ask me about our services, prices or booking."
  • Suggested questions: up to 10 that visitors can tap. Use real questions from your inbox.
  • Avatar: an image up to 1.4MB, such as the logo.

If you want leads, turn on Lead Collection fields (name, email or phone) and set a Support Email in Configure. Every plan then captures leads and emails them to you; Growth and Scale add a Leads dashboard and CSV export.

Step 3: How do you test the chatbot before embedding it on WordPress?#

Ask these 10 questions in the bot's preview, with the client's details swapped in.

#Question to askWhat a good answer looks likeIf it fails
1"What do you do?"One or two accurate sentencesAdd the home or about page
2"How much does [main service] cost?"The price from the pricing page or price listAdd the pricing page or paste the price list
3"Are you open on Sunday?"The real hoursAdd the contact page or paste the hours
4"Do you serve [a nearby town]?"Yes or no, from the service areaPaste the service area as text
5"How do I book?"The actual booking steps or linkAdd the booking page
6"Can I get a refund?"The policy, not a guessAdd the policy page
7A typo, e.g. "how mutch for a consultaton"Still answers correctlyAdd a short text note in customers' own words
8Something you don't offerSays so and points to contactPaste a short "what we don't offer" note
9Off-topic, e.g. "Who won the World Cup?"Stays on topicNote it; read real conversations after launch
10"I'd like a quote, can someone call me?"Asks for contact details (if lead fields are on)Add lead fields in Configure

Fix each failure with a source, often a two-sentence text note answering that exact question: Add Text Source for a new note, Process URLs for a new page, Update and Retrain for an edited note. Then ask again. Don't embed until the first six pass: a wrong price or refund answer is what a client screenshots and sends you.

Step 4: How do you paste the chatbot snippet into WordPress?#

Open the bot and go to Settings → Embed Scripts, then click Copy Script. A Preview button sits next to it. The snippet is two script tags:

<script>window.ladduConfig = { chatbotId: "<your-bot-id>" };</script>
<script src="https://chat.laddu-ai.com/embed.js" defer></script>

Copy both, in this order. They go just before </body>, as Laddu Chat's embed screen asks, and every method below puts them there. <head> also works if a tool has no footer field.

With WPCode (any theme, recommended)

  1. Plugins → Add New, search for WPCode, install and activate (free). Pick the card titled "WPCode – Insert Headers and Footers + Custom Code Snippets", not the other WPCode plugins in the results.

    WordPress Add Plugins screen searched for "wpcode", showing the WPCode – Insert Headers and Footers card by Syed Balkhi with 3+ million active installations

  2. Go to Code Snippets → Header & Footer (boxes: Header, Body, Footer).

  3. Paste the snippet into the Footer box. WPCode prints it "above the closing </body> tag", and its docs list live chat widgets as the kind of script that belongs there.

    WPCode Global Header and Footer screen with the two Laddu Chat script tags pasted into the Footer box, above the note "These scripts will be printed above the closing </body> tag"

  4. Click Save Changes (top right). If you use a caching plugin, clear its cache.

  5. Open the site in a private window and check the launcher appears on several pages. On a fresh Twenty Twenty-Five install it sits bottom right, with the bot's welcome message above it:

    Twenty Twenty-Five front page with the round chat launcher in the bottom-right corner and a welcome bubble above it, loaded by the WPCode footer snippet

    Screenshots from a throwaway WordPress Playground site, 20 November 2026. The widget shown is Laddu's own site bot; yours shows your welcome message.

With the Site Editor (block themes, no plugin)

Appearance → Editor → Patterns → Footer (under Template Parts): add a Custom HTML block, click Edit code, paste, click Update, then Save. WordPress rewrites defer as defer="", which works the same. Two catches: it only loads on pages whose template uses that footer part, and it disappears if you switch themes. WPCode avoids both.

WordPress Site Editor editing the Twenty Twenty-Five Footer template part, with the Custom HTML block's Edit code dialog open and the two Laddu Chat script tags pasted in

Without a plugin (child theme)

In a child theme's functions.php, print the snippet on the wp_footer hook, which WordPress describes as printing "scripts or data before the closing body tag on the front end". Replace the bot ID with your own:

add_action( 'wp_footer', function () {
    ?>
    <script>window.ladduConfig = { chatbotId: "<your-bot-id>" };</script>
    <script src="https://chat.laddu-ai.com/embed.js" defer></script>
    <?php
} );

The hook is theme-dependent; almost every theme calls wp_footer(). On a classic theme you can instead paste the snippet just before </body> in the child theme's footer.php. Never edit the parent theme: its next update wipes the change.

If the widget doesn't show#

  • Cache: clear the caching or optimisation plugin's cache and your CDN's cache.
  • Script optimisation: exclude the snippet from any setting that combines, defers or delays JavaScript.
  • Both tags: check that both script tags are there, in the same order.
  • Embedding switch: check that Enable embedding on website is on (Settings → Embed Scripts).
  • Strict CSP: if the site sends a Content Security Policy, allow script-src https://chat.laddu-ai.com, connect-src https://chat-api.laddu-ai.com, frame-src https://chat.laddu-ai.com and style-src 'unsafe-inline', plus the inline window.ladduConfig line: allow it with a hash or a nonce, or move it into a .js file on your own domain (see the CSP section of the HTML guide). Without that, the widget fails with chatbotId is missing. The chat window itself is an iframe.

How much does an AI chatbot on WordPress cost per month?#

Laddu Chat's plans, in USD. Every answer uses 1 credit, and credits are per account, shared by all bots.

SetupPlanMonthlyYearly billingAnswers / monthLaddu AI badge
One site, link shownStarter$20$200/yr2,500Shown
One site, link removedStarter + Remove branding add-on$44 ($20 + $24)$200/yr + $24/mo2,500Removed
Up to three sites, link removedGrowth$75 (about $25 per site across 3 sites)$750/yr10,000 sharedRemoved, included
Busier siteAny paid plan + extra credits+$15 per 1,000 credits a month–+1,000 each–

One credit is one answer, however long; visitors who don't ask anything cost nothing. The 100 free credits cover about ten runs of the test script. Starter's 2,500 is about 80 answers a day. Growth's 10,000 is about 3,300 per site across three evenly busy sites. Scale ($250 a month) shares 40,000 across up to 50 bots. Extra-credit packs stack.

If an account runs out of credits, the bot goes offline but still captures an email if a visitor types one. Watch Credits Used in the sidebar in the first month. For a freelancer's care plan, Growth is the cheaper way to cover two or three client sites without the Laddu link. Full list on the pricing page.

Know the limits before you pitch it to a client: Laddu Chat answers from your sources and passes leads on by email. It isn't a helpdesk. There's no live chat or human handoff (when the bot can't answer, it says so instead of guessing and points visitors to your Support Email, or offers to take their details if lead fields are on), no WhatsApp or Messenger, and no Zapier, HubSpot or webhooks. Badge removal hides only the Laddu AI badge. The widget still loads from chat.laddu-ai.com, owner emails are Laddu-branded, and there are no client sub-accounts or client billing.

How do you keep the chatbot's answers accurate after launch?#

  • Read the conversations weekly. Every plan shows each conversation and today's or the last 7 days' activity. Bad answers tell you which source to add next.
  • Refresh after edits. When a page changes, clear your cache plugin (WP Rocket, LiteSpeed Cache and the like) and CDN cache first, so the bot doesn't read the old page. Then click Recrawl on that page source and Retrain. There's no automatic refresh, so add it to your publishing checklist.
  • Re-run the test script after big site changes, such as a redesign, a new price list or new services.

Sources#

Frequently asked questions#

Do I need a WordPress plugin to add an AI chatbot?

No. A hosted chatbot is a short script snippet, and WordPress only has to print it before the closing </body> tag. The easiest way to do that is a header and footer plugin such as WPCode (free on WordPress.org). If you'd rather not add a plugin, a child theme can print the snippet through the wp_footer hook.

Will the chatbot read every page of my WordPress site automatically?

Not with Laddu Chat. There's no sitemap or whole-site import: you add each page as its own URL, so a 50-page site means adding 50 URLs. You can also add PDFs up to 10MB (with selectable text) and pasted text up to 100,000 characters.

Does it work with block themes like Twenty Twenty-Five?

Yes. Paste the snippet into the Footer field of a header and footer plugin such as WPCode, which works the same on block and classic themes. Without a plugin, use a child theme's functions.php and the wp_footer hook. Don't paste it into a block theme's template files: theme updates and Site Editor changes override them.

Can I add the chatbot to a WordPress.com site?

Yes, if your plan lets you install plugins. WordPress.com says installing plugins is available on all its paid plans; free sites must upgrade first.

How much does it cost to run an AI chatbot on one WordPress site?

With Laddu Chat, $20 a month on Starter (one bot, 2,500 answers a month, with a Laddu AI badge), $44 a month with the $24 badge-removal add-on, or $75 a month on Growth, which covers three bots with the badge removed. You start with 100 free credits, no card; paid plans start at $20 a month. Prices in USD.

How do I keep the bot's answers up to date when I edit a page?

Sources don't refresh on their own. After you change a page, clear your page and CDN cache, click Recrawl on that page source, then click Retrain. For a changed PDF, delete the old one, upload the new one and retrain; for pasted text, edit the source.