Get started with our SDK built for React applications
publisherToken
and code
AdsProvider
. This component handles all data-fetching logic and requires access to the chat messages. Place it somewhere in your component tree where messages are already available and high enough in the hierarchy to contain all ad placements (i.e., locations where ads will be rendered).
Prop | Description |
---|---|
publisherToken | Your unique publisher token |
messages | A list of messages between the assistant and the user |
userId | A unique string that should remain the same during the user’s lifetime (used for retargeting and rewarded ads) |
conversationId | Unique ID of the conversation |
enabledPlacementCodes | A list of placement codes that should be enabled for the conversation |
character | The character object used in this conversation |
messages
array includes objects with the following properties:
Prop | Description |
---|---|
id | Unique ID of the message |
role | Role of the message (user or assistant ) |
content | Content of the message |
createdAt | Timestamp when the message was created |
character
object includes the following properties:
Prop | Description |
---|---|
name | Name of the character |
avatarUrl | URL of the character’s avatar |
isNsfw | Whether the character is NSFW |
id | Unique ID of the character |
greeting | Greeting of the character |
persona | Description of the character’s personality |
tags | Tags of the character (list of strings) |
code
that you need to use for each ad slot or ad format you want to display.
We will be using an InlineAd
format in this example. Copy the markup <InlineAd />
and place it in your application where it should be rendered. Don’t forget to assign messageId
as a unique identifier. For example, if you have a MessageList
component, you can show an ad after each message like this (every message will have a unique ad displayed because of messageId
).
<InlineAd />
, being the most versatile format, already offers advanced functionality such as rendering images and videos. If you want to style your ads, check out our Inline ad guide.