Back to blog
shopifyecommercechatbotopenclawtutorial

Add an AI Chatbot to Your Shopify Store (Without Apps)

How to connect an OpenClaw agent to your Shopify store for product recommendations, order tracking, and FAQ automation — without paying $50/month for a chatbot app.

By ClawPort Team

Most Shopify chatbot apps cost $40-80/month and give you a rigid flow builder with limited AI. You can build something better for a fraction of the cost using OpenClaw — with real product recommendations, order lookup, and a personality that matches your brand.

This guide shows you how to connect OpenClaw to Shopify's API and deploy a chatbot that actually helps customers buy things.

What This Agent Will Do

  • Answer product questions from your actual catalog
  • Make recommendations based on what customers describe
  • Look up real order status by order number or email
  • Answer FAQs from your store policies
  • Handle return/refund inquiries and route to human if needed

Shopify API Setup

You'll need a Shopify custom app with these permissions:

  • read_products — product catalog access
  • read_orders — order status lookup
  • read_customers — customer lookup (optional)

Create a custom app in Shopify admin → Settings → Apps → Develop apps.

SHOPIFY_STORE_URL=your-store.myshopify.com
SHOPIFY_ACCESS_TOKEN=shpat_xxxxxxxxxx

Building the Product Search Tool

The most valuable capability is product search. Here's the tool:

// tools/product_search.js
import fetch from 'node-fetch';

const SHOPIFY_URL = process.env.SHOPIFY_STORE_URL;
const SHOPIFY_TOKEN = process.env.SHOPIFY_ACCESS_TOKEN;

async function searchProducts({ query, limit = 5 }) {
  const params = new URLSearchParams({
    title: query,
    limit: limit,
    fields: 'id,title,handle,product_type,body_html,variants,images,tags',
    status: 'active',
  });
  
  const response = await fetch(
    `https://${SHOPIFY_URL}/admin/api/2024-01/products.json?${params}`,
    {
      headers: {
        'X-Shopify-Access-Token': SHOPIFY_TOKEN,
        'Content-Type': 'application/json',
      }
    }
  );
  
  const data = await response.json();
  
  return data.products.map(p => ({
    title: p.title,
    url: `https://your-store.com/products/${p.handle}`,
    price: `$${(p.variants[0].price)}`,
    description: p.body_html.replace(/<[^>]*>/g, '').substring(0, 200),
    tags: p.tags,
    image: p.images[0]?.src,
  }));
}

export default searchProducts;

Register it as an OpenClaw tool:

tools:
  - name: "search_products"
    description: "Search the product catalog by keyword or description"
    parameters:
      query:
        type: string
        description: "Product search terms"
      limit:
        type: number
        description: "Max number of results (default 5)"
    handler: "tools/product_search.js"

Building the Order Lookup Tool

// tools/order_lookup.js
async function lookupOrder({ orderNumber, email }) {
  let url;
  
  if (orderNumber) {
    // Shopify order names are like #1001, #1002
    const name = orderNumber.startsWith('#') ? orderNumber : `#${orderNumber}`;
    url = `https://${SHOPIFY_URL}/admin/api/2024-01/orders.json?name=${encodeURIComponent(name)}&status=any`;
  } else if (email) {
    url = `https://${SHOPIFY_URL}/admin/api/2024-01/orders.json?email=${encodeURIComponent(email)}&status=any&limit=5`;
  } else {
    return { error: "Please provide an order number or email address" };
  }
  
  const response = await fetch(url, {
    headers: { 'X-Shopify-Access-Token': SHOPIFY_TOKEN }
  });
  
  const data = await response.json();
  
  if (!data.orders || data.orders.length === 0) {
    return { error: "No orders found with that information" };
  }
  
  return data.orders.map(order => ({
    orderNumber: order.name,
    status: order.fulfillment_status || 'unfulfilled',
    financialStatus: order.financial_status,
    createdAt: order.created_at,
    total: `$${order.total_price}`,
    items: order.line_items.map(i => i.name),
    trackingNumbers: order.fulfillments?.flatMap(f => f.tracking_numbers) || [],
    trackingUrl: order.fulfillments?.[0]?.tracking_url,
  }));
}

