Quick Reference

Quick Reference Guide

Fast lookup guide for common SDK tasks and feature activation.


πŸ“¦ Installation (1 Minute)

React/Next.js

npm install @prodact.ai/sdk

CDN (No Build Step)

<script type="module">
  import { createProduck } from 'https://cdn.jsdelivr.net/npm/@prodact.ai/sdk@latest/+esm';
</script>

πŸ”‘ Basic Setup

Next.js App Router

app/layout.tsx
import { ProduckProvider, ProduckChat } from '@prodact.ai/sdk/react';
 
export default function RootLayout({ children }) {
  return (
    <ProduckProvider config={{ sdkKey: process.env.NEXT_PUBLIC_SDK_KEY }}>
      {children}
      <ProduckChat position="bottom-right" />
    </ProduckProvider>
  );
}

Next.js Pages Router

pages/_app.tsx
import { ProduckProvider, ProduckChat } from '@prodact.ai/sdk/react';
 
export default function App({ Component, pageProps }) {
  return (
    <ProduckProvider config={{ sdkKey: process.env.NEXT_PUBLIC_SDK_KEY }}>
      <Component {...pageProps} />
      <ProduckChat position="bottom-right" />
    </ProduckProvider>
  );
}

Vanilla JavaScript

import { createProduck } from '@prodact.ai/sdk';
 
const produck = createProduck({ sdkKey: 'your-key' });
await produck.init();

⚑ Feature Activation

βœ… Feature 1: Chat Widget

What it does: Adds a floating chat button that opens a conversational interface.

How to activate:

import { ProduckChat } from '@prodact.ai/sdk/react';
 
<ProduckChat position="bottom-right" />

Customization:

<ProduckChat
  position="bottom-right"  // or "bottom-left", "inline"
  theme="dark"             // or "light"
  primaryColor="#8b5cf6"
  title="Ask me anything!"
  placeholder="Type your message..."
/>

Full Documentation β†’


βœ… Feature 2: Action Handlers

What it does: Runs your code when AI detects specific user intents.

How to activate:

Step 1: Create operation in dashboard:

  1. Go to Produck Dashboard (opens in a new tab)
  2. Select SDK Project β†’ Operations β†’ Add Operation
  3. Fill in:
    • Operation ID: my-action
    • Description: What it does
    • Trigger phrases: User messages that should trigger it

Step 2: Register handler in code:

import { useProduckAction } from '@prodact.ai/sdk/react';
 
function MyComponent() {
  useProduckAction('my-action', () => {
    // Your code runs here when triggered
    console.log('Action triggered!');
  });
}

Vanilla JS:

produck.register('my-action', () => {
  console.log('Action triggered!');
});

Full Documentation β†’


βœ… Feature 3: Auto-Scroll & Highlight

What it does: Automatically scrolls to and highlights sections when AI triggers them.

How to activate:

import { ProduckTarget } from '@prodact.ai/sdk/react';
 
<ProduckTarget
  targetId="pricing"         // Unique ID for this section
  highlightColor="#3b82f6"   // Optional: custom highlight color
  duration={2000}            // Optional: highlight duration (ms)
>
  <section id="pricing">
    <h2>Pricing</h2>
    {/* Your content */}
  </section>
</ProduckTarget>

Create matching operation:

  • Operation ID: show-pricing
  • Trigger phrases: "show pricing", "see prices", "how much does it cost"

Full Documentation β†’


βœ… Feature 4: Custom Messages

What it does: Send messages to the chat programmatically.

How to activate:

import { useProduck } from '@prodact.ai/sdk/react';
 
function HelpButton() {
  const { sendMessage } = useProduck();
  
  return (
    <button onClick={() => sendMessage('How do I get started?')}>
      Quick Help
    </button>
  );
}

Vanilla JS:

await produck.sendMessage('Hello!');

Full Documentation β†’


βœ… Feature 5: Access Chat Messages

What it does: Read the conversation history in your components.

How to activate:

import { useProduckMessages } from '@prodact.ai/sdk/react';
 
function MessageHistory() {
  const messages = useProduckMessages();
  
  return (
    <div>
      <h3>Last {messages.length} messages:</h3>
      {messages.map(msg => (
        <div key={msg.id}>{msg.content}</div>
      ))}
    </div>
  );
}

Full Documentation β†’


βœ… Feature 6: Track SDK Status

What it does: Check if SDK is initialized and ready.

How to activate:

import { useProduckReady } from '@prodact.ai/sdk/react';
 
function StatusIndicator() {
  const isReady = useProduckReady();
  
  return (
    <div>
      Status: {isReady ? 'βœ… Ready' : '⏳ Loading...'}
    </div>
  );
}

βœ… Feature 7: Global Action Callback

What it does: Track all action triggers in one place (event tracking, logging).

How to activate:

