Frontend API (JavaScript)
Control Bit and wire navigation + identity.
Get a Bit instance
import { createBit, getBit } from 'https://cdn.chatbyte.ai/bit/spark.min.js';
const bit = await createBit('your-agent-id');
const existing = getBit('your-agent-id');Widget controls
bit.open();
bit.close();
bit.toggle();Contextual notifications
bit.showNotification({
id: 'pricing-page',
text: 'Ask us about this page.',
oncePerSession: true,
});
bit.hideNotification('pricing-page');Saved automatic prompts are configured in Chatbyte settings. Use showNotification for page-specific runtime context.
Navigation handling
bit.setNavigationHandler((url) => {
router.push(url);
});Identity methods
bit.identify({ token });
bit.onRequestToken(async () => {
const response = await fetch('/api/bit-token');
const { token } = await response.json();
return token;
});For JWT requirements, see JWT & Identity.