Your app backend→Website Chat→OpenAI
Your app calls the mod on your server. The mod saves its records in your database and uses your own provider accounts for the features you enable.
Start the configured Website Chat service with persistent SQLite storage. Set MOD_ORIGIN to its configured backend origin. Use the configured HTTPS service origin in production.
Open a visitor conversation
Open a visitor conversation, then read its saved history. The service returns a token for that conversation. This probe reads its history, then deletes the sample through /api/forget. In your app, retain the token to resume the conversation and use the deletion route when the visitor chooses to forget it. An expired token requires a new session. Visitor tokens are separate from app sign-in and staff access.
Visitor session request example
Save this as integration-example.mjs and run node --env-file=.env integration-example.mjs. These requests do not send email, take payment or call an AI model.
const origin = process.env.MOD_ORIGIN;
if (!origin) throw new Error('Set MOD_ORIGIN to your chat service origin');
const started = await fetch(new URL('/api/session', origin), {
method: 'POST', redirect: 'error', credentials: 'omit',
signal: AbortSignal.timeout(10000), headers: { Origin: origin },
});
if (!started.ok) throw new Error('Session request failed: ' + started.status);
const { token } = await started.json();
const response = await fetch(new URL('/api/history', origin), {
redirect: 'error', credentials: 'omit', signal: AbortSignal.timeout(10000),
headers: { Origin: origin, Authorization: 'Bearer ' + token },
});
if (!response.ok) throw new Error('History request failed: ' + response.status);
console.log(await response.json());
const forgotten = await fetch(new URL('/api/forget', origin), {
method: 'DELETE', redirect: 'error', credentials: 'omit',
signal: AbortSignal.timeout(10000),
headers: { Origin: origin, Authorization: 'Bearer ' + token },
});
if (!forgotten.ok) throw new Error('Cleanup request failed: ' + forgotten.status);