Embeddable AI chat widget for AgentForge
npm install @agentforgelab/chat-widgetEmbeddable AI chat widget with premium glassmorphism design.
``html`
`bash`
npm install @agentforgelab/chat-widget
`javascript`
import { initWidget } from '@agentforgelab/chat-widget';
// Initialize (appends to document.body)
initWidget(document.body, { apiKey: 'wk_pub_your_key_here' });
`javascript`
window.AgentForgeConfig = {
apiKey: 'wk_pub_...', // Required: Your public API key
apiUrl: 'https://...', // Optional: Custom API URL
position: 'bottom-right', // Optional: 'bottom-right' | 'bottom-left'
};
`javascript
// Control widget
AgentForgeChat.open();
AgentForgeChat.close();
AgentForgeChat.toggle();
AgentForgeChat.isOpen(); // Returns boolean
// Identify user
AgentForgeChat.identify({ email: 'user@example.com', name: 'John' });
// Send message programmatically
AgentForgeChat.sendMessage('Hello!');
// Clear history (start fresh)
AgentForgeChat.clearHistory();
// Events
AgentForgeChat.on('open', () => console.log('Widget opened'));
AgentForgeChat.on('close', () => console.log('Widget closed'));
AgentForgeChat.on('ready', ({ sessionId }) => console.log('Ready:', sessionId));
AgentForgeChat.on('message:sent', ({ content }) => console.log('Sent:', content));
AgentForgeChat.on('message:received', ({ content }) => console.log('Received:', content));
``