Web widget
Add Jake Messenger to any website or signed-in web app
Web widget
TL;DR: Add one script tag. Create a token endpoint on your server. Approve the domain. Done.
What you need
- Public key from Settings → Workspace → Application keys
- Application secret stored on your server only
- Production origin in Approved widget domains
- A backend route that creates short-lived customer sessions
1. Approve the origin
Settings → Workspace → Application keys → add your production origin:
https://app.example.com2. Create a token endpoint
Add POST /api/jake/session to your backend. Require your normal auth — derive the customer ID from the trusted session.
const response = await fetch('https://app.tryjake.ai/v1/sdk/sessions', {
method: 'POST',
headers: {
authorization: `Bearer ${process.env.JAKE_APPLICATION_SECRET}`,
'content-type': 'application/json',
'x-jake-public-key': process.env.JAKE_PUBLIC_KEY!,
},
body: JSON.stringify({
externalId: signedInUser.id,
displayName: signedInUser.name,
email: signedInUser.email,
attributes: {
authenticated: true,
channel: 'web_widget',
platform: 'web',
plan: signedInUser.plan,
},
}),
});
if (!response.ok) throw new Error('Could not create a Jake customer session');
const { token, expiresIn } = await response.json();
return Response.json({ token, expiresIn, userId: signedInUser.id });Use a stable internal ID for externalId, not an email.
3. Add the widget
<script
async
src="https://widget.tryjake.ai/widget.js"
data-jake-public-key="YOUR_PUBLIC_KEY"
data-jake-token-endpoint="/api/jake/session"
></script>Customization
| Attribute | Purpose | Default |
|---|---|---|
data-jake-position | left or right | right |
data-jake-accent | Hex color override | Workspace color |
data-jake-locale | Customer locale | Browser locale |
data-jake-hide-launcher | Use your own button | false |
Custom button:
<button type="button" onclick="window.Jake.show()">Contact support</button>Browser API
window.Jake.show();
window.Jake.hide();
window.Jake.toggle();
window.Jake.shutdown(); // call on sign-out
const unsubscribe = window.Jake.on('unread', ({ count }) => { /* badge */ });Anonymous mode
Omit data-jake-token-endpoint for public-only questions. Anonymous sessions can't access private data or customer-specific actions.
Troubleshooting
- "Origin not approved" — add the exact origin in Settings → Workspace → Application keys
- Token endpoint errors — check the user is signed in and the public key matches the secret
- Launcher hidden — remove
data-jake-hide-launcheror callwindow.Jake.show()
Next: Go-live checklist →
