Repository navigation
Props Reference
Every prop of <WhatsAppChat>. All are optional except where noted. This page is generated from props.schema.json, which ships inside the npm package, so it matches the version you install.
Types used below are exported from the package: WhatsAppAgent, BusinessHoursConfig, PageContextOptions, PageContext, MessageDetails, WhatsAppChatLabels, ShowAfter, FormattedSubmission, IncomingMessage, WhatsAppTransportAdapter, WhatsAppAIConfig, WidgetDraft.
| Prop | Type | Default | What it does |
|---|---|---|---|
phoneNumber |
string |
required unless agents is set |
WhatsApp number in international format: 7–15 digits, optional leading +, no spaces or dashes. Required unless agents is set; used when no agent is selected. |
title |
string |
"Contact us" |
Heading inside the form. |
buttonLabel |
string |
"Chat on WhatsApp" |
Text on the launcher, and its accessible name in the icon variant. |
position |
'bottom-right' | 'bottom-left' | 'bottom-end' | 'bottom-start' |
"bottom-right" |
Where the widget sits. bottom-right and bottom-left are physical; bottom-end and bottom-start follow the reading direction (right in LTR, left in RTL for bottom-end). |
dir |
'ltr' | 'rtl' | 'auto' |
"auto" |
Text direction. auto follows the page. |
| Prop | Type | Default | What it does |
|---|---|---|---|
agents |
WhatsAppAgent[] |
— | People or departments to choose from. With two or more, a picker is shown and the chat opens with the selected agent's number. With one, that agent's number is used and no picker is shown. |
businessHours |
BusinessHoursConfig |
— | Opening hours. Shows an online/offline indicator and an offline notice outside hours. |
includePageContext |
boolean | PageContextOptions |
false |
Append the page title, URL (without query or hash), UTM source and optionally referrer to the message. true includes the title, URL and UTM parameters. |
| Prop | Type | Default | What it does |
|---|---|---|---|
variant |
'pill' | 'icon' |
"pill" |
pill shows the icon and label; icon shows only the round WhatsApp icon. |
theme |
'green' | 'brand' | 'dark' | 'light' | 'auto' |
"green" |
green (dark green), brand (bright WhatsApp green), light, dark, or auto (green launcher; the panel follows the visitor's light/dark preference). |
accentColor |
string |
— | Any CSS color. Overrides the theme's accent. |
size |
'sm' | 'md' | 'lg' |
"md" |
Launcher size. |
greeting |
string |
— | A short bubble above the closed launcher. |
showNotificationDot |
boolean |
false |
Show a small notification dot on the launcher until the widget is first opened. |
offset |
{ x?: number; y?: number } |
{"x":16,"y":16} |
Distance from the screen edges in pixels. |
zIndex |
number |
1000 |
CSS z-index of the widget. Can also be set with --wa-z-index. |
className |
string |
— | Extra class name on the root element. |
style |
CSSProperties |
— | Inline styles on the root element. |
iconOnly |
boolean |
deprecated | Deprecated: use variant="icon". |
| Prop | Type | Default | What it does |
|---|---|---|---|
fields |
{ name?: boolean; subject?: boolean } |
{"name":true,"subject":true} |
Set name or subject to false to hide that field. |
hint |
string |
"Prepare a draft here, then review and send it in WhatsApp." |
Replaces the helper text under the title. |
submitLabel |
string |
"Open in WhatsApp" |
Text on the form's submit button. |
defaultMessage |
string |
"" |
Pre-fills the message field. |
messageTemplate |
(details: MessageDetails) => string |
— | Builds the text sent to WhatsApp from the form details. Defaults to "Name:", "Subject:", the message, then the page context. |
labels |
Partial<WhatsAppChatLabels> |
— | Override built-in text, for translations. See Defaults for labels for every key. |
| Prop | Type | Default | What it does |
|---|---|---|---|
isOpen |
boolean |
— | Control the open state from outside. Pair with onOpenChange. |
defaultOpen |
boolean |
false |
Start with the form open (uncontrolled). |
onOpenChange |
(open: boolean) => void |
— | Called whenever the visitor opens or closes the form. |
showAfter |
number | ShowAfter |
0 |
Delay the launcher by milliseconds, or { ms, scrollPercent } to also wait for scrolling. |
hidden |
boolean |
false |
Render nothing. |
hideOnPaths |
string[] |
— | Hide on these pathnames; * matches any characters. Follows client-side navigation. |
| Prop | Type | Default | What it does |
|---|---|---|---|
transport |
'handoff' | WhatsAppTransportAdapter |
"handoff" |
How a conversation is delivered. "handoff" opens WhatsApp. An adapter with mode: "live" chats inside the widget. Create the adapter once, outside your component. See Live Chat. |
widgetId |
string |
"default" |
Stable ID for this widget. Keys the live chat in sessionStorage so a reload keeps the conversation. |
ai |
WhatsAppAIConfig |
— | Bring-your-own-AI hooks: polishMessage adds a "Polish with AI" button, and routeAndTriage can route to an agent, answer instantly, or refine the message. See Bring Your Own AI. |
onDeflection |
(event: { reply: string; resolved: boolean; submission: FormattedSubmission }) => void |
— | Called when the visitor answers an AI instant reply: resolved is true for "That solved it". |
webhookUrl |
string |
— | POST every submission to this URL as JSON without blocking the handoff (beacon, falling back to keepalive fetch). Failures are ignored. See Lead Webhooks. |
onBeforeHandoff |
(payload: FormattedSubmission) => void | Promise<void> |
— | Called with the submission before WhatsApp opens. An async callback is awaited for up to 1.5 seconds; errors are ignored. |
| Prop | Type | Default | What it does |
|---|---|---|---|
onOpen |
() => void |
— | Called when the form opens. |
onClose |
() => void |
— | Called when the form closes. |
onSend |
(details: MessageDetails, agent?: WhatsAppAgent) => void |
— | Called with the form details (and the chosen agent's id) when the visitor opens WhatsApp. |
injectStyles |
boolean |
true |
Inject the widget CSS automatically. Set to false to import whatsapp-chat-widget-react/styles.css yourself. |
onOpen?: () => void;
onClose?: () => void;
onOpenChange?: (open: boolean) => void;
onSend?: (details: MessageDetails, agent?: WhatsAppAgent) => void;
interface MessageDetails {
name: string;
subject: string;
message: string;
page?: PageContext; // present when includePageContext is enabled
}onSend runs just before WhatsApp opens (or when a live chat starts). The second argument is the selected agent when you use agents; with no agents the callback receives one argument only.
onDeflection?: (event: { reply: string; resolved: boolean; submission: FormattedSubmission }) => void;
onBeforeHandoff?: (payload: FormattedSubmission) => void | Promise<void>;
interface FormattedSubmission {
name: string; subject: string; message: string;
selectedAgent?: { id: string; name: string; role?: string };
pageContext?: { title?: string; url?: string; referrer?: string };
utm: Partial<Record<'utm_source' | 'utm_medium' | 'utm_campaign' | 'utm_term' | 'utm_content', string>>;
timestamp: number;
sessionId?: string; // live chat only
}The shapes of WhatsAppTransportAdapter, IncomingMessage and WhatsAppAIConfig are on the Live Chat and Bring Your Own AI pages.
{
name: 'Name',
subject: 'Subject',
message: 'Message',
close: 'Close WhatsApp form',
fillAll: 'Please fill in every field.',
invalidNumber: 'WhatsApp contact is unavailable: the phone number is invalid.',
online: 'Online',
offline: 'Offline',
offlineMessage: "We're offline right now. Leave a message and we'll reply when we're back.",
chooseAgent: 'Who would you like to chat with?',
// AI helpers (v0.8)
polish: 'Polish with AI',
polishing: 'Polishing…',
undo: 'Undo',
polished: 'Message polished. Undo is available.', // announced to screen readers
polishFailed: "Couldn't polish with AI. Your text is unchanged.",
routedTo: 'Routed to {name}', // {name} is replaced with the agent's name
thinking: 'Checking…', // submit button while routeAndTriage runs
instantReplyTitle: 'This might help',
solved: 'That solved it',
needHuman: 'Still need a human on WhatsApp',
resolved: 'Glad that helped!',
handoffReady: 'Your message is ready.', // shown when the browser needs a fresh click
openWhatsApp: 'Open WhatsApp',
// Live chat (v0.8)
conversation: 'Conversation',
composer: 'Your message',
send: 'Send',
sending: 'Sending…',
sent: 'Sent',
delivered: 'Delivered',
sendFailed: 'Not sent',
retry: 'Retry',
continueOnWhatsApp: 'Continue on WhatsApp app',
endChat: 'End chat',
you: 'You', // speaker names in the WhatsApp transcript
agent: 'Agent',
}title, hint, submitLabel and buttonLabel are separate props, not part of labels.
| Export | Use |
|---|---|
isOpenNow(config, now?) |
Check a BusinessHoursConfig yourself, for example to show hours elsewhere on your site. |
buildPageContext(option, env?) |
Build the page-context footer without the widget. |
matchesPath(pathname, patterns) |
The matcher behind hideOnPaths (* wildcard). |
WhatsAppWidgetProvider, useWhatsAppWidget()
|
Control the widget from anywhere. See Widget Hook and Provider. |
A separate entry point, so these stay out of your bundle unless imported.
| Export | Use |
|---|---|
createWebhookTransport(options) |
A live-chat adapter for n8n, Make, Zapier or any HTTP endpoint. See Live Chat. |
createOpenAICompatibleAI(options) |
Connects ai to any /v1/chat/completions endpoint. See Bring Your Own AI. |
dist/standalone.global.js exposes window.WhatsAppChatWidget with init, open, close, toggle, openWithDraft, isOpen, destroy and createOpenAICompatibleAI. See Script-Tag Build.