Connect signed-in users to Messenger

Issue a Messenger identity from your backend, boot the widget, and clear the session when the user signs out.

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.

  1. After authenticating the user in your application, send POST /messenger/identity from the backend with Authorization: Bearer <messenger-key> and Content-Type: application/json. Derive the fields from your authenticated account record.
  2. Send JSON such as {"user_id":"customer-123","name":"Sam Lee","email":"sam@example.com"}. A successful response is HTTP 201 and includes messenger_token, expires_at in Unix seconds, and contact_id.
  3. Return the scoped token to that user’s frontend and call SupportDesk('boot', { messenger_token: token }). If you also track identified events, include event_token in the same call.
  4. 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.

Related reading

Was this article helpful?