In-App Content

Treliq workflows can target identified users with in-app messages — onboarding nudges, announcement banners, contextual tooltips. The SDK handles the entire delivery and rendering pipeline; you call identify() and the right content shows up at the right moment.

Display types

TypeLooks likeAnchored to
bannerFull-width strip at top or bottom of the pageViewport edge
modalCentered overlay with backdropViewport center
popoverFloating card in a cornerConfigured position
tooltipSpeech-bubble pinned to a target elementCSS selector

InAppContent shape:

interface InAppContent {
  display_type: 'banner' | 'modal' | 'popover' | 'tooltip';
  content: Record<string, unknown>;   // Type-specific fields (text, buttons, target selector, etc.)
  run_id: string;                     // Workflow run identifier
  action_id: string;                  // The action that produced this content
}

The exact shape of content varies by display type and matches what you authored in the dashboard.

Delivery pipeline

identify() ─► server returns pending_content ─► SDK renders any backlog
       │
       └────► SDK opens WebSocket (if sseUrl set)
                       │
                       └─► server pushes new content as workflows fire
                                   │
                                   └─► SDK renders one item at a time

There are three independent delivery paths, all merged into one render queue:

  1. Pending content — returned in the identify() response. Anything queued for this user before they came back to the site renders immediately.
  2. WebSocket stream — if sseUrl is configured, the SDK keeps a persistent connection open at ${sseUrl}/v1/sse/stream?session_token=… and receives new items in real time as workflows execute.
  3. Polling fallback — if no sseUrl is given, the SDK polls /v1/engine/sdk/in-app every 30 seconds.

Connection lifecycle

The WebSocket is opened automatically inside identify() once a session token is available. It auto-reconnects with exponential backoff (1s, 2s, 4s, …, capped at 30s) on disconnects. Keepalive frames are sent by the server and silently consumed by the SDK.

Calling reset() or shutdown() closes the connection and cancels any pending reconnects.

Manual fetch

To force a one-off fetch (e.g. on focus, after a route change), call getInAppContent():

const items = await treliq.getInAppContent();
console.log(`Fetched ${items.length} in-app items`);

The returned items are also automatically rendered — the SDK pushes them onto its internal queue, which displays one item at a time so the user is never overwhelmed.

Rendering rules

  • Serial display — only one item is on screen at a time. The next one appears when the current one is dismissed or its action is reported.
  • Position — the global inApp.position setting controls banners and popovers. Tooltips and modals position themselves.
  • Disable rendering — set inApp.enabled: false in init(). The SDK still receives content; it just doesn’t draw anything. Useful if you want full control via getInAppContent() and your own UI.

Reporting interactions

When a user clicks a button or dismisses a message, the SDK reports the action back to the workflow so subsequent steps can react. This happens automatically for built-in renderings. If you render content yourself, you must call reportAction() explicitly.

Disabling in-app entirely

init({
  apiKey, projectId,
  inApp: { enabled: false },
});

The SDK still handles identify() and track() normally; it just won’t render any in-app UI or open a WebSocket.