Installable Chat Page (PWA), Chat Links & Web Push
Feature Installable Chat Page (PWA) on Mahadata allows customers to move from WhatsApp (or any channel) to a full chat page owned by your brand that can be installed to the home screen (Add to Home Screen) as a Progressive Web App — remaining the same contact, with support Web Push notification support when an agent or bot replies while the customer is not viewing the chat page.
For step-by-step guidance for admins and agents in the portal (enabling PWA on the widget and copying Chat link from the inbox), see Installable Chat Page (PWA) & Chat Links.
1. Enabling the Chat Page (PWA)
Section titled “1. Enabling the Chat Page (PWA)”- Open Settings > Channels > Webchat then select your widget and open the Install.
- In the Installable chat page (PWA):
- Enable the toggle Installable chat page (
config.pwa.enabled = true). The page origin is automatically set to your trusted portal/chat origin (config.pwa.origin). - Set Link valid for (hours) (
config.pwa.link_ttl_hours, range1–168hours, default24hours). - Enable Push notifications (
config.pwa.push_enabled = true) so that visitors can receive Web Push notifications when the tab is inactive.
- Enable the toggle Installable chat page (
- Click Save Changes.
Once enabled, the standalone chat page is available at:
https://chat.example.com/id/webchat/chat/<WIDGET_UUID>This page serves a per-widget Web App Manifest (/api/webchat/manifest/<WIDGET_UUID>) and dynamic icon (192x192 & 512x512 in /api/webchat/icon/<WIDGET_UUID>) according to your widget’s primary color, header title, and logo.
2. Sending a Single-Use Chat Link
Section titled “2. Sending a Single-Use Chat Link”Each chat link is single-use (single-use), has a limited validity period, and only stores the SHA-256 hash of the token in the database. When a customer opens the link:
https://chat.example.com/webchat/l/<TOKEN>the token is exchanged atomically in the customer’s browser (so that WhatsApp/iMessage link preview bots that only perform GET do not consume the token), binding the Webchat session directly to the same contact_id , and redirecting the customer to the PWA chat page. If the link is opened a second time or has expired, the customer sees a notification card stating that the link is no longer valid.
There are three ways to create a chat link:
A. From the Agent Inbox (“Chat link”)
Section titled “A. From the Agent Inbox (“Chat link”)”In a non-Webchat conversation (e.g., WhatsApp, Instagram, or Telegram), open the action menu (⋮) in the conversation header, then click Chat link:
- If the tenant has more than one widget with PWA enabled, select the destination widget.
- The system creates a one-time link via
POST /api/inbox/conversations/{id}/chat-link. - Click Insert into reply to insert the URL into the reply composer (or Copy the), then send the message to the customer.
B. From the Automation Flow Builder (Create chat link + Template URL Button)
Section titled “B. From the Automation Flow Builder (Create chat link + Template URL Button)”In the automation flow builder, add the Create chat link (createChatLink):
- Select the destination PWA widget (or use the first PWA widget by default) and the link expiration (
1–168hours). - When executed, this node populates three flow variables:
{{chat_link_url}}— full URL (for examplehttps://chat.example.com/webchat/l/AbCdEf...) to be inserted in the Send Message step as regular.{{chat_link_token}}— only the token part to be used in a WhatsApp template dynamic URL button with the base URL formathttps://chat.example.com/webchat/l/{{1}}and button variables{{chat_link_token}}.{{chat_link_expires_at}}— link expiration time in RFC 3339 format.
C. Via REST API (POST /v1/webchat/links)
Section titled “C. Via REST API (POST /v1/webchat/links)”Use your tenant’s API Key (Authorization: Bearer <API_KEY>) to create links programmatically. You can specify a contact using contact_id or E.164 phone number (phone):
curl -X POST "https://api.example.com/v1/webchat/links" \ -H "Authorization: Bearer mhd_live_xxxxxxxxxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{ "widget_id": "00000000-0000-0000-0000-000000000000", "phone": "+6281200000000", "ttl_hours": 24 }'Example response (200 OK):
{ "link_id": "11111111-1111-1111-1111-111111111111", "url": "https://chat.example.com/webchat/l/k8mP2xQ9vL4nR7tY1wZ3bC6dF0gH5jK8", "token": "k8mP2xQ9vL4nR7tY1wZ3bC6dF0gH5jK8", "expires_at": "2026-11-01T12:00:00Z"}3. Customer Experience: Install the App & Web Push Notifications
Section titled “3. Customer Experience: Install the App & Web Push Notifications”When a customer opens the PWA chat page (/webchat/chat/<WIDGET_UUID>):
- Install App Banner:
- On Chrome/Edge (Android & Desktop), the banner offers a Install button that triggers the browser’s native PWA install dialog (
beforeinstallprompt). - On iOS Safari, the banner shows a brief instruction: “Tap Share, then ‘Add to Home Screen’ to install this chat.”
- On Chrome/Edge (Android & Desktop), the banner offers a Install button that triggers the browser’s native PWA install dialog (
- Web Push Notification Opt-in:
- After the customer sends their first message, a non-blocking banner offers a Enable notification.
- When the customer approves the browser notification permission, a visitor-specific Service Worker (
/webchat-sw.jswith scope/<locale>/webchat/) register a Web Push VAPID subscription. - Customers can turn off notifications at any time via the
⋮in the chat header (Turn off notifications).
- Presence-Based Smart Push Delivery (Presence):
- ) As long as the customer’s chat tab is open and visible (
document.visibilityState === "visible") updates the short-TTL Redis presence key and not suppresses intrusive push notifications. - ). When the customer closes the tab, minimizes the app, or locks the screen, replies from agents or automatic bots trigger a Web Push (RFC 8291
aes128gcm) containing the widget title and a message snippet. Tapping the notification will refocus or open the chat page.
- ) As long as the customer’s chat tab is open and visible (
Platform Notes (iOS & In-App Browser)
Section titled “Platform Notes (iOS & In-App Browser)”- iOS / iPadOS: Apple only allows Web Push on web apps that have been added to the Home Screen (Add to Home Screen) on iOS 16.4 or laterIn-App Browsers (
PushManager. - In-App Browser (In-App Browsers): If the customer opens the link from inside a social app’s WebView that restricts Service Worker or Web Push, real-time chat over WebSocket still works fully; to install the PWA and enable push, the customer can choose Open in Chrome / Safari.
4. PWA Lifecycle Webhook Events (pwa_*)
Section titled “4. PWA Lifecycle Webhook Events (pwa_*)”You can subscribe to six PWA-specific events on Menu > Developer > Webhook (/developer/webhooks):
| The | When Triggered | Field data Primary |
|---|---|---|
pwa_redirect_clicked | Link /webchat/l/<token> successfully redeemed for the first time | link_id, visitor_id, widget_id, source_conversation_id |
pwa_session_started | WebSocket connection opened on the PWA page (pwa=1) or a session originating from a chat link | visitor_id, widget_id, link_id, resumed |
pwa_message_sent | Visitor sends a message from a PWA session | visitor_id, widget_id, message_id, message_type, text_preview |
pwa_message_received | Agent or bot reply is sent to the visitor’s PWA session | visitor_id, widget_id, message_id, sender (agent | bot), text_preview |
pwa_push_delivered | Server push receives a Web Push notification delivery (2xx) for visitors | visitor_id, widget_id, subscription_id, message_id |
pwa_session_closed | PWA WebSocket connection is closed and after a 5-second grace period there is no active connection back | visitor_id, widget_id |
See the Webhook Configuration for the complete webhook envelope format and HMAC signature verification.