Quick Reference Guide
Fast lookup guide for common SDK tasks and feature activation.
π¦ Installation (1 Minute)
React/Next.js
npm install @prodact.ai/sdkCDN (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
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
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..."
/>β 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:
- Go to Produck Dashboard (opens in a new tab)
- Select SDK Project β Operations β Add Operation
- Fill in:
- Operation ID:
my-action - Description: What it does
- Trigger phrases: User messages that should trigger it
- Operation ID:
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!');
});β 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"
β 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!');β 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>
);
}β 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 pageTheming
<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
NEXT_PUBLIC_SDK_KEY=your_sdk_key_here
NEXT_PUBLIC_API_URL=https://api.produck.io/api/v1Create React App
REACT_APP_SDK_KEY=your_sdk_key_hereVite
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
| Issue | Solution |
|---|---|
| Chat widget doesn't appear | Check SDK key, verify provider wraps app |
| Invalid SDK key error | Copy key from dashboard, check env variable name |
| Action not triggering | Verify operation ID matches, check dashboard config |
| CORS errors | Use correct API URL, check domain allowlist |
| TypeScript errors | Run npm install @prodact.ai/sdk@latest |
Full Troubleshooting Guide β
π API Quick Reference
React Hooks
| Hook | Purpose |
|---|---|
useProduckAction(id, handler) | Register action handler |
useProduckMessages() | Get message history |
useProduck() | Access full SDK context |
useProduckReady() | Check initialization status |
Components
| Component | Purpose |
|---|---|
<ProduckProvider> | Context provider (required) |
<ProduckChat> | Chat widget UI |
<ProduckTarget> | Auto-scroll wrapper |
Core SDK (Vanilla JS)
| Method | Purpose |
|---|---|
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
- Full Getting Started Guide β
- Complete Installation Guide β
- React Integration Docs β
- Vanilla JS Docs β
- Managing Operations β
- API Reference β
- Examples β
π‘ 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
- Start Here: Getting Started Guide (10 min)
- Install: Installation Guide (5 min)
- Learn: Core Concepts (15 min)
- Build: React Integration (20 min)
- Advanced: Examples (30 min)
π Get Help
- π Documentation
- π¬ Discord Community (opens in a new tab)
- π§ [email protected]
- π GitHub Issues (opens in a new tab)
Last updated: January 2026