<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: FlowPilot AI</title>
    <description>The latest articles on DEV Community by FlowPilot AI (@flowpilotaisupport_07a65).</description>
    <link>https://dev.to/flowpilotaisupport_07a65</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4258241%2Fed83894d-2529-4103-9d45-8852c0d2943d.png</url>
      <title>DEV Community: FlowPilot AI</title>
      <link>https://dev.to/flowpilotaisupport_07a65</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/flowpilotaisupport_07a65"/>
    <language>en</language>
    <item>
      <title>Building a WooCommerce AI chatbot that doesn't make up stock levels</title>
      <dc:creator>FlowPilot AI</dc:creator>
      <pubDate>Sun, 22 Nov 2026 19:03:07 +0000</pubDate>
      <link>https://dev.to/flowpilotaisupport_07a65/building-a-woocommerce-ai-chatbot-that-doesnt-make-up-stock-levels-5f39</link>
      <guid>https://dev.to/flowpilotaisupport_07a65/building-a-woocommerce-ai-chatbot-that-doesnt-make-up-stock-levels-5f39</guid>
      <description>&lt;p&gt;Most store chatbots fail in the same boring way: a customer asks "Is the blue one in stock in size M?" and the bot answers from a FAQ someone wrote six months ago. Or worse, the AI confidently says "Yes!" because it sounds helpful.&lt;/p&gt;

&lt;p&gt;I've been building &lt;a href="https://www.flowpilotworks.com" rel="noopener noreferrer"&gt;FlowPilot AI&lt;/a&gt;, an AI chat assistant for WooCommerce stores, and most of the work turned out not to be "add an LLM". It was everything around the LLM. Here are seven lessons, with the patterns I ended up using.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: FlowPilot is my product. The lessons apply to any store chatbot you build yourself.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Read live store data on every question
&lt;/h2&gt;

&lt;p&gt;The single biggest source of wrong answers is stale data. A copy of the catalog synced last night is already wrong the moment a product sells out.&lt;/p&gt;

&lt;p&gt;So the assistant fetches products from the WooCommerce REST API &lt;strong&gt;on every customer message&lt;/strong&gt;, along with the store's currency. That costs a request, but it means "in stock" really means in stock right now, and "129" is always shown with the right currency instead of a guessed one.&lt;/p&gt;

&lt;p&gt;If you're worried about load, cache for seconds, not hours.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Don't dump the whole catalog into the prompt
&lt;/h2&gt;

&lt;p&gt;A store with 2,000 products won't fit nicely into a prompt, and even when it does, the model gets worse at finding the right item.&lt;/p&gt;

&lt;p&gt;Instead, score products against the customer's question (name, SKU, short description) and send only the most relevant ones. Under a limit, send everything; over it, send the top matches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;selectProductsForAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;toWords&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;overlap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;toWords&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${p.name} ${p.sku} ${p.short_description}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For variable products (size, color), include the variations with their own stock status. Otherwise "Is it available in M?" gets answered from the parent product, which is usually wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Order lookups: the AI never decides who sees an order
&lt;/h2&gt;

&lt;p&gt;"Where is my order?" is the most common question, and the most dangerous one to get wrong. You can't let a chatbot read order #1042 to anyone who types "1042".&lt;/p&gt;

