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
Passchildren to replace the default trigger button content:
Agent tools
The SDK exportstool 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), useuseTool instead of passing tools through <Voicebox /> props:
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.