Overview
Data providers allow you to integrate your offer redirect URLs and cashback offers directly into AI chat conversations. When the AI recommends retailers, cashback information is automatically displayed to users. When users click on merchant or product links, your offer redirect URLs are pulled, creating seamless monetization opportunities.Data providers are recommended for full functionality of the chat interface, especially when displaying merchant recommendations.
Provider types
The SDK supports two types of data providers:- Offer Redirect URL Provider: Returns offer redirect URLs for individual merchant URLs
- Merchant Cashback Provider: Returns cashback information for multiple merchants in batch
Offer redirect URL provider
Type definition
Purpose
Converts regular merchant URLs into your offer redirect URLs. Called when the user clicks a merchant link or product link that the AI mentions or recommends for a specific retailer or product.Implementation
Input
- url: The merchant URL to convert (e.g.,
"https://www.amazon.com")
Output
- string: The offer redirect URL
- null/undefined: No offer redirect URL available for this merchant
Best practices
1. Handle errors gracefully
1. Handle errors gracefully
Always return
null on errors. Never throw exceptions or let errors propagate:2. Implement caching
2. Implement caching
Cache offer redirect URLs to improve performance and reduce API calls:
3. Support multiple domains
3. Support multiple domains
Handle different merchant domains and URL formats:
4. Keep response times fast
4. Keep response times fast
Aim for
<500ms response times:Merchant cashback provider
Type definition
Purpose
Provides cashback information for multiple merchants in a single batch request. Called when the AI displays a list of retailers or product recommendations.Implementation
Input
- merchantUrls: Array of merchant URLs (e.g.,
["https://amazon.com", "https://walmart.com"])
Output
A record mapping merchant URLs to cashback information:Best practices
1. Handle errors gracefully
1. Handle errors gracefully
Always return
{} on errors:2. Implement caching
2. Implement caching
Cache cashback data with TTL (time-to-live):
3. Normalize cashback text
3. Normalize cashback text
Provide consistent, user-friendly text:
4. Handle batch size limits
4. Handle batch size limits
Some APIs have batch size limits. Split large requests:
Complete example
Here’s a production-ready implementation with caching, error handling, and performance optimization:Testing data providers
Unit testing
Test your providers with mock data:Manual testing
Test in the browser console:Common issues
Provider not being called
Provider not being called
Symptom: Data providers never executeCauses:
- Chat panel not opened
- AI not recommending merchants
- Provider not configured properly
Slow performance
Slow performance
Symptom: Chat feels sluggish, UI delaysCauses:
- Provider taking >500ms to respond
- No caching implemented
- Large batch requests
Errors breaking SDK
Errors breaking SDK
Symptom: SDK stops working after provider errorCauses:
- Throwing exceptions instead of returning null/
- Unhandled promise rejections