export default lookupOrder;

SOUL.md for a Shopify Agent

# ShopBot — [Store Name] Assistant

You help customers of [Store Name] with product questions, order tracking,
and general support.

## Personality
- Warm and knowledgeable, like a great sales associate
- Enthusiastic about the products without being pushy
- Always honest if something is out of stock or unavailable

## Product Recommendations

When a customer describes what they're looking for:
1. Use search_products to find relevant options
2. Present 2-3 options with key features and prices
3. If they have more specific requirements, ask one clarifying question
4. Include a direct link to each product

Don't list more than 3 products at once. Quality > quantity.

## Order Tracking

When a customer asks about an order:
1. Ask for their order number (preferred) or email address
2. Use lookup_order to retrieve the status
3. If there's a tracking number, share it with the carrier link
4. If the order is delayed, empathize and offer to escalate if needed

## What You Can't Do
- Process refunds directly — direct to [email protected]
- Change or cancel orders — direct to [email protected] with order # and reason
- Make pricing exceptions

## Store Policies
- Free shipping on orders over $75
- 30-day returns on unworn items with tags
- Processing time: 1-3 business days
- Shipping time: 3-5 business days (US standard)

Adding the Chat Widget to Shopify

Add OpenClaw's embed script to your Shopify theme. In the Shopify theme editor (Online Store → Themes → Edit code → theme.liquid), add before the closing body tag:

<!-- OpenClaw Chat Widget -->
<script>
  window.openClawConfig = {
    agentId: 'YOUR_AGENT_ID',
    position: 'bottom-right',
    primaryColor: '#your-brand-color',
    greeting: 'Hi! Looking for something specific, or need help with an order?',
  };
</script>
<script src="https://cdn.openclaw.ai/widget.js" async></script>

Replace YOUR_AGENT_ID with your OpenClaw agent ID from the dashboard.

Handling Product Recommendations Well

The difference between a good and bad chatbot for ecommerce is how it handles vague requests. Train yours with examples:

## Example Conversations

User: I need a gift for my mom

You: Happy to help! A couple of questions so I can find something she'd love:
- What's your budget? 
- Any idea of her interests or style?

User: Maybe $50-80, she likes gardening

You: Perfect. Here are three options that would make a lovely gardening gift:

**Leather Garden Tool Roll** — $67
Holds 8 tools, butter-soft leather. Popular gift.
→ yourstore.com/products/leather-tool-roll

**Heirloom Seed Collection** — $54
25 varieties of heirloom vegetables and flowers, with planting guides.
→ yourstore.com/products/heirloom-seeds

**Ceramic Plant Markers Set** — $49
Handmade, dishwasher-safe, pack of 12.
→ yourstore.com/products/ceramic-markers

Any of these catch your eye, or should I look for something different?

What This Costs

Compared to a Shopify chatbot app at $40-80/month:

OptionMonthly CostQuality
Tidio Pro$49/monthFlow-based, limited AI
Gorgias AI$60+/monthSupport-focused, limited product rec
Intercom$74+/monthOverkill for small stores
OpenClaw + ClawPort$10 + API costs (~$5-15)Full AI, customizable

For a store doing under 500 conversations/month, your total OpenClaw cost is typically $10 (ClawPort) + $5-15 (API) = $15-25/month.

Deploy on ClawPort

ClawPort makes this straightforward: connect your GitHub repo, add your SHOPIFY_ACCESS_TOKEN as an environment variable in the dashboard, and you're live. No server configuration, no Nginx setup, no SSL certificates.

The tool handlers (product search, order lookup) run in your ClawPort environment. Shopify never gets a request from your laptop — it comes from ClawPort's infrastructure.

Seven-day free trial at clawport.io.

Ready to deploy your AI agent?

Get started with ClawPort in 60 seconds. No credit card required.

Get Started Free