Grounding a WooCommerce AI chatbot in real store data

<?php
function bbioon_assistant_reply( string $question ): string {
    return $assistant->complete( $question );
}

The return type is the problem. A WooCommerce AI chatbot built like this turns a guess into store policy: the model predicts some text, the function hands the theme one string, and the theme prints it. There’s no source behind it, no confidence number, and no route to a human when the guess is wrong.

A Canadian tribunal ruled on this exact setup in 2024. A customer asked Air Canada’s chatbot about bereavement fares, and the bot described a refund process that did not exist. The tribunal ordered the airline to pay, reasoning that it makes no difference whether information comes from a static page or a chatbot. The BBC covers the ruling in detail, and Smashing Magazine’s Designing With Uncertainty builds its whole argument on the case. It names the failure in one phrase:

probabilistic systems wrapped in deterministic interfaces

The design advice holds up: keep uncertainty visible, keep a human fallback, label machine output. I’d add the developer half, because the wrapper is our function. If you ground the model in store data before the question reaches it, the only probabilistic thing left is the phrasing.

Ground a WooCommerce AI chatbot in catalog data

A chatbot on a store should be allowed to rephrase facts, not recall them from training data. That means retrieval before generation. Three steps in code:

  1. Run a real query first, so names, prices, and stock levels come from the database.
  2. Put only those facts in the prompt, with an instruction to use nothing else.
  3. If the query returns nothing, do not call the model at all. Return a canned reply.
$products = wc_get_products( array( 's' => $question, 'limit' => 5 ) );

if ( empty( $products ) ) {
    // no results, no model call
    return "I couldn't find that in the catalog. Email us and a person will answer.";
}

$facts = array();
foreach ( $products as $product ) {
    $facts[] = sprintf(
        '%s, %s, %s',
        $product->get_name(),
        wp_strip_all_tags( wc_price( $product->get_price() ) ),
        $product->get_stock_quantity() ?? 'stock not tracked'
    );
}

$prompt = 'Answer only from these entries: '
    . implode( '; ', $facts )
    . '. If the answer is not in the list, say you do not know.';

The guard clause is the part most plugins leave out. They call the model no matter what, so an empty result becomes room to improvise, and that is how a store ends up promising a refund window nobody approved. I’ve written about getting client stores ready for WooCommerce AI workflows before, and grounding is the step that setup skips most often.

Policy questions get a canned answer

Catalog grounding handles “is this in stock”. The Air Canada failure was a policy question. Refund windows, shipping rules, warranty terms: render those from a page the owner maintains and let the model summarize at most. The WooCommerce terms page is one call away with wc_get_page_permalink( ‘terms’ ), and an empty return means the assistant has no terms answer to give. Saying so and linking to a contact page is correct behavior. Letting the model fill the gap is what the airline’s bot did.

Confidence scores are not calibrated

The article suggests showing confidence levels so skeptical users can calibrate their trust. But a model’s self-reported score isn’t calibrated: a 90% badge on a chat answer is decoration, and a 40% answer can still be the right one. A trained model is not a risk score yet, and its confidence number isn’t one either. Show ranges a store can honor, like a two to four day shipping window, and link the policy page next to anything that touches money. WooCommerce’s own chatbot documentation takes a similar line: responses can be inaccurate, compliance sits with the store owner, and human takeover is recommended for sensitive conversations.

Write the low-confidence path first

The article asks what the interface does when the AI is not sure. On a WordPress build, that comes down to three paths you can test with the model switched off: the API call times out, retrieval finds nothing, or the question has no policy behind it. Each needs a canned response and a route to a human. Log every handoff with the question attached and read them weekly; unanswered questions are your next FAQ entries. I’m not sure this holds at high chat volume, but that’s not the store most of us build for.

What I’d change on a client store this week

I’d pick one store with an assistant on it and read the code that calls the model: find where the empty-result guard is missing, add it, and add one line to the prompt that forbids inventing policy. Then I’d wire the handoff log. If your store runs a WooCommerce AI chatbot and you want that pass done properly, this is the kind of work I do. The first audit usually fits in an afternoon.

author avatar
Ahmad Wael
I'm a WordPress and WooCommerce developer with 15+ years of experience building custom e-commerce solutions and plugins. I specialize in PHP development, following WordPress coding standards to deliver clean, maintainable code. Currently, I'm exploring AI and e-commerce by building multi-agent systems and SaaS products that integrate technologies like Google Gemini API with WordPress platforms, approaching every project with a commitment to performance, security, and exceptional user experience.

Leave a Comment