Short answer
From your server, call POST /visitor-identification/v3/tokens/create with the signed-in user's email. On the page, set loadImmediately: false, then identificationEmail and identificationToken on window.hsConversationsSettings, and load the widget. Tokens expire after 12 hours and must be set on every page load. The API needs a Professional or Enterprise subscription; otherwise it returns 403.
1. Server side
POST https://api.hubapi.com/visitor-identification/v3/tokens/create
{ "email": "visitor@example.com", "firstName": "Pat", "lastName": "Lee" }
Only do this after your own system has verified the user. Never generate tokens from the browser.
2. Page side
window.hsConversationsSettings = {
loadImmediately: false,
identificationEmail: "visitor@example.com",
identificationToken: "TOKEN_FROM_YOUR_SERVER"
};
window.HubSpotConversations.widget.load();
Set the settings object before the widget loads, or you can get a race where the widget starts anonymous.
3. Related
Chat setup: website chatflows and inbox channels.