Add in-app support to a web app

Give your web app a "Get help" button that shares the customer's browser tab with your support team, with consent, in your own name, colour and logo.

Embed
Preview of the card
<a href="https://gaiadesk.net/docs/web-in-app-support"><img src="https://gaiadesk.net/docs/_api/public/orgs/89a5df38-be2c-4963-8823-21d4bd40a2ab/spaces/57b99ea0-d45a-4986-8aa6-6b0683c9fe1d/pages/e8a56ee2-1ff3-4fd3-92fb-5b126e37efa9/social-card.svg?v=3e7ae33eec8b" alt="Add in-app support to a web app" width="600" height="315"></a>

Give your web app a "Get help" button: your customer clicks it and agrees, and your support team sees your page in the GaiaDesk console — and, if you allow it, guides it — without the customer installing anything.

GaiaDesk's web SDK, @gaiadesk/embed 0.1.0 (on npm), runs in the page itself: TypeScript, no runtime dependencies, as an ES module or a <script> tag. It is open source (MIT), at github.com/Gaia-Desk/gaiadesk-embed. There is no native library: the browser shares the tab, and the SDK sends it over WebRTC. For how the SDKs fit together, see in-app support.

What your customer sees

  • One button. Your page shows "Get help" wherever you put it.

  • A consent dialog in your colours. It names your company, says that only this browser tab will be shared, that private fields stay hidden, and whether your team will be able to guide it. Nothing is shared until the customer agrees.

  • The browser's own share prompt. After "Share this tab", the browser asks which tab to share; the customer picks this one.

  • A bar for as long as anything is shared. "Sharing with Acme support · Stop", drawn by the SDK at the bottom of your page. In a guided session it also has Pause control.

  • A support code. Nine digits, shown on the bar, that your customer can read to an agent over the phone.

