1. Always call Intercom.logout() before loginUserWithUserAttributes().
2. Avoid calling loginUnidentifiedUser() if the user is logged in.
3. Use Intercom.getUserId() to check session state before switching users.
This should prevent session conflicts and resolve the error. Let me know if you need further debugging! 🚀
Thank you for your response!
As per the Intercom documentation, an unidentified user should automatically transition to an identified user, carrying over any attributes and conversations. However, based on your previous response, it seems like this transition does not happen automatically. Please check below image
In our app, we need to maintain the continuity of the user’s session, ensuring that any data from the unidentified user (guest session) is retained when the user logs in. Since calling Intercom.logout() clears all local user data, we cannot use it before loginUserWithUserAttributes(), as it would disrupt this transition.
Can you clarify the best approach to ensure a seamless transition from an unidentified user to an identified user without losing conversations or attributes?
Hi @seema.nagar – thanks for the follow-up and for sharing your concerns!
You’re absolutely right to refer to the Intercom documentation — Intercom does support transitioning from an unidentified user to an identified user while preserving conversations and attributes, as long as the transition is handled correctly.
Clarification on the Transition Behavior
By default, Intercom will automatically associate the existing anonymous session with the identified user when you call loginUserWithUserAttributes() — as long as you haven’t explicitly logged out beforehand.
That means: • You should not call Intercom.logout() before logging in the identified user if you want to preserve the anonymous session’s data (like conversations or events). • When loginUserWithUserAttributes() is called, Intercom merges the anonymous session into the identified one, maintaining continuity.
Best Practice for Seamless Transition
To ensure continuity without data loss:
// When the user is anonymous Intercom.loginUnidentifiedUser();
// Later, when the user logs in Intercom.loginUserWithUserAttributes({ userId: loggedInUserId, });
There’s no need to call Intercom.logout() in this flow. Logging out will wipe local session data, which is what we want to avoid in your case.
📌 Use Intercom.logout() Only When: • You want to explicitly clear all local user data (e.g. when a user logs out of your app). • You’re switching between two known users.
⸻
So in summary: - To retain session data → go straight from loginUnidentifiedUser() to loginUserWithUserAttributes() without logging out. - Do not call Intercom.logout() unless you’re intentionally clearing the session.
Let me know if you’d like help validating this behavior in your app — happy to assist!