Guides

How to add a chatbot to your WordPress site: three methods

Three safe ways to put a chatbot on a WordPress site, from a no-risk snippet plugin to a child theme function, with a clear rule for choosing and a test checklist.

By the Askocto team · · 4 min read

You can add a chatbot to WordPress in three ways: paste the embed script through a header and footer snippet plugin, add it to your theme's footer, or load it with a function in a child theme. The plugin method is the safest for most people, because a theme update will not remove it. This guide explains each method, how to choose and how to test afterwards.

In short: Use a snippet plugin unless you have a reason not to. Take a backup first, and test in a private window on desktop and phone.

Before you start

Make two preparations, whichever method you choose.

  1. Back up the site. Use your host's backup tool or a backup plugin. A one-line change is low risk, and a backup makes it zero.
  2. Have the chatbot ready. Train it on your content and test a few conversations before the widget goes live. The guide to training an agent on your help center covers this.

Then copy your embed script. In Askocto, you find it in your agent under Channels. It is one line, in this form:

<script src="https://cdn.askocto.co/embed.js" data-agent-id="agt_123" defer></script>

Which method should you use?

Method Best for Survives theme updates Skill needed
Snippet plugin Most sites Yes None
Theme footer edit Quick tests, themes you will never change No Low
Child theme function Developers, tighter control Yes Moderate

This keeps the code out of your theme and makes it easy to switch off.

  1. In the WordPress dashboard, choose Plugins, then Add New.
  2. Search for a plugin that inserts code in the header or footer. Pick one that is actively maintained and has many installs, and read its recent reviews.
  3. Install and activate it.
  4. Open the plugin's settings and find the Footer (or "before closing body") box.
  5. Paste the embed script and save.

The defer attribute in the script lets the page load first, so the footer is a fine place for it.

This works, but updating the theme will usually overwrite your change. Use it only for a quick test.

  1. Go to Appearance, then Theme File Editor.
  2. Open footer.php.
  3. Paste the script just before the closing body tag.
  4. Click Update File.

If your host disables the editor, you will need file access over SFTP. Make a copy of the file before you change it, so you can restore it.

Method 3: a function in a child theme

A child theme holds your changes apart from the parent theme, so updates do not touch them. Add this to the child theme's functions.php:

function add_support_chatbot() {
  echo '<script src="https://cdn.askocto.co/embed.js" data-agent-id="agt_123" defer></script>';
}
add_action('wp_footer', 'add_support_chatbot');

Replace the agent id with yours. If you are not comfortable with PHP, use Method 1. A syntax error in functions.php can take the site down, which is why the backup comes first.

Test it properly

Open the site in a private window so caches and logged-in states do not hide problems.

  1. The bubble appears on the home page, a product page and the checkout.
  2. A real question gets a right answer from your content.
  3. A question outside your content gets an honest "I am not sure" and an offer of a person.
  4. The window opens and closes on a phone and does not cover a cookie banner.
  5. With a caching plugin, clear the cache after you add the script.

If you run an online shop on WooCommerce, check the cart and checkout pages carefully, and consider hiding the chatbot on payment pages. The guide to AI customer support for Shopify stores discusses store-specific questions that apply to other shop platforms too.

Troubleshooting

  • Nothing shows. Clear the site cache and your browser cache, then check the page source for the script. If it is missing, the plugin setting did not save.
  • It shows twice. The script is in two places, perhaps a plugin and the theme. Remove one.
  • A security or consent plugin blocks it. Add the script's domain to allowed sources, or load it after consent.
  • A layout shift. Test with other floating widgets switched off. Only keep one bubble.
  • Slow page. Check the load with and without the script. The defer attribute should keep the impact small.

Show it where it helps

Many sites do better when the chatbot is on pricing, product and help pages and absent from sensitive pages. Most snippet plugins let you pick pages, or you can control the widget through the JavaScript object that the script provides. The website integration docs list the options for opening, closing and passing context.

When you are satisfied, review the first week of conversations and add missing answers to your content. For the same job on another builder, read how to add a chatbot to your Wix website. To try the chatbot itself, you can sign up for a free Askocto workspace.

Frequently asked questions

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

No, you can edit the theme footer or use a child theme function. A snippet plugin is simply the safest option because theme updates will not remove it.

Will a chatbot slow down my WordPress site?

A script with defer loads after the page content, so the effect is usually small. Measure before and after, and remove other widgets you do not use.

Can I show the chatbot on only some pages?

Yes. Many snippet plugins let you target pages or post types, or you can control the widget with open and close calls in your own code.

What should I do if the chatbot does not appear?

Clear your caches, check the page source for the script and make sure the agent id is correct. Look for a security or consent plugin that blocks outside scripts.

Train an agent on your own help center

Askocto answers the repeat questions across chat, email and voice and hands the hard ones to your team.

Keep reading

All articles
Guidesadd a chatbot to your wix website
Feb 28, 20255 min read

How to add a chatbot to your Wix website in 10 minutes

Adding a chatbot to Wix takes one pasted script. Follow the steps to train your agent, add the code, test on desktop and mobile, and fix the usual problems.

Read article
Guidesconnect ai agent helpdesk crm
Oct 27, 20267 min read

Connect an AI agent to your helpdesk and CRM: what to sync

Connecting an AI agent to your helpdesk and CRM is four decisions: what it reads, what it writes back, which actions it may take and how you prevent duplicates. Here is how to make each one.

Read article
Guidesembed ai chat widget
Oct 22, 20267 min read

Embed an AI chat widget on any site: what to decide first

Seven decisions to settle before you embed an AI chat widget: its job, placement, triggers, greetings, mobile behavior, speed and accessibility. No code, works on any site.

Read article