E-Commerce Plugin

Ready-made plugin for e-commerce, real estate, and travel sites. Hooks into your existing search API — zero DOM scraping. All operations are read-only by design.

Installation

import { ecommercePlugin } from '@aixa/plugin-ecommerce';

Basic Usage

import { ecommercePlugin } from '@aixa/plugin-ecommerce';

const plugin = ecommercePlugin({
  searchEndpoint: '/api/search',
  detailEndpoint: '/api/products',
});

plugin.register();

That's it. Once registered, agents can search your catalog and fetch product details — all through your existing API, with zero DOM scraping.

Configuration

Parameter Type Required Description
searchEndpoint string Yes URL for the search API endpoint. Receives search parameters as query string.
detailEndpoint string No URL for fetching individual product details. Receives product ID.
searchHandler function No Custom handler for search queries. Overrides the default fetch to searchEndpoint.
detailHandler function No Custom handler for product detail lookups. Overrides the default fetch to detailEndpoint.
dataLayerKey string No Optional key for reading results from a data layer (e.g., window.__CATALOG__).

Search Parameters

All parameters are passed to the search endpoint as query string parameters. None are required — every parameter acts as an optional filter.

Parameter Type Description
q string Free-text search query (e.g., "blue shirt").
category string Category slug or name (e.g., "clothing", "electronics").
minPrice number Minimum price filter.
maxPrice number Maximum price filter.
brand string Filter by brand name.
inStock boolean Only show in-stock items.
onSale boolean Only show items currently on sale.
rating number Minimum rating threshold (1–5).
sortBy enum Sort field: price, rating, newest, relevance, name.
sortDir enum Sort direction: asc, desc.
page number Page number for pagination (1-indexed).
pageSize number Number of results per page.

What Agents Can Do

After registering the plugin, agents can perform two operations:

Catalog Search

// Agent calls:
search({ q: "blue shirt", category: "clothing", maxPrice: 100 })

Returns matching products from your existing search API. All filters are optional — the agent only applies what the user asks for.

Product Detail

// Agent calls:
get_product_detail({ id: "SKU-12345" })

Fetches full product details including description, images, variants, and availability.

SAFE: All operations are read-only. No carts, no orders, no writes — just discovery.

Vertical Templates

The plugin ships with pre-configured parameter sets for common verticals via the VERTICAL_TEMPLATES constant:

import { ecommercePlugin, VERTICAL_TEMPLATES } from '@aixa/plugin-ecommerce';

// Use the real estate template
const plugin = ecommercePlugin({
  ...VERTICAL_TEMPLATES.realEstate,
  searchEndpoint: '/api/properties',
});

plugin.register();
Template Additional Parameters Use Case
VERTICAL_TEMPLATES.ecommerce Standard e-commerce parameters Online stores, marketplaces, retail.
VERTICAL_TEMPLATES.realEstate propertyType, minBedrooms, minBathrooms, minArea, maxArea, location Real estate listings, property search.
VERTICAL_TEMPLATES.travel destination, checkIn, checkOut, guests, propertyType Hotels, vacation rentals, flights.

Real Estate Example

// Agent calls with real estate template:
search({
  location: "Austin, TX",
  propertyType: "single-family",
  minBedrooms: 3,
  minBathrooms: 2,
  maxPrice: 600000
})

Custom Handlers

If your backend API doesn't follow the default query-string convention, provide a custom searchHandler. This gives you full control over how search parameters are translated into API calls.

const plugin = ecommercePlugin({
  searchHandler: async (params) => {
    // Query your own database directly
    const results = await myDatabase.query(
      'SELECT * FROM products WHERE name LIKE ? AND category = ?',
      [`%${params.q}%`, params.category]
    );

    // Return items in the standard format
    return results.map(item => ({
      id: item.sku,
      name: item.title,
      price: item.price,
      // ... standard fields
    }));
  },

  detailHandler: async ({ id }) => {
    const product = await myDatabase.findById('products', id);
    return {
      id: product.sku,
      name: product.title,
      description: product.description,
      price: product.price,
      images: product.images,
      inStock: product.inventory > 0,
    };
  },
});

plugin.register();

Zero Mutation Risk

The e-commerce plugin is deliberately constrained to read-only operations. Here's what that means in practice:

This means you can safely expose the plugin to any agent without fear of unintended side effects. The plugin handles discovery; your existing checkout flow handles conversion.

See it in action: Live demo with a sample store showing end-to-end agent search.