Chat Widget Setup

The RapiDesq chat widget lets you add real-time live chat to any website with a single script tag. This guide covers every aspect of widget configuration — from visual theming and pre-chat forms to routing, identity verification, and embedding.

Overview

The chat widget is an embeddable JavaScript component that creates a persistent live-chat interface on your website. When a visitor clicks the chat icon, a conversation window opens and connects them to your support team over a real-time connection. Messages are delivered instantly in both directions with no page reloads required.

Key capabilities of the widget include:

Creating a Widget

To create a new chat widget:

  1. Navigate to Admin > Channels > Chat Widget in the left-hand sidebar.
  2. Click Create Widget.
  3. Enter a Widget Name — a descriptive label for this widget (e.g., "Main Website Chat" or "Support Portal Widget"). This is only visible to your team.
  4. Work through the configuration sections described in this guide: Conversation Routing, Appearance, Messages, Conversation Start, Behavior, Allowed Domains, Conversation Closure, and Identity Verification.
  5. Click Create. The widget is created and ready to embed.

While you edit, a live preview shows exactly how the widget will look — in desktop and mobile sizes, on light and dark backgrounds, and even in a live mode where messages reach a real user queue. When editing an existing widget, the Widget Active toggle controls whether the widget is live; deactivating a widget takes it off your site without removing the embed code.

The Chat Widget admin page showing the widget list with embed code, edit, and delete actions The Chat Widget page in the admin portal, where widgets are created, configured, and embedded.
Tip Create separate widgets for different pages or sections of your site (e.g., "Support Portal Chat" vs. "Sales Landing Page Chat"). Each widget has independent configuration, making it easy to tailor the experience by source.

Conversation Routing

The Conversation Routing section of the widget editor controls where new conversations from this widget go. There are three routing modes:

If no routing is configured for a widget, conversations use your tenant's default routing rules — the editor shows a "Using default routing" notice in that case. You can change the routing target at any time without modifying your embed code.

Note See the Conversation Flows guide for building flows and the AI Bots guide for setting up bots.

Appearance & Theming

The Appearance section gives you control over the widget's visual presentation. All settings take effect for new visitors without any changes to your embed code.

Color and Branding

Setting Description
Primary Color Color used for the widget header, launcher button, and interactive elements. Enter a hex value or use the color picker.
Header Text Text displayed in the widget header bar. Defaults to "Chat with us".
Position Screen corner for the widget launcher: Bottom Right (default), Bottom Left, Top Right, or Top Left.
Widget Logo An uploaded image displayed in the chat widget header.
Widget Avatar An uploaded image used as the default avatar for automated messages in the widget.
Tip Bottom-right is the most familiar position for live chat and is recommended unless it conflicts with other elements on your page. If you use a floating action button in the bottom-right, consider Bottom Left to avoid overlap.

Dark Mode

If your website supports dark mode, the widget can adapt its colors to match. Turn on Enable Dark Mode Detection — the widget then detects the visitor's browser dark-mode preference and switches automatically. Three dark mode colors are configurable:

Setting Description
Dark Primary Color The accent color used for interactive elements, links, and buttons in dark mode. This replaces the standard primary color when dark mode is active.
Dark Header Background Background color for the widget header bar in dark mode. Use a dark, low-contrast color that is visually distinct from the message area.
Dark Message Background Background color for the conversation body in dark mode. Should be slightly lighter than the header to create visual hierarchy.
Note When dark mode detection is off, the widget always uses the standard primary color regardless of the visitor's system theme.

Messages

The Messages section configures the texts visitors see around the conversation:

Pre-Chat Forms

The Conversation Start section configures what happens when a visitor initiates a chat. Turn on Enable pre-chat form to collect contact information before the conversation begins. This gives your users context and populates the contact record automatically.

Standard Fields

The pre-chat form offers four built-in fields. Each can be independently shown or hidden, and each shown field can be marked as required:

Note The pre-chat form is intentionally lightweight — it collects contact identity only. If you need richer structured data collection (custom fields, dropdowns, validation), use a Web Form, which supports custom data fields from your field library, or route the widget to a Conversation Flow that asks questions in the chat itself.
Tip Keep pre-chat forms short. Every additional required field adds friction that may cause visitors to abandon the chat. Email is usually the one field worth requiring, since it links the conversation to a contact record.

Behavioral Settings

The Behavior section controls how the widget behaves during and around conversations.

Auto-Open Delay

