Skip to content

Build Opal Agents for Commerce

⏱ 45 minutes advanced
📜CoreOpalcommerce

Generic AI assistants can answer questions about your products, but they cannot analyze your transaction data, detect purchasing patterns, or generate content that reflects your catalog structure. Commerce-specific Opal agents bridge this gap by connecting directly to your Commerce Proxy API and Google Analytics data.

These agents transform raw commerce data into actionable intelligence — trend reports for account managers, product descriptions for your catalog, lapsed customer alerts for sales teams, and merchandising recommendations for buyers.

Every Commerce Opal agent follows the same pattern:

  1. Input variables — The user provides context (customer number, date range, category, etc.)
  2. API calls — The agent queries the Commerce Proxy API and optionally Google Analytics
  3. Analysis — The agent processes the data according to its prompt instructions
  4. Structured output — The agent produces a formatted report, content draft, or recommendation

The Commerce Proxy API uses OData conventions:

Common Commerce API patterns
bash
# Get customer profile
GET /api/v1/customers?$filter=customerNumber eq '12345'

# Get orders with line items
GET /api/v1/orders?$filter=orderDate ge 2025-01-01&$expand=orderLines

# Get products by category
GET /api/v1/products?$filter=categoryId eq 'electrical-wire'

# Paginate with OData NextLink (max 100 per request)
# Follow the @odata.nextLink URL in each response

Agent pattern 1: Customer purchase trend analysis

Section titled “Agent pattern 1: Customer purchase trend analysis”

This agent analyzes a specific customer’s transaction history and produces a trend report with product recommendations. Account managers use it to prepare for customer meetings.

Given a customer number and date range, the agent:

  • Retrieves the customer profile and all orders in the period
  • Pulls prior-year data for year-over-year comparison
  • Builds Top 10 rankings by quantity and dollar value
  • Identifies monthly purchasing patterns and seasonal trends
  • Generates two tiers of recommendations: products the customer bought last year but not this year, and products their peers buy that they do not
SettingValue
Agent typeSpecialized
NameCustomer Purchase Trend Reporting
VariablesCUSTOMER_ID (text), START_DATE (date), END_DATE (date)
ToolsCOMMERCE_PROXY_API, GOOGLE_ANALYTICS
CreativityLow (factual analysis)

Why two recommendation tiers? Self-history recommendations (“you bought this last year but not this year”) are high-confidence because they reflect proven demand. Peer-based recommendations (“customers like you also buy…”) are exploratory and expand the conversation. Separating them lets account managers prioritize appropriately.

Why include Google Analytics? Browsed-but-not-purchased products reveal unmet demand that order history alone misses. Cross-referencing GA data with the recommendation list highlights the highest-intent opportunities.

Agent pattern 2: Product content enrichment

Section titled “Agent pattern 2: Product content enrichment”

This agent generates and improves product descriptions, SEO metadata, and marketing copy for catalog items. Content teams use it to maintain consistent, high-quality product pages at scale.

Given a product number (or category for bulk processing), the agent:

  • Retrieves product attributes from the Commerce API (name, category, specifications, pricing)
  • Analyzes the current description for completeness and quality
  • Generates an improved description following brand voice guidelines
  • Creates SEO-optimized title tags, meta descriptions, and alt text
  • Suggests related product cross-sell and upsell connections
SettingValue
Agent typeSpecialized
NameProduct Content Enrichment
VariablesPRODUCT_ID (text), CONTENT_TYPE (dropdown: description/seo/full)
ToolsCOMMERCE_PROXY_API
CreativityMedium (creative writing within brand guidelines)
InstructionsLink to your brand voice instruction set

Why use Instructions? The agent should follow your organization’s brand voice, terminology, and style guidelines. Connecting it to an Opal Instruction ensures consistency across all generated content — the same tone whether the agent writes a product description or a category page.

Why separate content types? A “full” generation is expensive in Opal credits. Letting the user specify whether they need just SEO metadata or a complete rewrite avoids unnecessary credit consumption.

Agent pattern 3: Lapsed customer detection

Section titled “Agent pattern 3: Lapsed customer detection”

This agent identifies customers who have stopped purchasing and generates re-engagement recommendations for the sales team.

The agent:

  • Scans all customers with orders in a comparison period (e.g., last year) but no orders in the current period
  • Ranks lapsed customers by prior revenue (highest-value first)
  • For each lapsed customer, identifies their top product categories and suggests re-engagement offers
  • Cross-references with Google Analytics to see if lapsed customers are still visiting the website (interested but not buying)
SettingValue
Agent typeSpecialized
NameLapsed Customer Detection
VariablesCURRENT_START (date), CURRENT_END (date), PRIOR_START (date), PRIOR_END (date), MIN_PRIOR_REVENUE (number)
ToolsCOMMERCE_PROXY_API, GOOGLE_ANALYTICS
CreativityLow (data analysis)

Why a minimum revenue threshold? Without a threshold, the agent flags every inactive customer including one-time buyers. Setting a minimum (e.g., $5,000 prior-year revenue) focuses attention on customers worth recovering.

Why include website activity? A lapsed customer who still browses your site is a warmer lead than one who has disappeared entirely. The GA data helps sales teams prioritize which lapsed customers to contact first.

Agent pattern 4: Cart abandonment analysis

Section titled “Agent pattern 4: Cart abandonment analysis”

This agent analyzes abandoned carts to identify patterns and recommend conversion improvements.

The agent:

  • Queries recent cart data for carts that were created but never converted to orders
  • Analyzes abandonment patterns by product category, customer segment, cart value, and time of day
  • Identifies the most commonly abandoned products and categories
  • Correlates with Google Analytics to determine where in the checkout flow users drop off
  • Recommends specific interventions (pricing adjustments, UX improvements, follow-up emails)
SettingValue
Agent typeSpecialized
NameCart Abandonment Analyzer
VariablesSTART_DATE (date), END_DATE (date), MIN_CART_VALUE (number)
ToolsCOMMERCE_PROXY_API, GOOGLE_ANALYTICS
CreativityMedium (analytical with recommendations)

These four patterns cover the most common use cases, but the same architecture applies to any Commerce data analysis:

Agent ideaData sourceOutput
Promotion performanceOrders + promo codesROI report per campaign
Category merchandisingProducts + orders + GAAssortment recommendations
Inventory velocityOrders + time seriesFast/slow mover alerts
Competitive price monitoringProducts + external dataPrice positioning report
Vendor share-of-walletOrders by vendorVendor performance scorecard
New product adoptionOrders + launch datesAdoption curve analysis
Site search intelligenceGA search data + ordersSearch-to-purchase funnel
  1. Always paginate API calls — The Commerce Proxy API returns max 100 records per request. Your prompt must instruct the agent to follow OData NextLink URLs.

  2. Use leaf-level categories — Top-level categories are too broad for useful analysis. Instruct the agent to map products to their most specific category.

  3. Set creativity appropriately — Data analysis agents should use Low creativity for accuracy. Content generation agents can use Medium. Never use High for agents that produce factual reports.

  4. Include prior-year comparisons — Year-over-year context transforms raw numbers into meaningful trends. Always pull the equivalent prior period.

  5. Connect Instructions for content agents — Any agent that generates customer-facing text should reference your brand voice Instruction to maintain consistency.