Use the same stable User ID your application uses for Bettercom events. A workspace owner can generate the dedicated Messenger identity key in Messenger setup. Keep it in your backend’s secret store.
- After authenticating the user in your application, send
POST /messenger/identityfrom the backend withAuthorization: Bearer <messenger-key>andContent-Type: application/json. Derive the fields from your authenticated account record. - Send JSON such as
{"user_id":"customer-123","name":"Sam Lee","email":"sam@example.com"}. A successful response is HTTP 201 and includesmessenger_token,expires_atin Unix seconds, andcontact_id. - Return the scoped token to that user’s frontend and call
SupportDesk('boot', { messenger_token: token }). If you also track identified events, includeevent_tokenin the same call. - Refresh the identity when it expires after one hour. Call
SupportDesk('shutdown')on logout or before booting a different account.
To verify, sign in as two test users in succession. Open Messages as each one and confirm each sees their own conversations.