--- title: Chat sidebar_position: 3 --- # Chat Contributions Extensions can add a chat interface to Superset by registering a trigger and a panel. The host owns the layout, open/close state, and display mode — the extension only needs to provide the UI components. ## Overview A chat registration consists of two React components: | Component | Role | |-----------|------| | **Trigger** | Always-visible entry point (e.g., a floating button). Rendered in the bottom-right corner in floating mode, or as a fixed overlay in panel mode. | | **Panel** | The chat UI itself (message list, input, etc.). Mounted by the host in the active display mode. | ## Display Modes The host supports two display modes, switchable by the user or the extension at runtime: | Mode | Behavior | |------|----------| | `floating` | Panel floats above page content, anchored to the bottom-right corner. | | `panel` | Panel is docked to the right side of the application as a resizable sidebar, sitting beside the page content. | The user's last selected mode and open/closed state are persisted across page reloads. ## Registering a Chat Call `chat.registerChat` from your extension's entry point with a descriptor, a trigger factory, and a panel factory: ```tsx import { chat } from '@apache-superset/core'; import ChatTrigger from './ChatTrigger'; import ChatPanel from './ChatPanel'; chat.registerChat( { id: 'my-org.my-chat', name: 'My Chat' }, ChatTrigger, ChatPanel, ); ``` Only one chat registration is active at a time. If a second extension calls `registerChat`, it replaces the first and a warning is logged. ## Opening and Closing the Chat The trigger component is responsible for toggling the panel. Use `chat.isOpen()`, `chat.open()`, and `chat.close()` to control visibility: ```tsx import { chat } from '@apache-superset/core'; export default function ChatTrigger() { return ( ); } ``` You can also subscribe to open/close events from any component: ```tsx useEffect(() => { const { dispose } = chat.onDidOpen(() => console.log('chat opened')); return dispose; }, []); ``` ## Changing the Display Mode Call `chat.setDisplayMode` to switch between `'floating'` and `'panel'` modes. In your panel component, subscribe to `onDidChangeDisplayMode` to react to changes (including those triggered by the user): ```tsx import { useState, useEffect } from 'react'; import { chat } from '@apache-superset/core'; export default function ChatPanel() { const [mode, setMode] = useState(chat.getDisplayMode()); useEffect(() => { const { dispose } = chat.onDidChangeDisplayMode(m => setMode(m)); return dispose; }, []); return (