@happiest-team/ai-chat-core
v1.0.4
Published
Headless API Client and State Manager for Happiest Chat
Maintainers
Readme
@happiest-team/ai-chat-core
The low-level, headless API client and state management engine for Happiest Chat.
This package contains zero UI and is framework-agnostic. It is the underlying engine powering @happiest-team/ai-chat and @happiest-team/ai-chat-native. Use this package if you are building an integration for Vue, Angular, Svelte, or Vanilla JS.
🚀 Features
- Framework Agnostic: Runs in browser environments, Node.js, edge workers, and mobile architectures.
- Pure State Management: Exposes reactive session initialization, message sending, and token validation logic.
- Zero Dependencies: Tiny footprint to keep your bundle sizes heavily optimized.
📦 Installation
npm install @happiest-team/ai-chat-core🛠 API Reference
createHappiestClient(clubId, config?)
Initializes the core client that manages network interactions.
import { createHappiestClient } from '@happiest-team/ai-chat-core';
const client = createHappiestClient('YOUR_CLUB_ID', {
integrationId: 'OPTIONAL_INTEGRATION_ID',
theme: { primary: '#000000' }
});Session Management
// 1. Initialize the session & fetch widget config
const { token, config } = await client.initSession({
userId: 'usr_123',
metadata: { plan: 'pro' }
});
// 2. Send a message to the AI agent
const reply = await client.sendMessage('What are your opening hours?', {
onStream: (chunk) => {
console.log("Streaming response...", chunk);
}
});📄 License
MIT © Happiest
