AI Sort Builder is currently in Beta. Contact your Layers account manager or support team to request access.
Overview
AI Sort Builder allows you to configure sort orders using natural language descriptions instead of manually creating attributes, metrics, and sorting rules. The AI analyzes your request and automatically generates the necessary configuration, including calculated attributes, LayersQL metrics, and sorting expressions.Prerequisites
- AI Sort Builder must be enabled for your store (contact your account manager)
- Access to the Sort Orders section in your Layers dashboard
- An existing sort order to modify (the AI Builder is not available when creating new sort orders)
Using AI Sort Builder
Accessing the AI Builder
- Navigate to Sort Orders in your Layers dashboard
- Open an existing sort order for editing
- Click the AI Builder button (marked with a Beta badge) in the Sorting Expressions section
Writing effective prompts
Describe your sorting goals in natural language. The AI understands common ecommerce concepts and can generate complex configurations from simple descriptions. Example prompts:- “Sort by popularity, boost new arrivals”
- “Show best sellers first, then sort by price low to high”
- “Prioritize products with high margins, demote out-of-stock items”
- “Balance between popularity and profit margin, favoring popularity 70/30”
- “Sort by most viewed in the last 30 days, boost items added this week”
- Be specific about time windows (e.g., “last 30 days” vs. “recent”)
- Mention if you want weighted combinations and specify the weights
- Describe priority rules clearly (boost/demote conditions)
- Reference specific product attributes if you know they exist in your catalog
Understanding the generated configuration
After you submit a prompt, the AI generates a configuration that may include: Calculated attributes: Custom product attributes created using JSONLogic expressions. These derive new properties from existing product data (e.g., “is new arrival” based on publish date). LayersQL metrics: Analytics-based metrics that aggregate event data per product (e.g., “30-day view count” or “7-day revenue”). Sorting rules: The actual sorting configuration that determines product order, including direction (ascending/descending), weights, and priority conditions. The AI provides an explanation of what the configuration does and shows a preview of all generated resources.Reviewing and applying the configuration
Before applying the configuration:- Review the explanation to ensure it matches your intent
- Check the list of new attributes and metrics that will be created
- Verify the sorting rules align with your merchandising goals
- Regenerate: Ask the AI to create a new configuration if the current one doesn’t meet your needs
- Apply: Accept the configuration and add it to your sort order form
Iterative refinement
You can continue the conversation with the AI to refine the configuration:- After reviewing the generated configuration, describe what you’d like to change
- The AI maintains conversation context and can adjust the configuration based on your feedback
- Each iteration generates a new configuration that you can review and apply
- Initial prompt: “Sort by popularity”
- Follow-up: “Actually, also boost products with high margins”
- The AI adjusts the configuration to include margin-based boosting
How the AI works
Generation process
When you submit a prompt, the AI:- Analyzes your store’s existing attributes and metrics
- Understands your natural language description
- Generates the necessary calculated attributes and metrics
- Creates sorting rules that implement your desired behavior
- Validates the configuration to ensure it’s syntactically correct
Validation and retries
The AI automatically validates generated configurations and retries up to 3 times if validation fails. This ensures you receive a working configuration that can be applied to your sort order. If generation fails after all retry attempts, you’ll see an error message explaining what went wrong. You can try rephrasing your prompt or providing more specific details.Using existing resources
The AI checks your store’s existing attributes and metrics before creating new ones. If a suitable attribute or metric already exists, the AI references it instead of creating a duplicate. For example, if you already have a “Product Views” metric, the AI will use it when you ask to “sort by popularity” rather than creating a new metric.Common use cases
Popularity-based sorting
Prompt: “Sort by most popular products first” What the AI generates:- A LayersQL metric counting product views
- A sorting rule ordering products by view count (descending)
New arrivals with popularity tiebreaker
Prompt: “Show new arrivals first, then sort by popularity” What the AI generates:- A calculated attribute identifying products published in the last 30 days
- A LayersQL metric for product views
- Sorting rules that prioritize new arrivals, then sort by popularity
Weighted combination
Prompt: “Balance between popularity and profit margin, favoring popularity 70/30” What the AI generates:- A LayersQL metric for product views
- A weighted sorting configuration combining views (70%) and margin (30%)
Priority rules with conditions
Prompt: “Boost featured products, demote out-of-stock items, then sort by price” What the AI generates:- Priority rules boosting featured products
- Priority rules demoting out-of-stock items
- A price-based sort for remaining products
Troubleshooting
The AI Builder button doesn’t appear
Cause: AI Sort Builder is not enabled for your store. Solution: Contact your Layers account manager or support team to request access to the AI Sort Builder beta.Generation fails repeatedly
Cause: The prompt may be too vague or request something that’s not possible with the available data. Solution: Try rephrasing your prompt with more specific details. Mention specific attributes or time windows. If the issue persists, contact support.Generated configuration doesn’t match expectations
Cause: The AI may have misunderstood your intent or made assumptions about your catalog. Solution: Use the chat interface to refine the configuration. Describe what’s wrong and what you’d like to change. The AI maintains conversation context and can adjust accordingly.Status updates not appearing
Cause: Real-time updates may not be working in your browser. Solution: Try refreshing the page and reopening the AI Builder. If the issue persists, contact support for assistance.Best practices
Start simple, then refine
Start simple, then refine
Begin with a straightforward description of your primary sorting goal. Use the iterative refinement feature to add complexity based on the initial results.
Reference time windows explicitly
Reference time windows explicitly
When asking for time-based metrics (popularity, recency), specify the time window (e.g., “last 7 days” or “last 30 days”) for more predictable results.
Review before applying
Review before applying
Always review the generated configuration before applying it. Check that the attributes, metrics, and sorting rules align with your merchandising strategy.
Test the results
Test the results
After applying and saving a configuration, use the sort order preview feature to verify that products are ordered as expected.
Leverage existing resources
Leverage existing resources
Mention specific attributes or metrics you know exist in your store. The AI will reference them instead of creating duplicates.
Technical details
Calculated attributes
Calculated attributes use JSONLogic expressions to derive new product properties. The AI generates these when your prompt requires custom logic that isn’t available in existing attributes. Example JSONLogic for “is new arrival”:LayersQL metrics
LayersQL metrics aggregate analytics data per product. The AI generates these when your prompt references popularity, sales, or other event-based concepts. Example LayersQL for “30-day views”:Sorting rules
Sorting rules define how products are ordered. The AI generates these based on your prompt, including:- Direction: Ascending or descending
- Weight: For weighted combinations (must sum to 100 in a group)
- Operator and value: For priority rules (boost/demote conditions)