Skip to main content

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:
  1. Offer Redirect URL Provider: Returns offer redirect URLs for individual merchant URLs
  2. 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

Always return null on errors. Never throw exceptions or let errors propagate:
Cache offer redirect URLs to improve performance and reduce API calls:
Handle different merchant domains and URL formats:
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:
If a merchant doesn’t have cashback, simply omit it from the result.

Best practices

Always return {} on errors:
Cache cashback data with TTL (time-to-live):
Provide consistent, user-friendly text:
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

Symptom: Data providers never executeCauses:
  • Chat panel not opened
  • AI not recommending merchants
  • Provider not configured properly
Solution: Open the chat and ask about products or merchants to trigger provider calls
Symptom: Chat feels sluggish, UI delaysCauses:
  • Provider taking >500ms to respond
  • No caching implemented
  • Large batch requests
Solution: Implement caching, add timeouts, optimize API responses
Symptom: SDK stops working after provider errorCauses:
  • Throwing exceptions instead of returning null/
  • Unhandled promise rejections
Solution: Wrap all code in try-catch, always return null or on errors