WordPress Chatbot With API: Hook the Chat Into Your Theme, Logged-In Users and Orders With Copy-Ready Snippets

WordPress chatbot with API access means your own theme or plugin can talk to the chat, not just sit beside it. Open the chat from a menu button, pass a logged-in customer’s name, react when a lead arrives, or receive a webhook when a ticket is solved. This guide shows which hooks LiveChatBot gives you and the WordPress code to use them.

3ways in: JS API, REST API, webhooks
2webhook events: ticket.created and ticket.solved
₹0to use them, on the free plan

⚡ In short

  • The browser side is window.LiveChatBot: open, close, show, hide, setVisitor, sendMessage, pageView and on.
  • The server side is a REST API plus webhooks for ticket.created and ticket.solved.
  • In WordPress, add the browser calls through wp_footer or a small plugin, never by editing the theme core.
  • Ask the LiveChatBot team for developer documentation before you build anything heavy.
Wordpress chatbot with api in LiveChatBot: the one-line install code for WordPress, Shopify, Wix and other sites
How it looks in LiveChatBot: the one-line install code for WordPress, Shopify, Wix and other sites.

The map

Three doors into a WordPress chatbot with API support

Think of the integration as three doors, each for a different job.

Door 1: the JavaScript API

Runs in the visitor’s browser. Use it to open the chat from your own button, pass a name and email you already know, or listen for events such as a new lead. This is the door most WordPress owners need.

Door 2: the REST API

Runs on a server. Use it when your code must read or create records, for example syncing tickets with your own admin screen.

Door 3: webhooks

LiveChatBot calls your address when a ticket is created or solved. Use it to update an order note, email a manager or log the event. Zapier uses the same mechanism, which is why connecting chat to Zapier needs no code.

Step one

Install the plugin first, then add code on top

Install the WordPress plugin first. It loads the widget on every page, which also makes window.LiveChatBot available. Your code should only add behaviour on top.

Put custom code in a small site plugin or a code-snippets plugin, not in a theme you will update. That way a theme change never removes your integration.

A safe pattern is to hook into wp_footer, print a short script, and guard every call. The widget loads asynchronously, so your script must check that window.LiveChatBot exists before calling it. A missing guard is the number one cause of “it works on my machine” errors.

If you run a shop, the WooCommerce live chat guide covers the plugin side. This article covers what you add beyond it.

Browser side

Pass logged-in customers to the chat

When a customer is logged in, asking for their name again is a poor experience. WordPress already knows it. Print it into the page, then hand it to the chat.

What to pass

Name and email are enough for most sites. Do not pass passwords, order secrets or anything you would not show on screen. Escape every value with esc_js so a quote in a name cannot break the script.

Where to test

Log in as a test customer, open the chat and confirm the name appears in the inbox. Then log out and confirm nothing is left over. Our chat scripts page has wording ideas for the first message your visitor sees.

Try it

Copy-ready snippets

Each tab is one common job. Paste into a site plugin or a snippets plugin, change the values and test on a staging copy first.

<button onclick="if (window.LiveChatBot) { window.LiveChatBot.open(); }">Chat with us</button>
Tip: give any menu item a link to javascript:void(0) and add the same onclick to it.
add_action(‘wp_footer’, function () { if (!is_user_logged_in()) return; $u = wp_get_current_user();
echo ‘<script>window.addEventListener("load", function () { if (window.LiveChatBot) { window.LiveChatBot.setVisitor({ name: "’ . esc_js($u->display_name) . ‘", email: "’ . esc_js($u->user_email) . ‘" }); } });</script>’; });
If your theme loads pages without a full reload, call window.LiveChatBot.pageView() after each route change.
window.LiveChatBot.on(‘lead’, function () { /* send a note to your analytics */ });
add_action(‘rest_api_init’, function () { register_rest_route(‘mysite/v1’, ‘/chat-ticket’, [‘methods’ => ‘POST’, ‘callback’ => function ($r) { /* check a secret, then use $r->get_json_params() */ return [‘ok’ => true]; }, ‘permission_callback’ => ‘__return_true’]); });

