Integrate context-aware ads into your AI assistant in under 5 minutes.
pub_ are public integration keys for your app or website. Contact us at hello@intentara.com to request access.
The fastest way to integrate Intentara — add the script, mark your ad slots, and let the SDK do the rest.
Include the Intentara SDK in your HTML page:
<script src="__BASE_URL__/sdk/intentara.js"></script> This also creates an anonymous session for analytics — no cookies or localStorage involved.
intentara.init({ apiKey: 'pub_XXXX' }); Place slots wherever you want ads to appear. Optionally set a template per slot:
<!-- Card template (default) -->
<div data-intentara-slot></div>
<!-- Compact inline text link -->
<div data-intentara-slot data-intentara-template="native"></div> process() finds all slots, fetches one ad, and renders it everywhere — one API call total. Trigger it as soon as the user sends a new message, using the existing chat history plus the current user input.
const context = [...chatHistory, currentUserInput].join('\n');
intentara.process({
context,
onFill: (ad) => console.log('Ad rendered:', ad.name),
onNoFill: () => console.log('No matching ad found'),
}); That's it! Ads render inside Shadow DOM — fully isolated from your page styles. Customize them with CSS variables on the slot elements.
For full control, use getAd() and render() separately. Request the ad when the user submits a message so you do not need to wait for the LLM response.
const context = [...chatHistory, currentUserInput].join('\n');
const ad = await intentara.getAd({ context });
if (ad) {
intentara.render(ad, document.querySelector('#my-ad-slot'), {
template: 'card', // 'card' or 'native'
position: 'inline', // 'inline', 'suffix', or 'prefix'
});
} Prefer to call the API directly? Here's how to get a contextual ad using a simple HTTPS request.
For production use, call the HTTPS platform origin: https://platform.intentara.com.
curl -X POST https://platform.intentara.com/api/v1/public/creatives/by-context \
-H "Content-Type: application/json" \
-H "x-api-key: pub_XXXX" \
-H "x-session-id: your-session-id" \
-d '{"context": "I need a good pair of running shoes for a marathon"}' const response = await fetch(
'https://platform.intentara.com/api/v1/public/creatives/by-context',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'pub_XXXX',
'x-session-id': 'your-session-id', // optional, for session analytics
},
body: JSON.stringify({
context: 'I need a good pair of running shoes for a marathon',
}),
}
);
const ad = await response.json();
console.log(ad); A successful response returns a single ad creative:
{
"id": "abc123",
"name": "Marathon Pro Shoes",
"text": "Train harder, run faster — Marathon Pro X1 now available.",
"imageUrl": "__BASE_URL__/api/v1/public/creatives/images/shoe.jpg",
"impressionUrl": "__BASE_URL__/api/v1/public/creatives/beacon?requestId=req_xyz",
"targetUrl": "__BASE_URL__/api/v1/public/creatives/target/abc123?requestId=req_xyz"
} Key fields:
text — The ad copy to display to the user (used as clickable link text for text-only ads)imageUrl — Optional public image asset URL for the ad creative.impressionUrl — Tracking pixel URL. Load it for every displayed ad, including image ads.targetUrl — The click-through URL (tracks clicks automatically via redirect)