Documentation Index
Fetch the complete documentation index at: https://docs.kontext.so/llms.txt
Use this file to discover all available pages before exploring further.
Handling no-fill
Subscribe toAdEvent.NoFill to know when no ad was returned (geo-restriction, frequency cap, etc.). The skipCode payload tells you why.
Lifecycle management
Always callsession.destroy() (or its alias session.close()) when the conversation ends or the screen is closed. It cancels in-flight preloads, tears down every mounted ad, finalizes the OMID session, and releases WebView resources. Idempotent.
In Compose, anchor it to the screen-level DisposableEffect:
Live-updating session options
A subset of session options can be live-updated without recreating the session. Updates are read on the next/preload, so changes take effect on the next user message.
variantId, regulatory, userEmail, advertisingId. Non-null fields overwrite; null fields are left unchanged. To clear a field, recreate the session.
Live-updating consent mid-session
When the user updates their consent in your CMP, call:Switching character
The activecharacter cannot be live-updated — the accumulated message history belongs to the original persona, so swapping mid-session would leave messages targeted at the wrong character.
To switch character, destroy the current session and create a new one:
publisherToken, userId, conversationId, and enabledPlacementCodes — recreate the session whenever any of those change.
Loading older messages (conversation restore)
When restoring a conversation from your backend, calladdMessage(...) once per historical message in order. Preloads are debounced, so rapid sequential calls coalesce into a single preload for the most recent user message — you won’t fire one preload per restored message.
Pass every message, suppress ads with trackOnly
Always feed every message into the session, even when you don’t want an ad to appear (e.g. when a user is on a paid tier, in a no-ads region, or you’ve decided to show ads only every Nth message). Skipping addMessage(...) calls breaks the conversation context the server relies on for targeting. See Pacing for the full pattern.
trackOnly = true, the preload still fires (server keeps full analytics) but no AdEvent.Filled will arrive for that message and session.createAd(...) won’t resolve to a fillable ad.
Theming
Pass a publisher-defined theme string to theInlineAd composable; it propagates into the iframe’s update-iframe payload and is available to ad creatives.
Ad identity key — flipping it for the same messageId causes the iframe to reload with the new value.
View interop (non-Compose)
For apps not on Jetpack Compose, useInlineAdView (a FrameLayout subclass). Inflate or instantiate it like any other view, then call bind(messageId, session):
session.destroy() on screen teardown; the view’s WebView is recycled by the session’s pool.