Preview brand Custom

Chat button

A speech-bubble button at the bottom right of every page that opens a small panel to start a WhatsApp chat in the visitor's own WhatsApp.

Beta

Your business

We usually reply within a few hours

Hello! Ask us anything. (In this example the WhatsApp number isn’t set, so it shows the demo note.)

Demo: add the WhatsApp Business number to the site settings to switch this on. It opens a chat in the visitor’s own WhatsApp.

Or email hello@example.com

Your business

We usually reply within a few hours

Hello! Ask us anything. (In this example the WhatsApp number isn’t set, so it shows the demo note.)

Demo: add the WhatsApp Business number to the site settings to switch this on. It opens a chat in the visitor’s own WhatsApp.

Or email hello@example.com

Show code
yaml
# src/content/settings/chat.yaml (edited in Somnia CMS; or `chat` in somnia.config.mjs)
whatsapp: "447700900000"   # international, digits only
greeting: Hello! How can we help?
prefill: Hello, I have a question about…
hours:
  tz: Europe/London
  days: [1, 2, 3, 4, 5]
  from: "09:00"
  to: "18:00"
  label: UK time

The example shows the panel. The button itself floats at the bottom right of a site's pages; these docs are pages for looking things up, which have none, so its checks below are run on this site's home page.

When to use it

  • The business already answers WhatsApp messages and wants to be asked questions that way.
  • Someone is really there to answer within the hours it shows.

Use something else when:

  • Nobody watches WhatsApp: the contact page and its form.
  • The page is one people look things up on (docs, a brand guide): it has no chat button.

Why not a chat widget

Live-chat widgets load third-party scripts and usually set cookies, which brings a cookie banner. This is a plain link to wa.me: the conversation happens in WhatsApp, where the business already answers messages.

How it works

  • The button opens a small panel: the business's name, whether someone is there, a greeting, a link that opens WhatsApp with a first message started, and the email address as another way.
  • With hours it says whether someone is there now ("Online now") or when they'll reply ("from 09:00 UK time", adding "tomorrow" or the day, e.g. "on Monday", when the next opening isn't later today), worked out in the business's time zone, and shows a green dot on the button during opening hours.
  • Without a whatsapp number it shows on staging only, as a demo; a live page without one doesn't load its script at all.
  • The panel closes with Escape or its Close button, and focus goes back to the chat button.
  • Nudge: after four seconds on a page a small "Chat with us" bubble appears over the button, and the whole lockup (bubble and button) bounces gently twice, or a ring pulses three times. Choosing the bubble opens the chat; its × dismisses it. Either way it doesn't come back for the rest of the visit (the browser tab's session). No movement for visitors who ask for reduced motion. Set chat.nudge to { text, delay, motion } to change the wording, timing or movement, or false to switch it off.
  • The speech bubble is the button, with no circle round it: filled in color.chat.button, its three dots in color.chat.icon, with a soft shadow so it reads over photos and video. Both follow the brand's accent unless the brand sets its own (Headland: navy with white dots in light mode, sand with navy dots in dark, like its Enquire button).
  • It moves up out of the way of a bar a page fixes along the bottom (--somnia-bottom-bar), leaves room at the foot of the footer, and steps aside while the phone menu is open.
  • Everything in it is edited in Somnia CMS (WhatsApp chat): the number, the greeting, the hours, the bubble, and a switch that takes it off every page.

Do and don't

Do

  • Set the hours someone really answers in
  • Write a greeting that says what to ask about
  • Keep the email address in the panel, for people without WhatsApp

Don't

  • Show it with nobody to answer
  • Add a second floating button beside it
  • Make the bubble come back after it has been closed

Accessibility

What it does for you

  • A real button, 60px across, named "Chat with us", that says whether its panel is open.
  • Opening moves focus into the panel; Escape or Close shuts it and puts focus back on the button.
  • The panel is a dialog named for the business. It doesn’t trap focus: Tab goes on through it and back to the page.
  • The WhatsApp link says it opens WhatsApp. The email address is in the panel for anyone without it.
  • The "Chat with us" bubble has its own close button, isn’t announced when it appears, and doesn’t come back in the visit once closed or used.
  • With reduced motion nothing bounces or pulses. Otherwise the movement stops by itself after two bounces or three pulses.
  • In the same place on every page, and out of the way of the phone menu and of a bar fixed along the bottom.

What you need to do

  • Hours that are true: "Online now" is a promise.
  • A greeting in plain words, and an email address for people without WhatsApp.

Keyboard

