Skip to main content

Overview

The AI Chat SDK (@sleek/ai-chat-sdk) enables web applications to integrate intelligent, context-aware AI chat capabilities. The SDK provides a beautiful chat interface with AI-powered recommendations and merchant offers, along with flexible entry points like floating badges and inline inputs to engage users.

Key capabilities

  • Chat interface: Full-featured chat panel with AI conversation interface
  • Multiple entry points: Floating badge and inline input to engage users
  • Context-aware AI: Optional page context for smarter, relevant responses
  • Event system: Comprehensive events for all user interactions
  • Data integration: Display offer redirect URLs and cashback offers in conversations
  • Full customization: Brand colors, logos, fonts, and light/dark mode support
  • Multiple package formats: NPM package or IIFE script injection
  • Shadow DOM isolation: Prevents styling conflicts with your application

Prerequisites

Before integrating the SDK, ensure your project meets these requirements:
  • Modern browser with ES6+ support (Chrome 100+, Firefox 100+, Safari 15+, Edge 100+)
  • Node.js 18+ and package manager (pnpm, npm, or yarn) for NPM installation

Installation

1

Configure npm registry

Add the registry to your .npmrc file:
.npmrc
Contact support@onsleek.com to receive your authentication token.
2

Install the package

Quick start

Here’s a minimal example to get the SDK running in your application:

SDK methods

initializeAiChatSdk

Initializes the SDK with your API key and configuration options.
Parameters:
  • apiKey: Your API key for authentication
  • options: Configuration options (optional)
  • listeners: Array of event listener functions (optional)
Returns: SDK instance

getAiChatSdk

Retrieves the initialized SDK instance.
Returns: SDK instance (throws error if not initialized)

initializeChat

Opens the full chat panel with an optional initial message and default prompts.
Parameters:
  • initialMessage: Optional message to send when opening the chat
  • defaultPrompts: Optional array of prompt suggestions to display
Example:

showBadge

Shows a floating badge with AI-generated prompt suggestions. When users interact with the badge, it opens the chat panel.
Parameters:
  • query: Optional query to generate contextual prompts
  • isOnboarding: Whether to show onboarding content (default: false)
  • maxPrompts: Optional maximum number of prompts to display on the badge (clamped to 1-3)
Example:

showInline

Shows an inline input component that can be embedded in a container element. When users interact with the inline input, it opens the chat panel.
Parameters:
  • query: Optional query to generate contextual prompts
Example:

Entry points

The SDK provides multiple entry points to engage users and open the chat panel:

Direct chat

Open the chat panel directly using initializeChat(). Best for explicit “Open Chat” buttons or when you want to immediately start a conversation.

Floating badge

A compact badge that shows AI-generated prompts. Expands on hover and opens the chat panel when clicked. Great for non-intrusive engagement that encourages users to start a conversation.

Inline input

An input field that can be embedded in any container element. When users type or click a prompt, the chat panel opens. Ideal for seamless integration with existing UI layouts.

Build formats

The SDK is distributed in multiple formats for maximum compatibility: All formats include TypeScript definitions (.d.ts) for full IDE support.

Getting help

API reference

For detailed type definitions and API documentation, refer to the TypeScript definitions included with the SDK package.