<ProduckProvider
  config={{ sdkKey }}
  onAction={(actionKey, payload) => {
    // Track every action that fires
    analytics.track('Produck Action', {
      action: actionKey,
      timestamp: new Date(),
    });
  }}
>

βœ… Feature 8: Global Error Handler

What it does: Catch all SDK errors for monitoring.

How to activate:

<ProduckProvider
  config={{ sdkKey }}
  onError={(error) => {
    // Send to error tracking service
    Sentry.captureException(error);
    console.error('Produck Error:', error);
  }}
>

🎨 Chat Widget Customization

Positioning

<ProduckChat position="bottom-right" />  // Bottom right (default)
<ProduckChat position="bottom-left" />   // Bottom left
<ProduckChat position="inline" />        // Embedded in page

Theming

<ProduckChat
  theme="light"              // or "dark"
  primaryColor="#8b5cf6"     // Accent color
  title="Support Chat"       // Header title
  placeholder="Ask..."       // Input placeholder
/>

Conditional Rendering

function App() {
  const [showChat, setShowChat] = useState(false);
  
  return (
    <>
      <button onClick={() => setShowChat(true)}>Open Chat</button>
      {showChat && <ProduckChat position="bottom-right" />}
    </>
  );
}

πŸ” Environment Variables

Next.js

.env.local
NEXT_PUBLIC_SDK_KEY=your_sdk_key_here
NEXT_PUBLIC_API_URL=https://api.produck.io/api/v1

Create React App

.env
REACT_APP_SDK_KEY=your_sdk_key_here

Vite

.env
VITE_SDK_KEY=your_sdk_key_here

🎯 Common Operations

Navigation

useProduckAction('go-to-settings', () => {
  router.push('/settings');
});

Modal Control

const [isOpen, setIsOpen] = useState(false);
 
useProduckAction('open-modal', () => {
  setIsOpen(true);
});

Form Pre-fill

const [formData, setFormData] = useState({});
 
useProduckAction('prefill-contact', (payload) => {
  setFormData({
    subject: 'Support Request',
    category: payload.actionConfig?.category,
  });
});

Scroll to Section

useProduckAction('show-pricing', () => {
  document.getElementById('pricing')?.scrollIntoView({
    behavior: 'smooth',
    block: 'center',
  });
});

πŸ› Quick Troubleshooting

IssueSolution
Chat widget doesn't appearCheck SDK key, verify provider wraps app
Invalid SDK key errorCopy key from dashboard, check env variable name
Action not triggeringVerify operation ID matches, check dashboard config
CORS errorsUse correct API URL, check domain allowlist
TypeScript errorsRun npm install @prodact.ai/sdk@latest

Full Troubleshooting Guide β†’


πŸ“š API Quick Reference

React Hooks

HookPurpose
useProduckAction(id, handler)Register action handler
useProduckMessages()Get message history
useProduck()Access full SDK context
useProduckReady()Check initialization status

Components

ComponentPurpose
<ProduckProvider>Context provider (required)
<ProduckChat>Chat widget UI
<ProduckTarget>Auto-scroll wrapper

Core SDK (Vanilla JS)

MethodPurpose
createProduck(config)Create SDK instance
produck.init()Initialize SDK
produck.register(id, handler)Register action
produck.sendMessage(text)Send message
produck.getMessages()Get history

πŸ”— Quick Links


πŸ’‘ Code Snippets

Complete Example: Contact Form

import { useState } from 'react';
import { ProduckProvider, ProduckChat, useProduckAction } from '@prodact.ai/sdk/react';
 
function App() {
  return (
    <ProduckProvider config={{ sdkKey: process.env.NEXT_PUBLIC_SDK_KEY }}>
      <ContactSection />
      <ProduckChat position="bottom-right" />
    </ProduckProvider>
  );
}
 
function ContactSection() {
  const [isOpen, setIsOpen] = useState(false);
  
  useProduckAction('open-contact', () => {
    setIsOpen(true);
  });
  
  return (
    <section>
      <button onClick={() => setIsOpen(true)}>Contact Us</button>
      {isOpen && <ContactModal onClose={() => setIsOpen(false)} />}
    </section>
  );
}

Complete Example: Navigation

import { useRouter } from 'next/navigation';
import { useProduckAction } from '@prodact.ai/sdk/react';
 
function Navigation() {
  const router = useRouter();
  
  useProduckAction('go-to-pricing', () => router.push('/pricing'));
  useProduckAction('go-to-about', () => router.push('/about'));
  useProduckAction('go-to-docs', () => router.push('/docs'));
  
  return <nav>{/* Your nav items */}</nav>;
}

πŸŽ“ Learning Path

  1. Start Here: Getting Started Guide (10 min)
  2. Install: Installation Guide (5 min)
  3. Learn: Core Concepts (15 min)
  4. Build: React Integration (20 min)
  5. Advanced: Examples (30 min)

πŸ†˜ Get Help


Last updated: January 2026