Skip to main content

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.

<AdsProvider> props

publisherToken
string
required
Your unique publisher token.
userId
string
required
Unique identifier that remains the same for the user’s lifetime (used for retargeting and rewarded ads).
userEmail
string
Email of the user.
conversationId
string
required
Unique ID of the conversation.
enabledPlacementCodes
array
Placement codes enabled for the conversation. Defaults to ['inlineAd'].
character
object
Character object used in this conversation.
regulatory
object
Regulatory object used in this conversation.
variantId
string
Publisher-provided identifier for the user cohort (for A/B testing).
onEvent
function
Callback triggered when an event occurs. See Supported events below.
onDebugEvent
function
Callback for SDK-internal diagnostic events. Receives (name, data?) — useful when investigating preload/session behaviour during integration. Off by default.

useAds() hook

Returns addMessage, a forwarder that always routes to the current session. If <AdsProvider> swaps the session (e.g. publisherToken change), the next call hits the new one automatically.
addMessage
function
required
(message: Message, options?: AddMessageOptions) => void — register a new chat message with the SDK. The next preload is scheduled automatically.AddMessageOptions currently exposes one flag:

Message shape

id
string
required
Unique ID of the message.
role
string
required
Role of the message (user or assistant).
content
string
required
Message text.
createdAt
Date
required
Timestamp when the message was created.

<InlineAd> props

messageId
string
required
Unique ID of the message this ad belongs to.
code
string
Placement code provided during onboarding. Defaults to 'inlineAd'.
theme
string
Theme of the ad, e.g. light or dark.
wrapper
function
Render-prop function that lets you wrap the ad iframe in your own markup. The function receives the rendered ad as a React node:
<InlineAd
  messageId={m.id}
  wrapper={(ad) => <div className="my-ad-card">{ad}</div>}
/>

<ErrorBoundary>

<InlineAd> is wrapped in an internal ErrorBoundary so a broken ad never crashes the host app. The component is also exported in case you want to wrap your own logic:
import { ErrorBoundary } from '@kontextso/sdk-react'

<ErrorBoundary>
  <YourComponent />
</ErrorBoundary>

Supported events

ad.clicked

The user has clicked the ad.

ad.viewed

The user has viewed the ad.

ad.filled

Ad is available.

ad.no-fill

Ad is not available.

ad.render-started

Triggered before the first token is received.

ad.render-completed

Triggered after the last token is received.

ad.error

Triggered when an error occurs.

video.started

Triggered when the video playback starts.

video.completed

Triggered when the video playback finishes.

reward.granted

Triggered when a rewarded-ad reward is granted to the user.