Pular para o conteúdo
AIAgentsE-commerce

AI agents for e-commerce: what they are and how to use them in your operation

12 min

AI agents are the next evolution beyond chatbots and simple automations. While a chatbot answers questions and an automation follows a fixed script, an agent combines a large language model with tools, memory and the ability to take autonomous actions. It can reason about a problem, decide which tools to use, execute multi-step workflows and learn from outcomes. For e-commerce operations, this means an AI that does not just answer what is my order status but actually checks the order, identifies a shipping delay, proactively sends the customer an updated estimate and flags the logistics team. This guide covers what agents are, practical e-commerce use cases and how to build them with tools you already know.

Anatomy of an AI agent: LLM + tools + memory + action

An AI agent has four components. The LLM (Claude, GPT-4) is the brain. It receives a prompt describing its role, capabilities and constraints. It reasons about incoming requests and decides what to do. Tools are functions the agent can call: check_order_status(order_id), search_products(query), create_coupon(discount, expiry), send_email(to, subject, body). Each tool has a description the LLM reads to decide when to use it. Tools are the bridge between reasoning and action. Memory gives the agent context beyond the current conversation. Short-term memory is the conversation history. Long-term memory stores customer preferences, past interactions and learned patterns. Supabase with pgvector is ideal for long-term memory: store interaction summaries as embeddings and retrieve relevant context for new conversations. Action is what distinguishes agents from chatbots. A chatbot says I see your order is delayed, contact support. An agent says I see your order is delayed by 2 days due to a carrier issue. I have updated your estimated delivery date and applied a 10% discount code SORRY10 to your next purchase. Is there anything else I can help with? The agent took action: it called the order API, identified the issue, generated a coupon via the promotions API and composed a contextual response.

Customer service agent: resolving issues autonomously

A customer service agent handles the most common support interactions end-to-end. Order status and tracking: the agent calls the VTEX Orders API (GET /api/oms/pvt/orders/{orderId}) or Shopify Orders API to fetch order details, tracking number and carrier status. It translates raw API data into a customer-friendly response with estimated delivery date. Returns and exchanges: the agent checks if the order is within the return window, validates the reason against your return policy, creates a return request via API and sends the customer a return shipping label. On VTEX, this uses the Return Request API. On Shopify, the Refunds API. Coupon generation for service recovery: when the agent detects a legitimate complaint (delayed order, damaged product), it can generate a single-use coupon via the VTEX Promotions API or Shopify Price Rules API. Define guardrails: maximum discount percentage, maximum total value, expiry date. Product questions: the agent searches your catalog using semantic search (product embeddings stored in Supabase pgvector) and returns relevant products with availability, pricing and specifications. Implementation: the agent runs as a Cloudflare Worker. It receives customer messages via webhook (from your chat widget, WhatsApp or email). It maintains conversation state in Supabase. It calls the Claude API with the conversation history, available tools and your system prompt defining policies and constraints. Typical resolution rate: 50-70% of inbound support volume without human intervention.

Catalog management agent: automating product operations

A catalog management agent handles the tedious, repetitive work of maintaining a large product catalog. Description generation: when new products are added to Sanity CMS without descriptions, the agent detects the gap (via webhook or scheduled check), generates descriptions using the Claude API with your brand voice template and saves them as drafts in Sanity for editor review. Category and tag suggestion: the agent analyzes product attributes and images to suggest categories and tags. This is especially valuable for marketplaces or stores with frequent new product additions. It uses the existing category taxonomy as context and suggests the most appropriate placement. Image quality validation: the agent can use vision models (Claude with vision, GPT-4V) to analyze product images and flag issues: low resolution, wrong aspect ratio, no white background, watermarks, text overlays. It creates a quality report in Supabase that the catalog team reviews. Price monitoring: the agent checks competitor prices on a schedule (via scraping APIs or price monitoring services), compares with your pricing and flags products where your price is significantly higher or lower than the market. It can suggest price adjustments within guardrails you define. SEO audit: the agent periodically reviews product pages for SEO issues: missing meta descriptions, titles exceeding 60 characters, duplicate content, missing alt text on images. It generates fix suggestions and can auto-apply non-controversial fixes (like generating missing alt text). Integration: the agent connects to Sanity via the Content Lake API for reads and mutations. For VTEX, it uses the Catalog API. For Shopify, the Admin API. Scheduled tasks run via Cloudflare Workers Cron Triggers.

Analytics agent: turning data into decisions