When the session ends — the customer presses Stop (or the browser's own "Stop sharing"), your page stops it, the session expires, or the tab closes — sharing stops at once: the capture, the connection and the session all end.

What your support team sees

Agents open Support in the GaiaDesk console, see the waiting customer (with the details your page or backend passed) and join, or type the support code. Only your own account and team can join, and only team members with a support seat.

1. Install

npm install @gaiadesk/embed

Or, without a bundler, load the <script> build, which defines a global GaiaDeskEmbed:

<script src="https://cdn.jsdelivr.net/npm/@gaiadesk/embed@0.1.0/dist/gaiadesk-embed.min.js"></script>

2. Choose how sessions are created

A publishable key (no backend)

On your GaiaDesk account page, open API keys, create a Publishable key, and register the origins of the pages that will use it — for example https://app.example.com.

A publishable key can do one thing: create support sessions, at most an hour long, from those origins. It is safe to ship in your page. The customer details it sends are your page's word, and the console shows them as unverified.

GaiaDeskEmbed.start({
  publishableKey: "pk_live_…",
  customer: { name: "Ada", plan: "pro" },
  mode: "cobrowse",   // or "view" (the default)
  branding: { name: "Acme" },
});

The SDK then creates the session itself. expiresIn sets its length in seconds, from 60 to 3600 (default 3600).

Sessions from your own backend

If you would rather decide on the server who may get help, and pass verified customer details, create the session there with a secret API key (scope support) and hand the page only its embed token:

curl -s -X POST https://api.gaiadesk.net/v1/support/sessions \
  -H "Authorization: Bearer $GAIADESK_API_KEY" -H "Content-Type: application/json" \
  -d '{"mode": "cobrowse", "customer": {"name": "Ada", "plan": "pro"}, "origin": "https://app.example.com"}'

origin is optional; when you set it, the session can only be opened from that origin. The response carries embed_token (gdemb_…), which your page passes on:

GaiaDeskEmbed.start({ embedToken, mode: "cobrowse", branding: { name: "Acme" } });

With an embed token, the session is whatever your backend asked for: customer and expiresIn in the page are ignored. mode still sets the consent dialog's wording, so pass "cobrowse" when your backend created a cobrowse session, or the dialog will not tell your customer they can be guided. Never ship the secret key in your page: the embed token is all it needs. The full request is in the support API reference.

3. Add the button

import { GaiaDeskEmbed } from "@gaiadesk/embed";

const button = document.querySelector<HTMLButtonElement>("#help")!;
const status = document.querySelector<HTMLElement>("#help-status")!;

button.addEventListener("click", () => {
  if (GaiaDeskEmbed.state() !== "idle") {
    GaiaDeskEmbed.stop();
    return;
  }
  const help = GaiaDeskEmbed.start({
    publishableKey: "pk_live_…",
    customer: { name: "Ada", plan: "pro" },
    mode: "cobrowse",
    branding: { name: "Acme", color: "#0f766e" },
  });
  button.textContent = "Stop sharing";
  help.on("ready", ({ joinCode }) => (status.textContent = `Your support code is ${joinCode}`));
  help.on("joined", ({ agent }) => (status.textContent = `${agent ?? "An agent"} is viewing this tab`));
  help.on("error", ({ code, message }) => (status.textContent = `Could not share: ${message} (${code})`));
  help.on("ended", () => (button.textContent = "Get help"));
});

That is the whole integration. start shows the consent dialog at once, so call it from your button's click. It returns a handle with state, on(event, fn) (which returns a function that stops listening) and stop(). One session runs per page at a time: calling start while one runs returns the running one.

Event

Detail

state

{ state }: consent, starting, waiting, connected, ended

ready

{ sessionId, joinCode, mode }: the session is up; joinCode is the support code

joined / left

{ agent } (the agent's email, when known) / {}

control

{ allowed }: the customer paused or allowed guiding

action

{ type, applied, reason? }: an agent's request and what became of it

error

{ code, message }

ended

{ reason }: stopped, declined, expired, disconnected or error

ended is always last. A customer who says no — in your dialog or the browser's prompt — ends the session with declined.

branding puts your brand on the consent dialog, the bar and the agent's pointer:

branding

name

"Sharing with Acme support". Without it, the SDK says "our support".

color

Accent colour, #rgb or #rrggbb: buttons and the bar.

textColor

Text colour on the accent, #rgb or #rrggbb. Default white.

logoUrl

An https: URL or a data:image/… URL (PNG, JPEG, GIF, WebP or SVG), shown on the consent dialog.

A colour or logo in any other form is ignored, and the default is used.

Guided sessions

By default your team can only look. To let them guide, use mode: "cobrowse" with a publishable key, or create the session as cobrowse on your backend (and pass mode: "cobrowse" to start too, for the dialog's wording). The agent's pointer and highlights then appear in your page, labelled with your company's name, and their clicks, scrolls, typing and a few keys (Enter, Tab, Backspace, Delete, Escape, the arrows, Home, End) are applied as synthetic events in your page. Never:

  • outside this page, or on the SDK's own dialog and bar;

  • on a masked element or a password;

  • on a file picker, a javascript: link, or a link or form that leaves your origin;

  • more than 500 characters at once, or more than 20 requests a second.

Guiding works only when the browser confirms the shared tab is this one, which Chromium-based browsers do today. Elsewhere your team can still see, but not act. Your customer can pause guiding at any time from the bar, and allow it again.

Keeping things private

  • This tab only. The share must be a browser tab: if the customer picks a window or a whole screen, the SDK stops it at once and the session ends with an error (not_a_tab), because content around your page could not be masked. Other tabs, windows and apps are never shared.

  • Masks. Mark anything sensitive — card numbers, balances — with data-gaiadesk-mask; everything inside it is masked too. Password fields, and inputs whose autocomplete is current-password, new-password, one-time-code, cc-number or cc-csc, are masked without being asked. Masked areas are painted over in every frame before it leaves the page, and stay covered for a few frames as they scroll.

    <div data-gaiadesk-mask>Account balance: $12,345.67</div>
  • Consent every time. The SDK asks before every session; there is no option that skips the dialog or hides the bar.

@gaiadesk/consent 0.1.0 (npm) is GaiaDesk's consent step as a web component, <gaiadesk-consent>, with a React wrapper. It asks your customer in your app's own page, themed to it and worded your way, localized in 14 languages and fully keyboard and screen-reader accessible: a live preview of exactly what support will see (masked fields blacked out), per-session choices, who is waiting, links to your privacy policy and terms, an optional auto-decline, and a consent receipt stored on the session (see Proof of consent). It takes the same options and wording as the native library's dialog (libgaiadesk_embed 0.4.0).

The web SDK above, @gaiadesk/embed 0.1.0, keeps its own in-page consent dialog. <gaiadesk-consent> is mainly for desktop apps with a webview, where the native library is its bridge and takes the preview and makes the receipt: the Tauri plugin's consentBridge and @gaiadesk/embed-native's (run in Electron's main process over IPC, with the sandbox on).

npm install @gaiadesk/consent
import '@gaiadesk/consent'; // registers <gaiadesk-consent>

const el = document.body.appendChild(document.createElement('gaiadesk-consent'));
el.bridge = bridge;          // a ConsentBridge: the Tauri or Electron one, or webBridge (below)
const d = await el.open({ company: 'Acme', guided: true, masked: true, choices: { offer_logs: true } });
el.remove();
// d: { decision: "accepted" | "declined" | "timeout", choices, consent_token, receipt }

el.open(options) rejects with a ConsentError whose code is bad_config (an option the library would refuse, unknown keys included), no_bridge, already_open, closed (el.close(), or the element was removed), or the bridge's own. It fires bubbling consent-shown ({ locale, wording_version }), consent-accepted ({ choices }) and consent-declined ({ reason: "declined" | "timeout" }) events, for measuring drop-off.

With React, @gaiadesk/consent/react (React 18 or later):

import { GaiaDeskConsent } from '@gaiadesk/consent/react';

<GaiaDeskConsent
  open={asking}                        // true shows it; false takes it down without a decision
  options={{ company: 'Acme', guided: true }}
  bridge={consentBridge}
  onShown={(d) => track('consent_shown', d)}
  onAccepted={({ choices }) => track('consent_accepted', choices)}
  onDeclined={({ reason }) => track('consent_declined', reason)}  // "declined" | "timeout"
  onDecision={(d) => { setAsking(false); if (d.decision === 'accepted') start(d); }}
  onError={(e) => console.error(e.code, e.message)}
/>

Options (every key optional): company, capture (window, app or screen), guided, masked, brand_color, logo_png_base64, theme, locale (auto, from navigator.languages, or a BCP-47 tag), wording and wording_version, choices (offer_guided, offer_logs, offer_capture), privacy_url and terms_url (https:// only), timeout_seconds (0, the default, never times out), preview, app_version. Set company.

Theming. The element reads CSS custom properties, so it can take your app's own:

:root { --gd-bg: #fff; --gd-surface: #f4f4f8; --gd-text: #16161d; --gd-accent: #5b4cf0;
        --gd-radius: 10px; --gd-font: "Inter", system-ui, sans-serif; }

options.theme wins over them where set: appearance (light, dark, auto), background, surface, text, accent, radius (0 to 24 px), font_family, button_style (filled, outline, pill).

Wording. Override any string (title, intro, accept, decline, …, with {company}, {team}, {minutes}, {count} placeholders) and give each wording you ship a wording_version; every receipt carries it and a SHA-256 of the strings actually shown. Locales: en, es, fr, de, it, pt, nl, pl, tr, ru, ja, ko, zh-Hans and ar (right to left).

Accessibility. A modal dialog with ARIA labels, focus trapped, Enter accepts and Esc declines, visible focus rings, no animation under prefers-reduced-motion, and sizes in rem.

A plain web page: webBridge

Without a native library, a server-only bridge shows who is waiting and posts the receipt to the session:

import { webBridge } from '@gaiadesk/consent';
el.bridge = webBridge({ server: 'https://api.gaiadesk.net', embedToken, sessionId });

It calls GET /v1/support/sessions/{id}/wait and POST /v1/support/sessions/{id}/consent with the session's embed token. Its limits: no preview (a page cannot capture), no consent_token, and the receipt is built in the page: os_user is null and only the page vouches for its time and hash. A decline or timeout ends the session if no agent has joined it (customer_declined / consent_timeout).

See the component's README for every option, the wording keys and writing your own bridge.

What each browser supports

Capture

Guided input

Consent dialog

Chromium-based browsers (Chrome, Edge, …)

this tab

yes

in your page, branded

Other browsers that can share a tab

this tab

view-only

in your page, branded

The browser must offer screen sharing (getDisplayMedia) and let the customer pick a tab; where it cannot, the session ends with an error before anything is shared. Video goes over WebRTC, through GaiaDesk's relay when a direct path fails.

What is and is not permitted

You may: use the SDK in your own pages; offer support sessions to your own customers; brand the dialog and bar with your name, colour and logo.

You may not: hide or imitate the bar; start a session without your customer's agreement.

See the SDK's README for every option, event and error code.

Updated