Building Self-Serve Business Intelligence with LLM-Generated Widgets
AI Engineergo watch the original →
the gist
WorkOS built an internal workspace called Studio that uses LLMs to generate declarative JavaScript widgets for querying business data, moving from one-off Slack requests to reusable, deterministic dashboards.
The Breakthrough
Garrett Galow developed an internal workspace, Studio, that replaces manual SQL requests with LLM-generated, declarative JavaScript widgets that directly query primary data sources like Snowflake, Linear, and Notion.
What Actually Worked
- Late-stage context injection: The system avoids bloating the context window by injecting tool-specific schema and join logic only at the exact moment a tool is invoked, rather than pre-loading all metadata.
- Explicit distrust rules: The prompt engineering includes a directive for the LLM to ignore its internal training knowledge about WorkOS and instead rely exclusively on primary sources like documentation and live database schemas.
- Pre-deployment query validation: Every generated SQL query is executed against the database to ensure it returns non-zero results before the system commits the code to a persistent widget.
- Declarative widget generation: Once the LLM writes the widget as JavaScript code, the system stops using the LLM for data retrieval, making subsequent runs deterministic, cheap, and independent of model latency.
Context
Internal teams often struggle with a bottleneck where non-technical staff must file requests for data, wait for engineers to write one-off SQL queries, and then repeat the process when requirements change. WorkOS built Studio to allow non-technical users to ask natural language questions that result in reusable, live-updating widgets. By treating the output as code rather than just text, the team created a self-serve environment that scales without requiring constant engineering intervention.
Notable Quotes
- "The widgets are the interesting part: the LLM writes them once as declarative JavaScript that calls the underlying data sources directly, so every subsequent run is deterministic and cheap."
- "We tell the LLM to specifically like distrust knowledge around our product often just because like sometimes the model training is using outdated data."
Content References
- tool: Snowflake, context: mentioned
- tool: Linear, context: mentioned
- tool: Notion, context: mentioned
- tool: LangGraph, context: mentioned
- tool: Convex, context: mentioned
- tool: WorkOS Pipes, context: mentioned