Documentation Index
Fetch the complete documentation index at: https://usegately.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
The Gately Chat Widget provides an integrated support chat experience for your users.
Quick Setup
Gately.initChatWidget({
position: 'bottom-right'
})
Configuration
interface ChatWidgetOptions {
position?: 'bottom-right' | 'bottom-left'
primaryColor?: string
greeting?: string
placeholder?: string
showOnMobile?: boolean
autoOpen?: boolean
zIndex?: number
}
Basic Usage
JavaScript
Gately.initChatWidget({
position: 'bottom-right',
primaryColor: '#F97316',
greeting: 'Hi! How can we help you today?',
placeholder: 'Type your message...'
})
React
import { IntegratedChatWidget } from '@gately/sdk'
function App() {
return (
<div>
<YourApp />
<IntegratedChatWidget
position="bottom-right"
primaryColor="#F97316"
/>
</div>
)
}
Customization
Styling
Gately.initChatWidget({
primaryColor: '#6366f1',
styles: {
fontFamily: 'Inter, sans-serif',
borderRadius: '16px',
headerBackground: '#6366f1',
headerText: '#ffffff',
userBubble: '#6366f1',
agentBubble: '#f3f4f6'
}
})
Custom Launcher
// Hide default launcher
Gately.initChatWidget({
showLauncher: false
})
// Use custom button
document.getElementById('chat-btn').addEventListener('click', () => {
Gately.openChat()
})
API Methods
Open Chat
Close Chat
Toggle Chat
Send Message
Gately.sendChatMessage('Hello, I need help!')
Set User Info
// Automatically set from logged-in user
// Or manually set for anonymous users
Gately.setChatUser({
name: 'John Doe',
email: 'john@example.com'
})
Events
On Open
Gately.initChatWidget({
onOpen: () => {
console.log('Chat opened')
analytics.track('chat_opened')
}
})
On Close
Gately.initChatWidget({
onClose: () => {
console.log('Chat closed')
}
})
On Message
Gately.initChatWidget({
onMessage: (message) => {
console.log('New message:', message)
}
})
Collect user info before starting chat:
Gately.initChatWidget({
preChatForm: {
enabled: true,
fields: [
{ name: 'name', label: 'Name', required: true },
{ name: 'email', label: 'Email', type: 'email', required: true },
{ name: 'topic', label: 'Topic', type: 'select', options: [
'Sales',
'Support',
'Billing',
'Other'
]}
]
}
})
Logged-In Users
For authenticated users, info is automatically populated:
// User is logged in
const user = Gately.getUser()
// Chat widget automatically shows:
// - User's name
// - User's email
// - User's plan
// - Previous conversation history
Mobile Behavior
Gately.initChatWidget({
showOnMobile: true,
mobileFullScreen: true, // Open in full screen on mobile
mobileBreakpoint: 768
})
Unread Badge
Show unread message count:
Gately.initChatWidget({
showUnreadBadge: true
})
// Get unread count
const count = Gately.getChatUnreadCount()
Offline Mode
Configure behavior when agents are offline:
Gately.initChatWidget({
offlineMode: {
enabled: true,
message: 'We\'re currently offline. Leave a message and we\'ll get back to you.',
collectEmail: true
}
})
Integration with Helpdesk
Chat messages create tickets in your helpdesk:
- User sends message via chat
- Ticket is created in Helpdesk
- Agent responds via Helpdesk
- User sees response in chat widget
React Component
import { createChatWidget } from '@gately/sdk'
function App() {
useEffect(() => {
const widget = createChatWidget({
position: 'bottom-right',
primaryColor: '#F97316'
})
return () => {
widget.destroy()
}
}, [])
return <YourApp />
}
Conditional Display
// Only show on certain pages
if (window.location.pathname.startsWith('/app')) {
Gately.initChatWidget()
}
// Only show for logged-in users
if (Gately.isAuthenticated()) {
Gately.initChatWidget()
}
// Only show for specific plans
const user = Gately.getUser()
if (user?.plan_id === 'pro') {
Gately.initChatWidget({
greeting: 'Welcome, Pro member! How can we help?'
})
}
Gately.destroyChatWidget()