An analytics agent monitors your store's performance data and surfaces actionable insights without requiring manual dashboard analysis. Data sources: Google Analytics 4 (via GA4 Data API), Supabase (for custom event tracking and customer data), platform analytics (VTEX Analytics API, Shopify Analytics API), ad platforms (Google Ads API, Meta Marketing API). What the agent does: daily performance summary (revenue, sessions, conversion rate, AOV compared to previous period and targets), anomaly detection (sudden traffic drops, conversion rate changes, unusual refund patterns), funnel analysis (identifies where customers are dropping off and suggests hypotheses), product performance (flags products with high views but low add-to-cart, suggesting pricing or description issues), campaign ROI (correlates ad spend with revenue by channel and flags underperforming campaigns). Implementation: a Cloudflare Worker runs on a daily cron schedule. It queries GA4 and your Supabase analytics tables, processes the data through the Claude API with context about your business goals and sends a summary to Slack or email. The agent learns your thresholds over time: if your normal conversion rate is 2.5%, it alerts on deviations beyond one standard deviation. Storage: all analytics summaries and anomalies are stored in Supabase for historical context. The agent references past summaries when analyzing new data, providing trend analysis rather than isolated snapshots.

Operations agent: inventory, SLA and logistics

An operations agent handles the operational tasks that keep a store running smoothly but consume significant human attention. Inventory monitoring: the agent tracks stock levels across warehouses (VTEX Inventory API, Shopify Inventory API) and alerts when products approach reorder points. It can automatically create purchase orders based on sales velocity and lead times. For stores using multiple fulfillment centers, it optimizes inventory allocation based on regional demand patterns. SLA monitoring: the agent monitors order fulfillment SLAs. When orders approach SLA deadlines without being shipped, it alerts the warehouse team via Slack or email. It tracks SLA compliance rates over time and identifies patterns (specific carriers, product categories or warehouse locations with recurring issues). Shipping cost optimization: the agent compares shipping quotes across carriers for each order and selects the optimal option based on delivery time, cost and reliability. For Brazilian stores using Melhor Envio or Correios, it pre-calculates shipping options and caches them in Cloudflare Workers KV for fast checkout display. Fraud detection assistance: the agent flags suspicious orders based on patterns: mismatched billing and shipping addresses, unusually large orders from new customers, multiple orders from the same IP with different payment methods. It does not block orders automatically but creates review queues with risk scores in Supabase.

Tech stack for building e-commerce agents

LLM: Claude API is the recommended choice for e-commerce agents. Claude excels at following complex instructions, using tools reliably and maintaining consistent behavior. The tool use feature lets you define functions the agent can call, with structured input/output schemas. Cost: approximately $3-15 per 1 million input tokens depending on the model. Orchestration: for simple agents (1-3 tools, single-turn), direct Claude API calls are sufficient. For complex agents (10+ tools, multi-turn, branching logic), LangChain or custom orchestration provides better control over the agent loop, error handling and fallback logic. Memory and data: Supabase handles both structured data (orders, customers, products in PostgreSQL tables) and vector search (product embeddings, conversation history in pgvector). Row Level Security ensures data isolation between customers. Realtime subscriptions enable live updates to agent dashboards. Compute: Cloudflare Workers for request handling and scheduled tasks. Workers run at the edge with sub-millisecond cold starts, 128MB memory and 30-second CPU time limits. For long-running agent tasks (bulk catalog processing), use Cloudflare Queues to process asynchronously. Platform APIs: VTEX provides REST APIs for orders, catalog, inventory, pricing and promotions. Shopify provides both REST and GraphQL APIs with similar coverage. Both require authentication tokens with scoped permissions. Frontend: the agent's interface can be a chat widget on your store, a Slack bot for internal agents, an email integration or a dashboard built with Next.js showing agent activity and metrics.

How to start: build your first agent in a weekend

Do not start with a complex multi-tool agent. Build the simplest useful agent first, then expand. Weekend project: order status agent. Hour 1-2: set up a Cloudflare Worker that receives POST requests with a customer message and order ID. Connect to your VTEX or Shopify API to fetch order details. Hour 3-4: integrate the Claude API. Define one tool: check_order_status(order_id) that returns order status, items, tracking number and estimated delivery. Write a system prompt: You are a helpful customer service agent for [Store Name]. You can check order status. Be concise and friendly. Answer in the customer's language. Hour 5-6: add conversation memory via Supabase. Create a conversations table. Store each exchange. Pass conversation history to Claude for context. Hour 7-8: add a simple chat widget to your store (or test via Postman/curl). Test with real order IDs. Handle edge cases: order not found, cancelled order, order in transit. This minimal agent handles the single most common support question (where is my order) and gives you the foundation to add tools incrementally. Next tools to add: search_products, check_return_eligibility, generate_coupon. Each tool is a function that calls an API and returns structured data. Claude decides when to use each tool based on the customer's message. Within a month you have an agent handling 50-60% of support volume.