Internal Service β This is not an HTTP endpoint. Itβs called directly by the generate-all orchestrator.
Purpose
Generates visibility prompts for each discovered product. These are product-specific search queries that potential customers might use to find products like this.
Runs in GROUP 2b (starts when GROUP 1a + 1b + 1d complete, runs in parallel with GROUP 2a and 2c).
Function Signature
async def run_product_prompts(
url: str,
org_slug: str,
discovered_products: list,
pages: list,
prompts_per_product: int = 5
) -> Optional[StepResult]
Parameters
| Parameter | Type | Description |
|---|
url | str | The Shopify store URL |
org_slug | str | The Clerk organization slug |
discovered_products | list | Products from GROUP 1d |
pages | list | Pre-scraped pages from GROUP 1b |
prompts_per_product | int | Prompts per product (may be increased to meet minimum) |
Returns
{
"name": "product_prompts",
"status": "success",
"data": {
"products_processed": 8,
"total_prompts": 56,
"prompts_per_product": 7
}
}
Prompt Generation Strategy
All prompts are tied to products:
| Metric | Value |
|---|
| Default prompts per product | 5 |
| Minimum total prompts | 50 during onboarding |
| New products (via cron) | 5 prompts each |
| Daily sampling | 10 prompts for visibility scoring |
Minimum 50 Logic
During onboarding, if products Γ 5 < 50, prompts per product is increased:
# Example: 3 products
# Base: 3 Γ 5 = 15 prompts (below minimum)
# Adjusted: ceil(50 / 3) = 17 prompts per product
# Result: 3 Γ 17 = 51 total prompts
# Example: 12 products
# Base: 12 Γ 5 = 60 prompts (above minimum)
# No adjustment needed: 5 prompts per product
# Result: 12 Γ 5 = 60 total prompts
Execution Flow
Product-Specific Prompts
Uses Gemini with product context:
prompt = f"""
Generate {count} search queries for this specific product: {product_name}
Requirements:
- Queries should be specific to this product
- Include feature-specific queries
- Include comparison queries with alternatives
- Sound like something a real person would type into ChatGPT or Google
"""
Database Storage
Prompts are linked to the product entity:
INSERT INTO entity_prompts_tracker (
entity_id, -- Product entity ID
prompt
) VALUES (
'product-uuid-...',
'Best tool for X feature'
);
Code Location
src/app/apis/onboarding/generate_all/tasks/prompts.py
Contains run_product_prompts() for GROUP 2b.
Skipped Scenarios
Product prompts are skipped if:
- No products were discovered in GROUP 1d
- Product discovery failed
- Products donβt have valid entity IDs
{
"name": "product_prompts",
"status": "skipped",
"error": "No products discovered"
}