# Chat widget

Embed an AI-powered chat assistant on any website.

## Overview

The inFlow chat widget renders a floating chat button and conversation window powered by your AI agent. Visitors can ask questions, get recommendations, and receive automated responses based on your business knowledge and configured tools.

The widget appears as a floating button (corner and style of your choosing). Clicking it opens a chat window with your branding and agent persona. It works on any website — plain HTML, React, Vue, WordPress, Shopify, or any platform that can add a `<script>` tag.

Beyond text answers, the agent can show tappable quick-reply buttons, rich cards (pricing, steps, comparisons), and a meeting scheduler backed by your real availability — visitors pick a day and time, the slot is verified against your calendar, and the booking lands as a scheduled lead with notes about what they wanted.

## Declarative embed

The simplest approach: add a `<script>` tag and a `<div>` with `data-tks-chat`. The toolkit auto-detects the attribute and mounts the chat widget.

```html
<!-- Load the toolkit (once per page) -->
<script
  src="https://api.inflow.build/toolkit.v2.js"
  data-tks-key="pk_..."
  data-tks-environment="your_environment_id"
  async
></script>

<!-- Chat widget will appear here -->
<div data-tks-chat="67a1b2c3d4e5f6a7b8c9d0e1"></div>
```

The `data-tks-chat` value is your agent ID, found in your inFlow dashboard under AI → Agents.

## Programmatic embed (React / Next.js) _(Developer only)_

For React and Next.js apps, use the `InflowChat` component. It handles script loading, mounting, and cleanup automatically. _(Developer only)_

```tsx
"use client";
import { InflowChat } from "@/components/embed/InflowChat";

export default function SupportPage() {
  return (
    <InflowChat
      agentId="67a1b2c3d4e5f6a7b8c9d0e1"
      publicKey="pk_..."
      // Optional
      apiBase="https://api.inflow.build"
      className="my-chat-widget"
      onReady={(api) => console.log("Chat ready", api)}
    />
  );
}
```

_(Developer only)_

## Configuration _(Developer only)_

| Prop | Type | Description |
| --- | --- | --- |
| agentId | string | Agent ID from your inFlow dashboard (required) |
| publicKey | string | Your pk_… public key (required) |
| apiBase | string | API origin (default "https://api.inflow.build") |
| className | string | Extra CSS classes for the container div |
| remountKey | string | Changing this value forces a full remount |
| onReady | (api) => void | Callback when the chat widget is initialized |

_(Developer only)_

## Styling

All visual options live in your dashboard under the agent's Appearance tab, with a live preview: launcher icon, button color (solid or gradient), launcher shape (circle, rounded, or a labeled pill), size, left/right position, an attention animation (pulse, glow, bounce, or wiggle), and four chat window themes — Midnight (dark), Light, Brand (your color in the header), and Glass (frosted). Publish the agent to push the new look to every embed.

For page-level overrides you can also set the `--tks-chat-brand` CSS variable on your page (`:root` or `body`): _(Developer only)_

```css
:root {
  --tks-chat-brand: #6366f1; /* indigo accent */
}
```

_(Developer only)_

The widget is fixed-position with high z-index (9001–9002), so it floats above all page content. It respects the font-family cascade and adapts to system fonts when available. _(Developer only)_

## Environment snippet _(Developer only)_

When you create an environment in your inFlow dashboard and link an agent to it, the generated snippet includes the chat div automatically: _(Developer only)_

```html
<!-- inFlow Toolkit — Production -->
<script src="https://api.inflow.build/toolkit.v2.js"
  data-tks-key="pk_..."
  data-tks-environment="67c3d4..."
  async></script>

<!-- AI Chat — renders as a floating widget -->
<div data-tks-chat="67a1b2c3d4e5f6a7b8c9d0e1"></div>
```

_(Developer only)_

The `data-tks-environment` attribute enables analytics attribution. `data-tks-site` is optional and only for tracking a specific inFlow Site. The script also starts analytics automatically; see [Embedding scripts](/docs/embed-scripts). _(Developer only)_
