Javascript SDK
Get started with our general purpose SDK built for any browser-based application
Javascript SDK is a low level SDK that works with any browser-based application. If you are using React, you should also checkout our declarative React SDK.
1. Create an account
To get started, get in touch with us via Calendly or email. We will onboard you personally into the Kontext platform and help you get started.
During onboarding you will receive your publisherToken
and a code
that’s needed in the next steps.
2. Installation
A detailed overview of the SDK can be found in the SDK Reference.
Import our SDK
You might need to make fetchAd
available globally.
Assemble a list of messages
messages
is the list of messages between assistant and user. They are used to determine which ads to show. Order of messages matters and it should always end with an assistant message.
If you are integrating Kontext to a human-to-human messaging app, just use role “assistant” for everyone else apart from the current user. This works well both in 1:1 and group chat setups.
Create your params object
This object is used to call the fetchAd
function. Based on the params, it will determine what product and ad copy to show.
3. Show your first ad
At this point, you are all set. You can now call the fetchAd
function which also has a few optional callbacks that can be used for your analytics or rendering logic.