Server side

Receive webhooks safely in WordPress

A webhook is a public address, so treat it like a front door.

Check who is calling

Add a long random secret to the address or a header, and reject any request without it. Keep the secret in wp-config.php, not in the page source.

Answer fast

Reply with a success code straight away and do heavy work later. A slow webhook can be retried or dropped.

Handle duplicates

The same event can arrive twice. Store the ticket ID you handled and ignore repeats.

Start with the events you have

LiveChatBot sends ticket.created and ticket.solved. A common use: when a ticket is solved, add a note to the matching WooCommerce order. Ask the team for the exact payload before you write the code. We do not publish developer docs on this site yet.

Worked example

A WordPress chatbot with API in action: from solved ticket to order note

Here is an illustrative flow for a small shop, invented only to show the method.

  1. A customer chats about a late parcel. Your agent turns the chat into a ticket.
  2. The agent solves it. LiveChatBot sends the ticket.solved webhook to your WordPress address.
  3. Your receiver checks the secret, finds the order number in the ticket details and adds a private note: “Chat ticket solved”.
  4. Next time anyone opens that order, the history is visible without leaving WordPress.

Why this helps

Your support history and your sales history sit in one place. Nobody has to copy and paste between tabs, and a new team member can see at a glance that the customer already got help.

Keep it small

Resist the urge to sync everything. One event, one action, tested well, beats five half-finished automations. Add the next one only when the first has run cleanly for a week.

Honest limits

What this WordPress chatbot with API setup does not do

Be clear before you build.

  • No native CRM apps. There is no built-in HubSpot, Salesforce or Zoho connector. Use Zapier, webhooks or the REST API.
  • No pre-chat form. You can pass details with setVisitor, but visitors are not forced to fill a form first.
  • No document upload for training. The AI Agent learns from facts you write in.
  • No white label. “Powered by LiveChatBot” stays on every plan.
  • Few webhook events. Only ticket.created and ticket.solved today.

If your project needs a missing piece, say so on a trial and ask the team, rather than assuming.

Costs and care

Performance, privacy and maintenance

Every extra script costs a little load time. Keep your code short and load it in the footer.

Privacy matters too. If you pass a logged-in customer’s email to the chat, say so in your privacy policy. In India, the DPDP Act 2023 expects clear notice about personal data you collect.

Finally, plan for updates. When WordPress, your theme or the plugin changes, re-run your short test: open the chat from the button, log in and check the name, trigger a test ticket and confirm the webhook arrived. A five-minute test after each update is cheaper than discovering a silent break from a customer. For a wider view of connections, see the integrations page, and the AI Agent page for how automatic answers fit in.

Frequently asked questions

Does LiveChatBot work as a WordPress chatbot with API access?

Yes. You get a browser JavaScript API, a REST API and webhooks for ticket.created and ticket.solved, plus the WordPress plugin.

Do I need to be a developer?

Not for the plugin or Zapier. A developer helps for custom snippets and webhook receivers.

Where do I put the code in WordPress?

In a small site plugin or a code-snippets plugin, hooked to wp_footer, so theme updates do not remove it.

Is the API free?

Yes, it is available on the free plan. Visitor limits still apply to the chat itself.

Where are the developer docs?

Ask the LiveChatBot team for developer documentation; the integrations page lists what is available.

Keep reading

Related guides

📘

WordPress Chatbot Installation: What Can Go Wrong in the First Hour, and the Pre-Flight and Verify Checklist That Prevents It

Read the guide →

🧭

WordPress Chatbot Integration: Four Layers of Connection, From the Plugin to Zapier, and Which Ones You Actually Need

Read the guide →

Build on a free chat

Free plan for two websites, with the JavaScript API, REST API and webhooks. Start free on livechatbot.in.