@agentforgelab/chat-widget
v1.0.1
Published
Embeddable AI chat widget for AgentForge
Downloads
148
Maintainers
Readme
AgentForge Chat Widget
Embeddable AI chat widget with premium glassmorphism design.
Installation
CDN (Recommended)
<script>
window.AgentForgeConfig = { apiKey: 'wk_pub_your_key_here' };
</script>
<script src="https://unpkg.com/@agentforgelab/chat-widget@latest/dist/index.global.js" async></script>npm
npm install @agentforgelab/chat-widgetimport { initWidget } from '@agentforgelab/chat-widget';
// Initialize (appends to document.body)
initWidget(document.body, { apiKey: 'wk_pub_your_key_here' });Configuration
window.AgentForgeConfig = {
apiKey: 'wk_pub_...', // Required: Your public API key
apiUrl: 'https://...', // Optional: Custom API URL
position: 'bottom-right', // Optional: 'bottom-right' | 'bottom-left'
};Public API
// Control widget
AgentForgeChat.open();
AgentForgeChat.close();
AgentForgeChat.toggle();
AgentForgeChat.isOpen(); // Returns boolean
// Identify user
AgentForgeChat.identify({ email: '[email protected]', 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));