Skip to content

Recipes

Mcdavid Obioha edited this page Dec 2, 2026 · 2 revisions

Recipes

Copy, paste, adjust. Each recipe is a complete <WhatsAppChat> element.

Minimal

<WhatsAppChat phoneNumber="+12025550123" />

Round icon in the corner

<WhatsAppChat phoneNumber="+12025550123" variant="icon" theme="brand" position="bottom-left" />

Message-only form (no name or subject)

<WhatsAppChat
  phoneNumber="+12025550123"
  title="Quick question?"
  fields={{ name: false, subject: false }}
  hint="Typically replies within an hour."
  submitLabel="Send on WhatsApp"
/>

Sales and support with business hours

<WhatsAppChat
  title="Talk to us"
  agents={[
    { id: 'sales', name: 'Ada Obi', role: 'Sales', phoneNumber: '+2348011111111' },
    { id: 'support', name: 'Tunde Bello', role: 'Support', phoneNumber: '+2348022222222' },
  ]}
  businessHours={{
    timezone: 'Africa/Lagos',
    schedule: { mon: ['09:00', '17:00'], tue: ['09:00', '17:00'], wed: ['09:00', '17:00'], thu: ['09:00', '17:00'], fri: ['09:00', '17:00'] },
    offlineMessage: 'We reply Monday to Friday, 9am to 5pm WAT.',
  }}
/>

Track where leads come from

<WhatsAppChat
  phoneNumber="+12025550123"
  includePageContext
  onSend={({ page }) => analytics.track('whatsapp_lead', { url: page?.url, source: page?.utm.utm_source })}
/>

Open from a button in your page

const [open, setOpen] = useState(false);

<button onClick={() => setOpen(true)}>Chat with us</button>
<WhatsAppChat phoneNumber="+12025550123" isOpen={open} onOpenChange={setOpen} />

Gentle nudge: delayed launcher with a greeting

<WhatsAppChat
  phoneNumber="+12025550123"
  variant="icon"
  showAfter={{ ms: 4000, scrollPercent: 20 }}
  greeting="Chat with us 👋"
  showNotificationDot
/>

Prefill the message from the page

<WhatsAppChat
  phoneNumber="+12025550123"
  defaultMessage={`Hi, I'm interested in ${product.name}.`}
  fields={{ subject: false }}
/>

Keep it off sensitive pages

<WhatsAppChat phoneNumber="+12025550123" hideOnPaths={['/checkout/*', '/account/*', '/login']} />

Dark mode that follows the device

<WhatsAppChat phoneNumber="+12025550123" theme="auto" />

Brand colors

<WhatsAppChat phoneNumber="+12025550123" accentColor="#6d28d9" />

Or site-wide, with CSS:

:root { --wa-primary: #6d28d9; --wa-radius: 1.25rem; }

Arabic, right-to-left

See Right-to-Left and Translations for the full example.

Custom message format

<WhatsAppChat
  phoneNumber="+12025550123"
  messageTemplate={({ name, subject, message }) => `[Website enquiry]\nFrom: ${name}\nAbout: ${subject}\n\n${message}`}
/>

Save every lead to Slack, Sheets or a CRM

<WhatsAppChat phoneNumber="+12025550123" includePageContext webhookUrl="https://hooks.example.com/whatsapp-lead" />

See Lead Webhooks for the payload and recipes for n8n, Make, Zapier, Slack and HubSpot.

Open the widget with a pre-filled message

<WhatsAppWidgetProvider>
  <WhatsAppChat agents={agents} />
  <PlanButton plan="Pro" />   {/* calls useWhatsAppWidget().openWithDraft({ subject: 'Pro plan', ... }) */}
</WhatsAppWidgetProvider>

See Widget Hook and Provider.

Polish messages and route to the right agent with AI

const ai = createOpenAICompatibleAI({ endpoint: '/api/whatsapp-ai', model: 'gpt-4.1-mini', enableRouting: true });

<WhatsAppChat agents={agents} ai={ai} />

See Bring Your Own AI and Backend Recipes.

Live chat through n8n

const transport = createWebhookTransport({ sendUrl: '/n8n/chat-send', pollUrl: '/n8n/chat-replies' });

<WhatsAppChat phoneNumber="+12025550123" transport={transport} widgetId="support" />

See Live Chat.

WordPress, Webflow or Shopify

<script src="https://cdn.jsdelivr.net/npm/whatsapp-chat-widget-react@0.8.0/dist/standalone.global.js"
  data-phone="+12025550123" data-theme="brand" defer></script>

See Script-Tag Build.

Clone this wiki locally