supabase/functions/ and run on the Deno runtime. The base endpoint for calls is:
inventory-oracle
File:supabase/functions/inventory-oracle/index.tsModel:
gemini-2.5-flash-lite (v1beta API)
Analyses 30 days of order history for a product and predicts when stock will run out. Returns urgency level and messages for both customer-facing display and admin restock planning.
Request body
Response
Error response
dashboard-intelligence
File:supabase/functions/dashboard-intelligence/index.tsModel:
gemini-2.5-flash-lite (v1beta API)
Generates a C-Level executive narrative and health score from dashboard KPIs. Used by getDashboardPulse() in admin-dashboard.service.ts.
Request body
Response
customer-intelligence
File:supabase/functions/customer-intelligence/index.tsModels:
gemini-2.5-flash (Analyst + Sommelier engines)
The most complex edge function. Handles multiple actions dispatched via an action field in the request body.
Actions
concierge_chat / semantic_search
The main AI concierge pipeline. Runs a two-engine Analyst→Sommelier architecture:
- Analyst classifies intent and dispatches tool calls
- Sommelier generates the empathetic response
parse_admin_intent
Converts an admin natural language command into a structured action.
generate_supplier_copy
Generates a professional WhatsApp restock message for a supplier.
generate_whatsapp_copy
Generates a personalised WhatsApp marketing message for a customer segment.
generate_proactive_insights
Analyses low-stock products and at-risk customers to produce 3 strategic insights.
voice-intelligence
File:supabase/functions/voice-intelligence/index.tsModel:
gemini-2.5-flash-lite (v1beta API)
Converts a natural language query (text or base64 audio) into a clean search keyword string.
Request body
Response
searchQuery set to the original transcript, so the frontend can fall back to a plain text search without breaking.
product-intelligence
File:supabase/functions/product-intelligence/index.tsModel:
gemini-2.5-flash-lite (v1beta API)
Generates SEO-friendly product descriptions and marketing copy.
Request body
Response
loyalty-intelligence
File:supabase/functions/loyalty-intelligence/index.tsModel:
gemini-2.5-flash-lite (v1beta API)
Evaluates a customer’s RFM segment from the customer_intelligence_360 view and generates a personalised discount offer. Creates a real coupon in the coupons table and records it in smart_loyalty_propositions.
Request body
Response
Returns the fullsmart_loyalty_propositions row:
Campeón→ 10%Leal→ 15%En Riesgo/Casi Perdido→ 20–25%Nuevo→ 15%
customer-narrative
File:supabase/functions/customer-narrative/index.tsModel:
gemini-2.5-flash-lite (v1beta API)
Generates a 2-sentence executive CRM narrative for a customer, combining customer_intelligence_360 data with the last 5 order amounts and statuses.
Request body
Response
bundle-intelligence
File:supabase/functions/bundle-intelligence/index.tsModel:
gemini-2.5-flash-lite (v1beta API)
Suggests a complementary product from a compatible category, generates a creative bundle name, and creates a 15% discount coupon valid for 2 hours.
Request body
Compatibility rules
Response
embeddings-processor
File:supabase/functions/embeddings-processor/index.tsModel:
gemini-embedding-001 (v1beta API — intentionally not migrated)
Converts a text string into a vector embedding array for semantic search.
Request body
Response
v1beta endpoint (https://generativelanguage.googleapis.com/v1beta/models/gemini-embedding-001:embedContent) because gemini-embedding-001 is only available on the beta API.
