IT

How to embed an AI agent inside an Apache Superset dashboard

Learn how to integrate an AI data agent into Apache Superset via iframe and REST API without rebuilding the system or writing complex plugins.

·3 min read
How to embed an AI agent inside an Apache Superset dashboard

Integrating artificial intelligence into business intelligence systems is becoming a standard for modern data analytics. A typical workflow involves business users going to an analyst when metrics surge, prompting the analyst to write SQL queries. New technologies bridge this gap using text-to-SQL data agents capable of answering questions directly within the dashboard interface.

Architecture and iframe integration

Implementing a full-featured analytics chat agent (such as Nao) inside Apache Superset was achieved without rewriting the BI architecture itself. Instead, a lightweight embedded agent page /embed/chat was utilized, containing only the conversation interface and input field while stripping away extraneous sidebars. This approach fits the interface neatly into a compact corner window.

The container is a standard Superset Markdown block containing an iframe tag. Using CSS styles, the panel is fixed over the charts despite the layout's specific structure. The dashboard identifier dashboard_id is passed into the iframe address, linking the current visual context directly to the AI's capabilities.

Read alsoTypeSer 2.0: Open Source ERP Platform Built with TypeScript and PostgreSQL

Context layer and automated metadata export

The primary challenge for data agents is understanding what data a user is referring to. To prevent users from explaining context repeatedly, a script automatically exports dashboard and dataset metadata from the Superset REST API into Markdown files. A dedicated file is generated for each dashboard describing its charts, virtual dataset tables, and applied filters.

When a user asks a question like «what grew here?», the agent receives the dashboard_id, references the corresponding description file, and independently locates the relevant table. This allows the agent to construct precise SQL queries, identify the reasons behind metric shifts, and accurately report growth percentages based on live database info.

Security configuration and technical nuances

Successfully launching the integration required updating Superset sanitizer settings to allow iframe tags within Markdown blocks, alongside configuring the CSP frame-src directive to permit the external domain. On the agent side, frame-ancestors headers were adjusted to allow embedding. The solution has been tested and works starting from Superset version 2.0.1.

During development, engineers faced layout constraints. For instance, standard CSS rules like position: fixed inside dashboard columns failed due to transform properties, requiring targeted style overrides. Additionally, the current implementation cannot read active interactive filter values directly from the URL, a gap that can be bridged using upcoming MCP servers.

What this means for developers and business

Such seamless integration of AI agents into existing BI tools blurs the line between deep technical analysis and simple business queries. Companies can utilize trusted dashboards as a single source of truth while augmenting them with an intelligent assistant, avoiding the need to purchase or build expensive proprietary visualization platforms.

For developers, this approach demonstrates how to extend the functionality of a powerful Open Source product with minimal effort—requiring just a few configuration lines and a synchronization script—saving team resources and providing business stakeholders with rapid in-context analytics.

Source: Все публикации подряд на Хабре

Related articles