Skip to main content

Overview

This guide covers common issues you may encounter when integrating the AI Chat SDK and how to resolve them.

Installation issues

Package not found

Symptom: npm install or pnpm add fails with “package not found” Solution:
1

Configure .npmrc

Add the registry configuration to your .npmrc file:
.npmrc
@sleek:registry=https://npm.cloudsmith.io/sleek/sleek/
//npm.cloudsmith.io/sleek/sleek/:_authToken={YOUR_TOKEN_HERE}
2

Add your token

Replace {YOUR_TOKEN_HERE} with your authentication token
3

Install the package

pnpm add @sleek/ai-chat-sdk
Contact [email protected] if you need an authentication token.

Module not found

Symptom: Cannot find module '@sleek/ai-chat-sdk' Solution: Verify your TypeScript configuration includes:
tsconfig.json
{
  "compilerOptions": {
    "moduleResolution": "bundler",
    "esModuleInterop": true
  }
}

SDK initialization issues

SDK not initializing

Symptom: SDK initialization fails or throws error Solution: Enable debug mode to see detailed error messages:
import { initializeAiChatSdk } from '@sleek/ai-chat-sdk';

const sdk = initializeAiChatSdk('your-api-key', {
  enableDebug: true,  // Shows detailed logs in console
  chatConfig: {
    // ... your config
  },
});
Check the browser console for specific error messages.

”SDK already initialized” error

Symptom: Error when calling initializeAiChatSdk multiple times Solution: Use getAiChatSdk() to retrieve the existing instance:
import { getAiChatSdk } from '@sleek/ai-chat-sdk';

const sdk = getAiChatSdk();
sdk.initializeChat();

UI issues

Chat panel not appearing

Symptom: Calling sdk.initializeChat() doesn’t show the chat panel Common causes:
  • Invalid or missing API key
  • SDK not initialized before calling initializeChat()
  • JavaScript errors in console
Solution:
1

Enable debug mode

enableDebug: true
2

Check browser console

Open DevTools (F12) and look for error messages
3

Verify initialization

try {
  const sdk = getAiChatSdk();
  sdk.initializeChat();
} catch (error) {
  console.error('SDK error:', error);
}

Chat panel appears blank

Symptom: Panel opens but shows blank content Solution:
  1. Verify your API key is valid
  2. Check browser console for network errors
  3. Ensure you have internet connectivity
  4. Try clearing browser cache

Data provider issues

Providers not being called

Symptom: Data providers never execute Solution: Ensure providers are configured correctly:
dataProviders: {
  offerRedirectUrlProvider: async (url) => {
    console.log('Provider called for:', url);
    // Your implementation
    return 'https://example.com/offer';
  },
  merchantCashbackProvider: async (urls) => {
    console.log('Cashback requested for:', urls);
    // Your implementation
    return {};
  },
}
Test by asking merchant-specific questions like “Show me deals on Amazon”

Provider errors

Symptom: SDK stops working after provider throws error Solution: Always handle errors and return valid fallback values:
const offerRedirectUrlProvider = async (url) => {
  try {
    const response = await fetch(`/api/offers?url=${url}`);
    const data = await response.json();
    return data.offerUrl || null;
  } catch (error) {
    console.error('Provider error:', error);
    return null;  // Always return null on error
  }
};

const merchantCashbackProvider = async (urls) => {
  try {
    const response = await fetch('/api/cashback', {
      method: 'POST',
      body: JSON.stringify({ urls }),
    });
    const data = await response.json();
    return data.cashback || {};
  } catch (error) {
    console.error('Provider error:', error);
    return {};  // Always return {} on error
  }
};

Slow performance

Symptom: Chat feels sluggish or freezes Solution: Add timeouts to data providers (recommend 500ms):
const offerRedirectUrlProvider = async (url) => {
  const controller = new AbortController();
  const timeout = setTimeout(() => controller.abort(), 500);

  try {
    const response = await fetch(url, { signal: controller.signal });
    clearTimeout(timeout);
    return response.offerUrl;
  } catch (error) {
    clearTimeout(timeout);
    return null;
  }
};

Event issues

Events not firing

Symptom: Event listeners are never called Solution: Ensure listeners are registered during initialization:
initializeAiChatSdk('your-api-key', {
  // ... config
}, [
  // Event listeners must be passed here
  (event) => {
    console.log('Event:', event.type, event.data);
  }
]);
Event listeners cannot be added after SDK initialization. They must be passed as the third parameter to initializeAiChatSdk().

Network issues

API requests failing

Symptom: Chat not responding, network errors in console Solution:
1

Verify API key

Ensure your Zero Click AI API key is correct and active
2

Check network

Verify you have internet connectivity
3

Enable debug mode

enableDebug: true
Check console for detailed error messages
4

Check browser console

Look for 401/403 errors indicating authentication issues
If issues persist, contact [email protected]

Browser compatibility

The SDK supports modern browsers:
  • Chrome 100+
  • Firefox 100+
  • Safari 15+
  • Edge 100+
For best results, ensure users are on the latest browser version.

Debugging tips

Enable debug mode

Always start troubleshooting with debug mode enabled:
initializeAiChatSdk('your-api-key', {
  enableDebug: true,
  // ... other config
});
This provides detailed logs in the browser console.

Check SDK version

Verify you’re using the latest version:
pnpm list @sleek/ai-chat-sdk
Update if needed:
pnpm update @sleek/ai-chat-sdk

Test in incognito mode

Test in incognito/private browsing to rule out:
  • Browser extension interference
  • Cached data issues
  • Cookie problems

Check the console

Always check the browser DevTools Console (F12) for:
  • Error messages
  • Network failures
  • SDK debug logs

Common error messages

”Invalid API key”

Your API key is incorrect or inactive. Verify your key and ensure it’s active.

”Failed to initialize SDK”

  1. Check that your API key is valid
  2. Enable debug mode to see specific error details
  3. Check browser console for additional errors

”Data provider error”

  1. Ensure providers return correct types (null or {} on error)
  2. Add try-catch blocks to all providers
  3. Never throw exceptions from providers

Getting help

If you’re still experiencing issues, contact our support team. When contacting support, please include:
  • SDK version (pnpm list @sleek/ai-chat-sdk)
  • Browser name and version
  • Error messages from console (with enableDebug: true)
  • Code snippet of your SDK initialization
  • Steps to reproduce the issue