The Auto-open Delay (seconds) setting causes the widget to open automatically after the visitor has been on the page for the specified number of seconds. This can increase engagement by proactively offering help. Leave the field empty to disable auto-open so the visitor must click the launcher.

Note Use a moderate delay (5–15 seconds) to avoid interrupting visitors who are still orienting themselves on the page.

Typing Indicators

When Show typing indicator is enabled, visitors see an animated typing indicator while a user composes a response. This reduces perceived wait time and reassures the visitor that their message is being addressed.

Bot Typing Delay

The Bot Typing Delay slider (0–5 seconds) controls how long a typing indicator is shown before automated messages — flow steps and bot replies — are displayed. A short delay makes automated responses feel more natural. Set it to 0 for instant delivery.

User Avatars

Enable Show user avatar to display the user's profile picture next to their messages in the conversation. This adds a personal touch and helps visitors feel they are talking to a real person.

File Uploads

The Enable file uploads toggle controls whether visitors can attach files (screenshots, documents, etc.) to their messages. When enabled, a file-attachment button appears in the message input area.

Emoji Picker

When Enable emoji picker is on, an emoji picker button appears alongside the message input, allowing visitors to insert emoji into their messages.

Conversation Closure

The Conversation Closure section controls what happens when conversations end:

Tip Enabling reopen with a reasonable timeout (30–60 minutes) is recommended. It prevents the frustrating experience of a visitor needing to repeat themselves when they have a quick follow-up question after a conversation is closed.

Bot Resolution Feedback

When an AI bot resolves a conversation without escalating to a human, the widget shows the visitor a quick thumbs up / thumbs down prompt asking whether the answer was helpful. The feedback is recorded against the conversation so you can monitor how well your bots are performing.

Embedding on Your Website

After configuring your widget, embed it on your site by adding the script tag to your HTML.

Getting the Embed Snippet

On the Chat Widget page, click the Get Embed Code action next to your widget. A dialog opens showing the snippet for that widget, along with a copy button and a reminder of any domain restrictions. The snippet looks like this:

<script
  src="https://<your-rapidesq-host>/widget.js"
  data-widget-id="YOUR_WIDGET_ID"
  data-api-url="https://<your-rapidesq-api-host>"
  data-tenant-id="YOUR_TENANT_ID"
  async>
</script>

The dialog generates the snippet with your real widget ID, tenant ID, and hosts filled in — just copy and paste. Place the snippet just before the closing </body> tag on every page where you want the widget to appear. The async attribute ensures the script loads without blocking page rendering — your page content loads first, and the widget initializes in the background.

Full Page Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>My Website</title>
</head>
<body>
  <!-- Your page content -->
  <h1>Welcome to our site</h1>

  <!-- RapiDesq Chat Widget — place just before </body> -->
  <script
    src="https://<your-rapidesq-host>/widget.js"
    data-widget-id="abc123-def456-ghi789"
    data-api-url="https://<your-rapidesq-api-host>"
    data-tenant-id="tenant-id-here"
    async>
  </script>
</body>
</html>

Allowed Domains

The Allowed Domains section restricts widget embedding to specific domains. This is an important security measure that prevents unauthorized sites from embedding your widget and consuming user time or impersonating your brand.

Important Always configure Allowed Domains for production widgets. Leaving the list empty means anyone who obtains your widget ID can embed your chat widget on their site.

Identity Verification

Identity verification lets you confirm the identity of logged-in visitors so your users can trust that the person chatting is who they claim to be. This is essential for support scenarios involving account-specific information, billing, or sensitive data — and it ensures verified visitors are matched to the right contact record reliably.

How It Works

Identity verification uses public-key signed tokens: your backend signs a short token for each logged-in user with a private key that only you hold, and RapiDesq verifies the signature using the public key you provide. RapiDesq never holds your signing key.

  1. Enable identity verification in the widget's Identity Verification section.
  2. Choose a signing algorithm — RSA (RS256/RS384/RS512), ECDSA (ES256/ES384/ES512), or EdDSA. RS256 is the default and works with standard JWT libraries.
  3. Paste your public key in PEM format. You keep the matching private key on your server.
  4. Your backend generates a signed token whenever a logged-in user loads a page with the widget. The token carries the visitor's identity claims.
  5. Pass the token to the widget after the script loads (see below). When the visitor starts a conversation, RapiDesq verifies the signature and attaches the verified identity to the conversation.

Token Claims

The token's email claim is required — it identifies the contact. Optional claims include externalId, name, firstName, lastName, and a customFields object. You can also configure Claim Mappings in the widget editor to map token claims onto contact fields or custom fields.

