Skip to main content
This guide shows how to embed Meridial Voicebox into any React application, including frameworks such as Next.js, Remix, React Router, Gatsby, Vite, and more.

1) Install the package

2) Embed Voicebox in your app

<Voicebox /> is the single component you embed. It renders a trigger button and the user-facing support widget for live voice support and human support escalation. Add it where you want in-app support to be available:
publishableKey comes from your Meridial dashboard. Use identifier to associate sessions with a specific user.
The "use client" directive is required in Next.js App Router. In other React frameworks you can omit it as per your framework’s documentation.

Props

Custom trigger

Pass children to replace the default trigger button content:

Agent tools

The SDK exports tool and useTool so the agent can perform actions in your application (navigate, fill forms, read state, and so on). Define a tool with a Zod input schema and an execute handler:

Registering tools from child components

When a tool needs access to local component state (for example, a form on the current page), use useTool instead of passing tools through <Voicebox /> props:
Tools registered via useTool are merged with any tools passed to <Voicebox />. On key conflicts, hook-registered tools take precedence.

Prompting the agent

When the Voicebox session is connected, useTool returns an optional generateReply function. Call it after app milestones (e.g. onboarding steps) to have the agent speak with custom instructions.
generateReply is undefined when the Voicebox is closed or not connected.
Instructions passed to generateReply are truncated to a maximum of 1,000 characters. This limit is enforced on both the client and the agent as a safeguard against issues with overly long prompts.

Styling

The component uses Tailwind CSS and is designed to work with existing Tailwind / shadcn setups. Two options:

Option 1: scan the package with your Tailwind build

In your global stylesheet:
Adjust the relative path to match your stylesheet’s location.

Option 2: import the prebuilt CSS

If you don’t want Tailwind to scan the package: