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 you | Chatbot plugin (runs in WordPress) | Hosted chatbot + snippet |
|---|---|---|
| Where the bot is built | wp-admin | The vendor's dashboard |
| Updates | Another plugin to keep updated | Vendor updates the widget; only the header and footer plugin (if used) to update |
| What runs on your server | The plugin's PHP code | Nothing; the widget loads in the visitor's browser |
| Reading your content | Some read posts and pages from your database | You add sources (Laddu Chat: one URL per page, PDFs, pasted text) |
| Moving to another tool | Uninstall; check for leftover settings or data | Delete two script tags |
| Same bot on a non-WordPress site | No | Yes, the same snippet works on any site |
| Client handover | The client's admins can change plugin settings | The client never touches the bot unless you share the dashboard |
| AI costs | Varies; some need your own AI provider key, billed separately | One 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 theme | Block theme | |
|---|---|---|
| Recommended | Header and footer plugin → Footer field | Header and footer plugin → Footer field |
| Without a plugin | Child theme footer.php, just before </body>, or functions.php with the wp_footer hook | Child theme functions.php with the wp_footer hook |
| Theme File Editor location | Appearance → Theme File Editor | Tools → Theme File Editor |
| Paste into the footer template there? | Only in a child theme's footer.php | No. 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 it | Editing the parent theme: an update overwrites it | Same, 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 ask | What a good answer looks like | If it fails |
|---|---|---|---|
| 1 | "What do you do?" | One or two accurate sentences | Add the home or about page |
| 2 | "How much does [main service] cost?" | The price from the pricing page or price list | Add the pricing page or paste the price list |
| 3 | "Are you open on Sunday?" | The real hours | Add the contact page or paste the hours |
| 4 | "Do you serve [a nearby town]?" | Yes or no, from the service area | Paste the service area as text |
| 5 | "How do I book?" | The actual booking steps or link | Add the booking page |
| 6 | "Can I get a refund?" | The policy, not a guess | Add the policy page |
| 7 | A typo, e.g. "how mutch for a consultaton" | Still answers correctly | Add a short text note in customers' own words |
| 8 | Something you don't offer | Says so and points to contact | Paste a short "what we don't offer" note |
| 9 | Off-topic, e.g. "Who won the World Cup?" | Stays on topic | Note 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)
-
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.

-
Go to Code Snippets → Header & Footer (boxes: Header, Body, Footer).
-
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.
-
Click Save Changes (top right). If you use a caching plugin, clear its cache.
-
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:

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.

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.comandstyle-src 'unsafe-inline', plus the inlinewindow.ladduConfigline: 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 withchatbotId 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.
| Setup | Plan | Monthly | Yearly billing | Answers / month | Laddu AI badge |
|---|---|---|---|---|---|
| One site, link shown | Starter | $20 | $200/yr | 2,500 | Shown |
| One site, link removed | Starter + Remove branding add-on | $44 ($20 + $24) | $200/yr + $24/mo | 2,500 | Removed |
| Up to three sites, link removed | Growth | $75 (about $25 per site across 3 sites) | $750/yr | 10,000 shared | Removed, included |
| Busier site | Any 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#
- WPCode, "Using the Global Header & Footer settings": Footer field "is printed just above the closing </body> tag"; chat widgets belong there; Save Changes button. https://wpcode.com/docs/using-the-global-header-footer-settings/ (checked 19 November 2026)
- WPCode on WordPress.org, listed as WPCode – Insert Headers and Footers, free: https://wordpress.org/plugins/insert-headers-and-footers/ (checked 19 November 2026)
- WordPress.com, "Install a plugin": "Installing plugins is available on all WordPress.com paid plans… For free sites, upgrade your plan." https://wordpress.com/support/plugins/install-a-plugin/ (checked 20 November 2026: "available on all WordPress.com paid plans: Personal, Premium, Business, and Commerce")
- WordPress Advanced Administration, "Editing Files": file editors under Tools for block themes and under Appearance for classic themes; theme updates overwrite changes; use a child theme. https://developer.wordpress.org/advanced-administration/wordpress/edit-files/ (checked 19 November 2026)
- WordPress documentation, "Block themes": block themes use blocks for header and footer, edited in the Site Editor. https://wordpress.org/documentation/article/block-themes/ (checked 19 November 2026)
- WordPress Developer Reference,
wp_footer: "Prints scripts or data before the closing body tag on the front end"; theme-dependent. https://developer.wordpress.org/reference/hooks/wp_footer/ (checked 19 November 2026) - Laddu Chat plans, credits, add-ons, sources, snippet, lead capture and limits: Laddu Chat product facts, verified against the product code on 8 November 2026. Live plans: /pricing
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.