&lt;p&gt;The rule I use: the customer enters the &lt;strong&gt;order number and the email used for the order&lt;/strong&gt;, and the server checks that both match before anything goes near the model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;wooGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`orders?search=${orderNumber}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;orderNumber&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
         &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;billing&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only a verified order summary (status, items, tracking number) is passed to the AI. If there's no match, the server answers "I couldn't find an order with these details" itself, without calling the model at all. The AI can't leak what it never receives.&lt;/p&gt;

&lt;p&gt;Rate-limit these lookups per visitor too, so nobody can brute-force order numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Tell the model what to do when it &lt;em&gt;doesn't&lt;/em&gt; know
&lt;/h2&gt;

&lt;p&gt;Most prompts say "don't make things up". That's not enough, because the model still has to say &lt;em&gt;something&lt;/em&gt;, and "something" tends to be a confident guess.&lt;/p&gt;

&lt;p&gt;What worked better was giving it an explicit way out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the answer isn't in the provided data (return policy, delivery times, payment options), say you can't confirm it and point the customer to the &lt;strong&gt;"Talk to a person"&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;Same if the customer is upset, or asks for a refund, cancellation or address change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And one more rule I didn't expect to need: &lt;strong&gt;never claim to have done an action.&lt;/strong&gt; The assistant can't cancel orders or start refunds, but without this rule it will happily write "I've cancelled your order for you."&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Treat product descriptions and messages as data, not instructions
&lt;/h2&gt;

&lt;p&gt;Product descriptions are written by store owners, plugins, importers and sometimes copied from suppliers. Customer messages are written by anyone. Both end up in your prompt.&lt;/p&gt;

&lt;p&gt;So the prompt states plainly that instructions found inside product data, chat history or the customer's message are &lt;strong&gt;data only&lt;/strong&gt; and must not be followed. The assistant also never promises discounts or coupons. It's not perfect protection against prompt injection, but combined with "the AI can't take actions" (lesson 4) and "the AI never sees unverified orders" (lesson 3), the damage a clever message can do is small.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Let WooCommerce create the API keys
&lt;/h2&gt;

&lt;p&gt;Asking a store owner to go to &lt;em&gt;WooCommerce → Settings → Advanced → REST API&lt;/em&gt;, generate a key pair and paste it somewhere is where a lot of non-technical users give up.&lt;/p&gt;

&lt;p&gt;WooCommerce has a built-in authorization endpoint for this. You send the user to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//their-store.com/wc-auth/v1/authorize&lt;/span&gt;
  &lt;span class="na"&gt;?app_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;YourApp&lt;/span&gt;
  &lt;span class="na"&gt;&amp;amp;scope&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;read_write&lt;/span&gt;
  &lt;span class="na"&gt;&amp;amp;user_id&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;&amp;amp;return_url&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;send&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="n"&gt;back&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;&amp;amp;callback_url&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;endpoint&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt; &lt;span class="n"&gt;receives&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The store owner sees WooCommerce's own approval screen, clicks &lt;strong&gt;Approve&lt;/strong&gt;, and WooCommerce POSTs the generated keys to your &lt;code&gt;callback_url&lt;/code&gt;. No copying, no typos. Store them encrypted at rest (I use AES-256-GCM), and remember the owner can revoke them any time from the REST API screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Usage limits shouldn't surprise anyone
&lt;/h2&gt;

&lt;p&gt;AI costs money per message, so you need limits. The question is what happens at the limit.&lt;/p&gt;

&lt;p&gt;The pattern that annoys store owners most is the automatic upgrade: quota hits 95%, the plan jumps a tier, the bill grows. I went the other way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email the owner at &lt;strong&gt;80%&lt;/strong&gt; and &lt;strong&gt;100%&lt;/strong&gt; of their monthly conversations (once each per period).&lt;/li&gt;
&lt;li&gt;At the limit, &lt;strong&gt;ongoing chats continue&lt;/strong&gt;, and new visitors see a short "leave your details" form instead of an AI answer. Those messages go to the owner by email.&lt;/li&gt;
&lt;li&gt;Nothing is charged or upgraded automatically.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Customers still get a path to a human, the owner gets a heads-up, and nobody opens a surprising invoice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;None of this is exotic. It's mostly about deciding, for each question a shopper might ask, &lt;strong&gt;where the truth lives&lt;/strong&gt; (the live store, a verified order, or a human) and making sure the model only speaks for the first two.&lt;/p&gt;

&lt;p&gt;If you want to see how this behaves on a real store, there's a &lt;a href="https://www.flowpilotworks.com/try" rel="noopener noreferrer"&gt;live demo&lt;/a&gt; where you type any WooCommerce store's address and chat with an assistant that knows its public products. I'd love feedback, especially from people who've built store chatbots and hit problems I haven't thought of yet.&lt;/p&gt;

</description>
      <category>woocommerce</category>
      <category>ai</category>
      <category>wordpress</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