KeyWhat it does
TabReaches the button last on the page, after the footer; in the open panel, goes through Close, the WhatsApp link and the email link.
Enter or SpaceOpens or closes the panel.
EscapeCloses the panel and returns to the button.

What a screen reader is told

  • The button: "Chat with us", collapsed or expanded.
  • The panel: a dialog, "Chat with" and the business’s name.
  • The link: "Chat on WhatsApp (opens WhatsApp)".

This is what the browser reports to assistive technology. What each screen reader then says varies, and has not been listened to yet.

WCAG 2.2

CriterionLevelHow this meets it
2.1.1 KeyboardANative buttons and links throughout.
2.1.2 No Keyboard TrapANothing holds the focus: Tab leaves the panel and Escape closes it.
2.2.2 Pause, Stop, HideAThe bubble’s movement stops by itself in under five seconds, and not at all with reduced motion.
2.4.3 Focus OrderAFocus goes into the panel when it opens and back to the button when it closes.
2.5.8 Target Size (Minimum)AAThe button is 60px across; Close and the bubble’s × are 32px.
3.2.6 Consistent HelpAHelp is in the same place on every page that has it.
4.1.2 Name, Role, ValueAA button with its open or closed state, and a named dialog.

The criteria this component has a part in. A page that uses it still has to meet the rest.

Checked

CheckHowResult
Automated (axe-core)WCAG 2.0, 2.1 and 2.2 rules at A and AA, the page in light and in darkPassed
Nothing found, light or dark
Narrow screenNo sideways scrolling at 320px wide (WCAG 1.4.10)Passed
No sideways scrolling
Keyboard and what the browser reportsReal key presses on the live example, and the role, name and state given to assistive technologyPassed
9 of 9 checks pass
On paperSomnia’s print check: no overlaps, stranded headings or controls on the pagePassed
No faults on 6 sheets
Screen readerListened to by a person, in VoiceOver and NVDANot yet
Not yet checked by a person

The 9 checks made with the keyboard, on the example at the top of this page:

  • Passed On a site’s page the button is named "Chat with us" and says its panel is closed
  • Passed Enter opens the panel, the button says so, and focus moves into the panel
  • Passed The panel is a dialog named for the business
  • Passed Tab goes through Close, the WhatsApp link and the email link, then back to the button
  • Passed Escape closes it and focus goes back to the button
  • Passed The WhatsApp link says it opens WhatsApp
  • Passed The button is 60px across
  • Passed The "Chat with us" bubble has its own close button, and stays away once closed
  • Passed With reduced motion, nothing bounces or pulses

Run by script on against Somnia DS 1.89.0, in Chromium with axe-core 4.14.0. How these checks work, and every component's results.

Not yet checked

  • How it sounds in a screen reader (VoiceOver, NVDA, TalkBack) has not been checked by a person. The roles, names and states the browser reports are checked by script; what is actually spoken is not.
  • Windows high contrast (forced colours) has not been looked at by a person.
  • Whether the floating button can cover something that has keyboard focus at the bottom right of a page (WCAG 2.4.11) has not been checked page by page.
  • The button comes last in the Tab order. Whether that is too far for people who use it by keyboard has not been tested.

Evidence

Where it's used

WhereFor
mediadreams.co.ukEvery page except these docs and the brand guidelines.
Headland YachtingIts pages, with its opening hours.

What we saw, and what changed

WhenWhat we sawWhat changed
The speech bubble sat inside a circle.The bubble is the button, with no circle round it, in its own color.chat colours with a soft shadow (1.28.0).
Outside opening hours it gave a time with no day, whenever the next opening was.It adds "tomorrow" or the day: a Friday evening says "on Monday" (1.26.0).
The "Chat with us" bubble could only bounce, and its timing was set in the site’s config.When it appears and how it moves (bounce, a pulsing ring, or none) are settings in Somnia CMS (1.45.0).
On an iPhone it covered the phone menu’s last buttons.It steps aside while the menu is open (1.76.1).
It floated over these docs, which people read to look things up.Reference pages have no chat button (1.80.0).
The check written for this page found the bubble still bounced or pulsed for people who ask for reduced motion: the rule that stops it had been outranked since the choice of movement was added in 1.45.0.Nothing moves with reduced motion (1.82.0).

From building and using it on real sites, each entry taken from the changelog or the build's own notes. This is observation by the studio and its clients, not research sessions with users.

What it rests on

What we don't know yet

  • How many chats it starts isn’t counted: the link opens WhatsApp and nothing is recorded.
  • Whether the bubble helps or annoys has not been asked of anyone.