Live chat is the chat button in the corner of a website. A visitor types a question, someone on the team sees it in an inbox within seconds and answers, and the reply appears in the visitor's chat window. Here is what happens under the hood, using Reponly's widget as the example.
1. The widget code
A live chat widget is a small script you add to your pages. This is the whole embed code:
<script src="https://reponly.com/widget.js" data-project="pk_your_project_key" async></script>asyncmeans the page doesn't wait for it: the script loads after your content.data-projectis the project key. It tells the chat service which product the chats belong to. It's public by design, like a site ID for analytics.- The script draws the chat button and, when it's opened, the chat window.
2. The chat window
The window runs in an iframe: a small separate page from the chat service, placed on top of your site. Your site's styles can't break it, and its code can't read your page. Reponly's button also sits in a shadow DOM, so your CSS and the widget's CSS never mix.
3. Sending a message
- The visitor types a message. The widget sends it to the chat service over HTTPS, with the page they're on and their device, so the team has context.
- The service stores it and starts a conversation the first time someone writes.
- Everyone on the team gets the new message instantly in their inbox, plus a desktop or email notification if they want one.
4. The reply, in real time
Both sides keep a live connection (a WebSocket) open to the chat service. When an agent replies, the service pushes the message down that connection and it appears in the visitor's window without a refresh. If the connection drops, the widget reconnects and catches up, so a message is never lost.
5. When nobody is online
Chat isn't only for when you're at your desk. The widget can ask for an email address. If the visitor leaves before an answer arrives, the reply goes to their inbox by email, with a link that reopens the same conversation.
6. Signed-in customers
By default, each browser is an anonymous visitor. If your product has accounts, your server can vouch for the signed-in user, so they see the same chat on every device and the team sees who they are. See Identify signed-in users.
Is a live chat widget safe?
- It's isolated. The chat runs in its own iframe with a strict content security policy: it only loads its own scripts and only talks to the chat service.
- Only your sites can show it. List your domains under Allowed domains and the chat can't be embedded anywhere else.
- The key isn't a secret. The project key only opens a chat; it can't read other visitors' conversations. Anything sensitive, like identifying users, is signed on your server with a secret that never reaches the browser.
- It's light. The loader is about 2 KB compressed, and the chat window only loads when a visitor reaches for the button.
Add it to your site
Paste the snippet before </body>, or follow the steps for your framework or site builder in Add live chat to a website. One account covers every site you run: see Live chat for multiple websites.