A chat widget you can actually program
One script tag to install. A small JavaScript API to control it. Signed identity for your logged-in users. A REST API with scoped keys for everything else.
Add it to any site
Paste the snippet before the closing body tag. You will find your site ID in the dashboard under Websites. The script loads asynchronously and sits in its own shadow DOM, so it never clashes with your styles.
<script
src="https://api.recursivechat.dev/widget.js"
data-site="wgt_your_site_id"
async
></script>Control the widget from your code
Call window.RecursiveChat with a command name. Calls made before the script has loaded are queued and run once it is ready.
- open / close / toggle
- Show or hide the chat panel from your own UI.
- identify
- Link the visitor to your signed-in user so their history follows them across devices.
- setMetadata
- Attach key and value pairs, such as plan or order number, shown to your team.
- sendMessage
- Send a message on the visitor’s behalf, for example from a help button.
- reset
- Forget the current visitor and close the chat, for example on sign out.
// Calls made before the script loads are queued
window.RecursiveChat = window.RecursiveChat || function () {
(window.RecursiveChat.q = window.RecursiveChat.q || []).push(arguments);
};
// Open the chat from your own button
document.querySelector('#help').addEventListener('click', () => {
RecursiveChat('open');
});
// Attach context your team will see in the inbox
RecursiveChat('setMetadata', { plan: 'pro', orderId: 'A-10442' });
// Start the conversation with a question
RecursiveChat('sendMessage', 'I need help with my order');Recognise your signed-in users
Sign each user ID on your server with your site's identity secret using HMAC-SHA256, then pass it to the widget. RecursiveChat checks the signature, so nobody can pretend to be another customer, and the same person keeps one conversation history on every device.
// On your server (Node.js)
import { createHmac } from 'node:crypto';
const signature = createHmac(
'sha256',
process.env.RECURSIVECHAT_IDENTITY_SECRET,
)
.update(String(user.id))
.digest('hex');// In the browser, after the user signs in
RecursiveChat('identify', {
externalCustomerId: user.id,
signature, // from your server
name: user.name,
email: user.email,
});
// When they sign out
RecursiveChat('reset');Everything in the dashboard, over HTTP
Create API keys in the dashboard and give each one only the scopes it needs, read or write. Send the key as a Bearer token.
- conversations
- visitors
- agents
- knowledge
- sites
- members
- usage
curl https://api.recursivechat.dev/v1/conversations?workspaceId=ws_your_workspace&status=open \
-H "Authorization: Bearer rc_sk_your_secret_key"Get your site ID in a minute
Create a free account, add your website and copy the snippet. No card needed.