Backend Example (Node.js)

const jwt = require('jsonwebtoken');
const fs = require('fs');

// Your private key — RapiDesq only ever sees the public key.
const privateKey = fs.readFileSync('private-key.pem');

const token = jwt.sign(
  { email: 'user@example.com', name: 'John Doe' },
  privateKey,
  { algorithm: 'RS256' }
);

Passing the Token to the Widget

After the widget script loads, hand it the token:

window.ContactCenterWidget('init', { identityToken: 'SERVER_GENERATED_TOKEN_HERE' });

When identity verification is enabled for a widget, the embed code dialog includes these instructions, the claim reference, and a signing code sample.

Important Your private key must never be exposed in client-side JavaScript. Always generate the signed token on your server and pass only the token to the frontend. Because RapiDesq stores only the public key, your signing material cannot be forged even if widget configuration were exposed.
Note Identity verification is optional. When disabled, visitors chat anonymously or provide their details through the pre-chat form.

Business Hours

Widgets do not carry their own schedule. Business-hours behavior comes from where the widget's conversations are routed:

The widget's own Offline Message setting (in the Messages section) provides the text visitors see when your team is unavailable.

Note See Business Hours & Schedules for creating schedules, holiday exceptions, and applying schedules to teams and flows.

Testing Your Widget

Thorough testing ensures your visitors have a smooth experience. The widget editor's built-in preview covers most visual checks — it renders desktop and mobile sizes, light and dark backgrounds, and a live mode that sends real messages to your user queue. After embedding, work through the following scenarios on your actual site.

Basic Functionality

  1. Open your website in a browser and confirm the widget launcher icon appears in the configured position.
  2. Click the launcher. Verify the header text and welcome message display correctly.
  3. If the pre-chat form is enabled, fill it in and confirm required fields are enforced.
  4. Send a test message and confirm it appears in your RapiDesq inbox (or that the assigned flow or bot responds).
  5. Reply from the RapiDesq side and verify the response appears in real time in the widget.

Feature-Specific Checks

Cross-Browser and Device Testing

Verify the widget renders and functions correctly on:

Important Always test both online and offline user states. If you have configured identity verification, test with valid tokens, expired tokens, and no token to ensure each scenario is handled gracefully.

Configuration Reference

A summary of the widget editor's settings, grouped by section.

Setting Section Description
Widget NameGeneralInternal label for the widget.
Widget ActiveGeneralEnable or disable the widget (edit mode).
Routing Mode / TargetConversation RoutingDirect to Team, Conversation Flow, or AI Bot, plus the selected target.
Primary ColorAppearanceColor for header, launcher, and accents.
Header TextAppearanceHeader bar text. Default "Chat with us".
PositionAppearanceBottom Right (default), Bottom Left, Top Right, or Top Left.
Widget LogoAppearanceUploaded image shown in the widget header.
Widget AvatarAppearanceUploaded default avatar for automated messages.
Enable Dark Mode DetectionAppearanceFollow the visitor's browser dark-mode preference.
Dark Primary Color / Dark Header Background / Dark Message BackgroundAppearanceThe dark-mode color set.
Welcome MessageMessagesGreeting when the widget opens.
Offline MessageMessagesMessage when your team is unavailable.
Enable pre-chat formConversation StartCollect contact information before the chat begins.
Standard Fields (Name, Email, Phone, Company)Conversation StartEach field independently shown and optionally required.
Auto-open Delay (seconds)BehaviorOpen automatically after a delay; empty disables.
Show typing indicatorBehaviorShow a typing indicator while the user types.
Bot Typing DelayBehaviorTyping-indicator duration before automated messages (0–5s).
Show user avatarBehaviorDisplay user profile pictures.
Enable file uploadsBehaviorAllow visitors to attach files.
Enable emoji pickerBehaviorShow an emoji picker in the message input.
Allowed DomainsAllowed DomainsDomains where the widget can be embedded (empty = all).
Allow contacts to reopen closed conversationsConversation ClosurePermit reopening within the timeout window.
Reopen Timeout (minutes)Conversation ClosureReopen window, up to 24 hours. Default 60.
Default Close MessageConversation ClosureShown when a user closes without a custom message.
Enable identity verificationIdentity VerificationRequire signed identity tokens from your backend.
Signing Algorithm / Public Key (PEM)Identity VerificationRSA, ECDSA, or EdDSA; you paste only the public key.
Claim MappingsIdentity VerificationMap token claims to contact fields or custom fields.