Skip to main content

Widget Configuration

Complete reference for all available configuration options.

Required Options

OptionTypeDescription
projectIdstringYour PocketPing project ID (SaaS)
endpointstringYour backend URL (self-hosted)
note

Use either projectId (SaaS) or endpoint (self-hosted), not both.

Appearance Options

OptionTypeDefaultDescription
operatorNamestring"Support"Name shown in the widget header
operatorAvatarstring-URL to operator avatar image
primaryColorstring"#6366f1"Main brand color (hex)
theme"light" | "dark" | "auto""auto"Widget color theme
position"bottom-right" | "bottom-left""bottom-right"Widget position on screen

Behavior Options

OptionTypeDefaultDescription
welcomeMessagestring-Auto-sent message when chat opens
placeholderstring"Type a message..."Input placeholder text
soundEnabledbooleantruePlay sound on new messages
showOnPagesstring[]["*"]URL patterns where widget appears
hideOnPagesstring[][]URL patterns where widget is hidden

Callback Options

OptionTypeDescription
onOpen() => voidCalled when widget opens
onClose() => voidCalled when widget closes
onMessage(msg: Message) => voidCalled on new message (sent or received)
onSessionStart(session: Session) => voidCalled when session is created

Full Example

PocketPing.init({
// Connection (choose one)
projectId: 'proj_xxxxxxxxxxxxx',
// endpoint: 'https://yoursite.com/pocketping',

// Appearance
operatorName: 'Acme Support',
operatorAvatar: 'https://yoursite.com/avatar.png',
primaryColor: '#0ea5e9',
theme: 'auto',
position: 'bottom-right',

// Behavior
welcomeMessage: 'Hi! How can we help you today?',
placeholder: 'Ask us anything...',
soundEnabled: true,
showOnPages: ['*'],
hideOnPages: ['/admin/*', '/checkout'],

// Callbacks
onOpen: () => {
console.log('Chat opened');
analytics.track('chat_opened');
},
onClose: () => {
console.log('Chat closed');
},
onMessage: (message) => {
console.log('New message:', message);
},
onSessionStart: (session) => {
console.log('Session started:', session.id);
},
});

Methods

After initialization, you can control the widget programmatically:

// Open the chat widget
PocketPing.open();

// Close the chat widget
PocketPing.close();

// Toggle open/closed
PocketPing.toggle();

// Update configuration
PocketPing.setConfig({ primaryColor: '#10b981' });

// Identify the visitor (for CRM integration)
PocketPing.identify({
email: 'user@example.com',
name: 'John Doe',
plan: 'pro',
});

// Completely remove the widget
PocketPing.destroy();

Next Steps