How to add a custom AI chatbot to your Shopify store
· 7 min read
Most of the questions a Shopify store gets are the same few, asked again and again: does it come in my size, how long does delivery take, can I return it? An AI chat assistant can answer them at any hour, from your own product and policy pages, so shoppers get an answer before they leave and you get fewer emails.
You don't need an app or a developer to add one. Most AI chat assistants, ours included, are added with a single line of code, a script tag, pasted once into your theme. This guide uses Pixexl's assistant as the example, but the steps are the same for most chat tools that give you a script tag.
Before you start
You'll need three things:
- Access to your store's themes. The store owner, or a staff account with the Themes permission.
- Your chat's embed code. In Pixexl, it's on your project's Settings tab, under the integration code. It looks something like this:
<script
src="https://…/pixe-widget.js"
data-project-id="your-project-id"
data-api="https://…"
async
></script>
- Your store's domain added to the project. For security, the chat only runs on domains you've allowed. Add your store's own domain, and its
yourstore.myshopify.comaddress too if you want to test there or haven't connected a domain yet.
Before it goes live, give the assistant something to answer from. Add your home page, your shipping and returns policies, your FAQ and your size guide as its knowledge (see What to give your AI assistant so it answers well).
Chatbot app or embed code?
The Shopify App Store has plenty of chatbot apps. An embed code works differently: the chat runs on the provider's service, and your theme only loads one small script.
- An embed code adds nothing to your store but that one line: no app permissions, no app blocks to configure on every template, and it keeps working if you move to another platform. The assistant's knowledge, forms and conversations live in its own dashboard.
- A chatbot app can make sense if you want it to read your orders or catalogue from the Shopify admin, but it asks for access to your store's data, and it usually works only on Shopify.
If what you need is an assistant that answers your shoppers' questions from your own pages, the embed code is the simpler choice. That's what the rest of this guide sets up.
Add the code to theme.liquid
theme.liquid is the layout every page of your store is built on, so code you add there appears on every page.
- In your Shopify admin, go to Online Store → Themes.
- Next to your live theme, open the … menu and choose Duplicate. This keeps a copy to go back to if anything goes wrong.
- On your live theme, open the … menu again and choose Edit code.
- In the Layout folder, open theme.liquid.
- Find the closing
</body>tag, near the end of the file, and paste your embed code just above it. - Choose Save.
Open your store in a new tab and the chat button should appear in the corner.
If you'd rather try it first, do the same on the duplicate instead, and use Preview to check it before you publish that theme. Preview addresses aren't your store's domain, so add the preview's domain to the project while you test.
When you change or update your theme
The code lives in your theme, so it stays with that theme:
- Updating your theme to a new version from the Theme Store gives you a fresh copy of its files, without your edits. Paste the embed code into the new version's
theme.liquidbefore you publish it. - Switching to a different theme works the same way: add the code to the new theme before you make it live.
It's a 30-second job, but it's easy to forget. If the chat disappears after a theme change, this is why.
Will it clash with my theme?
It shouldn't. The chat draws itself in its own sealed-off area of the page, so your theme's styles can't change how it looks, and its styles can't leak into your store. Its colours, greeting and position come from the Widget tab in your Pixexl dashboard, so you can change them later without touching your theme again.
One thing to look at: many themes put their own buttons in a bottom corner, a "back to top" arrow or another app's badge. If one sits where the chat button does, move the chat to the other corner in the Widget tab.
Cookie consent
The chat remembers a shopper's conversation in their browser, so it's covered by your cookie rules. You have two choices:
- Use the chat's own cookie notice. It's on by default and asks the visitor before the chat stores anything. You can link it to your privacy policy from the Widget tab.
- Use your existing cookie banner. If you already run Shopify's cookie banner or a consent app, you can turn the chat's notice off, add
data-consent="pending"to the script tag, and have your consent tool callPixeWidget.grantConsent()when the shopper agrees. Your consent app's documentation will say where to put that kind of callback.
Pick one, not both. Two cookie pop-ups on one page annoys everyone.
It's not showing up: what to check
- The wrong theme. Check you edited the theme that's live (it's the one at the top of Online Store → Themes), not a draft or the duplicate.
- The code landed in the wrong place. It must be inside
theme.liquid, before</body>, not in a section or snippet that only some templates use. - The domain. If you're looking at the store on its
myshopify.comaddress or a theme preview, that address needs to be in the project's allowed domains. - The chat is switched off. Check that "Show the chat on my site" is on in the Widget tab.
- A typo in the code. Copy the embed code again from the Settings tab rather than retyping it.
If it still won't appear, open your browser's developer console (right-click, Inspect, then Console). The chat leaves a short message there explaining why it didn't load.
After it's live
Installing the chat is the quick part. The part that makes the difference is the first couple of weeks after:
- Ask it what your shoppers ask: delivery times, returns, sizes, care instructions. See how it does.
- Read the real conversations once a week. Any question it fumbles points to something missing from your store's pages.
- Add forms, so a question about an order or a custom request turns into an enquiry you can answer, without the shopper leaving the chat (see How to turn website chats into bookings and enquiries).
Every Pixexl plan includes the assistant, and your first 2 weeks are free, so you can try it on your store with real shoppers before you decide. Meet Pixe AI to see what it can do.
Shopify chatbot questions
Do I need a Shopify chatbot app?
No. An app from the Shopify App Store isn't needed: the chat is a single script tag that you paste into your theme's theme.liquid file, once, and it shows on every page of your store.
Can the chatbot answer questions about shipping, returns and sizes?
Yes, as long as that information is on your store's pages or in a document you add. Add your shipping, returns and size guide pages as the assistant's knowledge, and it answers from them, in your words.
Can it see my orders or stock levels?
No. The assistant answers from the pages and documents you give it, not from your Shopify admin, so it can't look up an order. For order questions, add a form so the chat collects the order number and the customer's email and sends them to you.
Does it show on the checkout page?
No. Shopify doesn't run theme code on its checkout, so the chat appears on your storefront (home, collections, products, cart and pages) but not during checkout.
Will it slow down my store?
Not noticeably. The script loads with async, so the browser fetches it without holding up the rest of your page, and it doesn't add anything to your theme's Liquid or your store's data.
Is there a free trial?
Yes. Every Pixexl plan includes the AI chat assistant, and your first 2 weeks are free, so you can try it on your store with real shoppers. See pricing for the plans.