5 SDK Integration Best Practices for Maximum Chatbot Revenue
Avoid common integration mistakes and optimize your Sponsy SDK setup for better performance, higher CTR, and increased affiliate earnings.
Sponsy Team
Avoid common integration mistakes and optimize your Sponsy SDK setup for better performance, higher CTR, and increased affiliate earnings.
Sponsy Team

You've integrated the Sponsy SDK - congratulations! But integration is just the beginning. The difference between a mediocre and a high-performing monetization setup often comes down to implementation details.
In this guide, we'll share five best practices that top-performing publishers use to maximize their chatbot revenue.
The most common integration mistake is calling the recommendation API too early or too late in the conversation.
// DON'T: Immediately after user sends first message
onUserMessage(msg) {
sponsy.getRecommendation(msg); // User hasn't shown intent yet
}
// DON'T: After the conversation is basically over
onUserLeave() {
sponsy.getRecommendation(lastMessage); // User is already leaving
}
// DO: After bot response, when context is complete
onBotResponse(userMsg, botResponse) {
// Now we have full context for intent detection
const rec = await sponsy.getRecommendation({
userMessage: userMsg,
assistantMessage: botResponse
});
if (rec) {
appendToChat(rec.html);
}
}
The ideal timing is after your bot generates a response but before rendering it to the user. This gives Sponsy the full context needed for accurate intent detection.
Sending too little context leads to poor intent detection. Sending too much wastes bandwidth and processing time.
const request = {
userMessage: lastUserMessage, // Required
assistantMessage: lastBotResponse, // Required
sessionId: currentSessionId // Required for pacing
};
const request = {
userMessage: lastUserMessage,
assistantMessage: lastBotResponse,
sessionId: currentSessionId,
metadata: {
vertical: 'travel', // Your app's vertical
locale: 'en-US', // User's locale
platform: 'web' // web, ios, android
}
};
Every unnecessary API call adds latency and potentially wastes your rate limit.
class SponsyClient {
private sessionRecommendations = new Map();
private lastCallTime = 0;
private MIN_INTERVAL = 3000; // 3 seconds
async getRecommendation(context) {
const now = Date.now();
// Rate limit client-side
if (now - this.lastCallTime < this.MIN_INTERVAL) {
return null;
}
// Check session cache
const cacheKey = hash(context.userMessage);
if (this.sessionRecommendations.has(cacheKey)) {
return this.sessionRecommendations.get(cacheKey);
}
this.lastCallTime = now;
const rec = await sponsy.getRecommendation(context);
if (rec) {
this.sessionRecommendations.set(cacheKey, rec);
}
return rec;
}
}
Your chat should never break because of a monetization error.
async function showRecommendation(context) {
try {
const rec = await sponsy.getRecommendation(context);
if (rec?.html) {
appendToChat(rec.html);
trackImpression(rec.id);
}
} catch (error) {
// Log for debugging, but don't break the chat
console.error('[Sponsy] Recommendation failed:', error.message);
// Optionally report to your error tracking
if (process.env.NODE_ENV === 'production') {
Sentry.captureException(error);
}
// Continue chat flow normally
// User never sees any error
}
}
const TIMEOUT = 2000; // 2 seconds max
async function getWithTimeout(context) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), TIMEOUT);
try {
const rec = await sponsy.getRecommendation(context, {
signal: controller.signal
});
clearTimeout(timeoutId);
return rec;
} catch (error) {
if (error.name === 'AbortError') {
console.warn('[Sponsy] Request timed out');
return null;
}
throw error;
}
}
You can't optimize what you don't measure. Implement comprehensive tracking from day one.
// 1. Impression - when recommendation is shown
function onShow(recommendation) {
analytics.track('sponsy_impression', {
recommendationId: recommendation.id,
category: recommendation.category,
position: 'inline'
});
}
// 2. Click - when user clicks the recommendation
function onClick(recommendation) {
analytics.track('sponsy_click', {
recommendationId: recommendation.id,
category: recommendation.category
});
}
// 3. Dismiss - when user dismisses
function onDismiss(recommendation) {
analytics.track('sponsy_dismiss', {
recommendationId: recommendation.id,
reason: 'user_closed'
});
}
// 4. Timeout - when recommendation wasn't shown
function onTimeout() {
analytics.track('sponsy_timeout', {
context: 'api_slow'
});
}
| Metric | Good | Warning | Critical |
|---|---|---|---|
| API Latency | <200ms | 200-500ms | >500ms |
| Fill Rate | >80% | 60-80% | <60% |
| CTR | >3% | 1-3% | <1% |
| Error Rate | <0.1% | 0.1-1% | >1% |
Once you have the basics right, experiment to find optimal settings:
const variant = getABVariant(sessionId); // 'A' or 'B'
const config = {
A: { delay: 0, maxPerSession: 2 },
B: { delay: 1000, maxPerSession: 3 }
};
await sleep(config[variant].delay);
if (sessionCount < config[variant].maxPerSession) {
showRecommendation();
}
// Track which variant for analysis
analytics.track('sponsy_abtest', { variant });
Use this checklist to ensure your integration is production-ready:
A well-implemented SDK integration is the foundation of successful chatbot monetization. By following these five best practices:
You'll maximize your revenue while maintaining a great user experience.
Questions about implementation? Reach out to our team at support@sponsyai.com or check our documentation.
Sponsy Team
Engineering at Sponsy
Building the future of conversational AI monetization. Follow our journey and learn best practices for chatbot revenue optimization.

Master the essential metrics that drive chatbot monetization success. Learn how to track, optimize, and benchmark your AI app's revenue performance.

Learn how to monetize your chatbot effectively while respecting user privacy. No PII, no transcripts, no compromise.

Consumer search behavior is fundamentally shifting. Learn how AI assistants are becoming the new front door to discovery - and what it means for your brand strategy.