@frigade/assist-api
v1.5.0
Published
Frigade Assist API - Add product answers and live guidance to your agent
Readme
@frigade/assist-api
Frigade Assist API: add product answers and live, on-page guidance to your own AI agent.
Install
npm install @frigade/assist-apiRequires react and react-dom 18-19 as peer dependencies.
Usage
import * as FrigadeAssistAPI from '@frigade/assist-api';
FrigadeAssistAPI.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. Then launch a guide from your agent:
const result = await FrigadeAssistAPI.query({
intent: 'Invite a teammate',
});Or pass a Vercel AI SDK tool call straight through (returns null if the tool call isn't Frigade's):
const result = await FrigadeAssistAPI.handleToolCall(toolCall);result.status is one of started, answer, needs_clarification, cancelled, unavailable, or error. Calls made before init resolve unavailable with reason not-initialized; calls made while init is still loading wait for it.
Dismiss the running guide:
FrigadeAssistAPI.close();A query() still in flight resolves cancelled, as it does when the user closes the guide card. Before init, or with no guide running, close() does nothing.
Static guides
FrigadeAssistAPI.showStaticGuide({
query: 'How do I invite a teammate?',
steps: [
{ selector: '#invite-button', content: 'Click **Invite**' },
{ selector: '#email-input', content: 'Enter their email address' },
],
});Shows a guide you wrote yourself, with no AI query. Notes:
- Needs the
static-guidesfeature flag on your assistant (contact Frigade to enable it). Without it, the call logs a console warning and does nothing. - Each
selectormust match exactly one visible element on the page. There is no recovery if it doesn't. - Limits:
query1-2000 characters, 1-20 steps,selector1-1000 characters,content1-5000 characters (markdown). Nothing may be blank. - Runs appear in the dashboard as questions on the "Static guide" channel and don't count toward usage.
- There are no thumbs up/down on static guides.
- Calls made before
initare queued and run once the assistant is ready.
Events
const unsubscribe = FrigadeAssistAPI.on('complete', () => {
console.log('Guide completed');
});
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. |
See the FrigadeAssistAPIConfig type for the full list.
License
See LICENSE.
