@frigade/assistant
Frigade Assistant: an in-product assistant that answers your users' questions inside your web app.
Install
npm install @frigade/assistant
Requires react and react-dom 18-19 as peer dependencies.
Usage
import * as FrigadeAssistant from '@frigade/assistant';
FrigadeAssistant.init({
apiKey: 'YOUR_FRIGADE_PUBLIC_API_KEY',
apiUrl: 'https://api.frigade.ai',
userId: 'user-123',
});
Call it once, in the browser, after your app loads.
Controls
FrigadeAssistant.show(); // open the assistant, ready for a question
FrigadeAssistant.hide(); // take it off the page; it keeps running
FrigadeAssistant.close(); // end the conversation, back to the collapsed button
FrigadeAssistant.ask({ question: 'What can you do?' });
FrigadeAssistant.getMode(); // 'pre-init', 'hidden', 'collapsed', 'input', ...
Calls made before the assistant has mounted are queued and run once it does. getMode() returns 'pre-init' until then.
Events
const unsubscribe = FrigadeAssistant.on('ask', ({ query }) => {
console.log('User asked', query);
});
unsubscribe();
Handlers can be registered before or after init. off(event, handler) also removes a handler. See the EventType type for all events.
Options
| Option | Type | Description |
|---|---|---|
apiKey | string | Required. Your Frigade public API key. |
apiUrl | string | Required. Frigade API URL. |
userId | string | ID of the signed-in user. |
userProperties | Record<string, unknown> | Extra properties about the user. |
assistantId | string | Scope requests to a specific assistant. |
locale | string | Force the UI language (e.g. 'es-MX'). Defaults to browser. |
defaultVisible | boolean | Whether the assistant is visible on load. Defaults to true. |
See the FrigadeAssistantConfig type for the full list.
License
See LICENSE.