Issue with Web Messenger after Intercom('shutdown') and Intercom('boot'); | Community
Skip to main content

I`m using the FIN Messenger in a test website. The frontend always call to call to  Intercom('shutdown') and Intercom('boot’) on page load. Before that, we get the JWT form our backend an send that to the messenger throught the API. That works well.

The problem is when the user logs out of our backend, reloading the page still shows the conversation of the user who logged out.

As if Intercom('shutdown'); and Intercom('boot', config); weren't working.


 

function bootIntercom(config) {
    if (window.Intercom) {
        window.Intercom('shutdown');
    }
    window.Intercom('boot', config);
}

(async () => {
    const status = document.getElementById('statusContainer');
    try {
        const res = await fetch('https://REDACTED/autenticar', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            credentials: 'include'
        });
        const data = await res.json();
        if (res.ok && data.success && data.token) {
            status.innerText = `✅ Autenticado como ${data.payload.user_first_name}`;
            bootIntercom({
                api_base: "https://api-iam.intercom.io",
                app_id: "REDACTED",
                intercom_user_jwt: data.token,
                session_duration: 86400000
            });
        } else {
            status.innerText = '⚠️ Sesión no iniciada. Modo visitante.';
            bootIntercom({
                api_base: "https://api-iam.intercom.io",
                app_id: "REDACTED"
            });
        }
    } catch {
        status.innerText = '❌ Error al verificar sesión';
        bootIntercom({
            api_base: "https://api-iam.intercom.io",
            app_id: "REDACTED"
        });
    }
})();

 

Hi ​@Diego Vitali ! Ebenezer here from Engineering Support👋.

Could you check out these troubleshooting steps?

  • Ensure Correct Logout Flow:

    • On user logout, call Intercom('shutdown') as the very first step in your logout handler, before any page reload or redirect.
    • After shutdown, if you want Messenger to be available for visitors, call Intercom('boot', {app_id: ...}) with no user data.
    • On login, after obtaining the new JWT, call Intercom('boot', config) with the new user's data and JWT.
  • Check for Asynchronous Issues:

    • Make sure that Intercom('shutdown') completes before any subsequent Intercom('boot', ...) call. In some frameworks, especially SPAs, race conditions can occur if both are called in quick succession.
  • Verify Cookie Removal:

    • After calling Intercom('shutdown'), check that the intercom-session-sapp_id] cookie is actually removed from the browser. If it persists, Messenger may still show the previous user's data.

       

  • Debug with Installation Logs:

    • Use the installation logs and token debugger in Intercom's Messenger settings to check for errors related to JWTs and session handling.

       

  • Session Duration Settings:

    • Consider aligning the Messenger session duration with your application's session timeout to minimize the risk of session persistence.

       

  • SPA Considerations:

    • In Single Page Applications, always manually trigger Intercom('shutdown') on logout, and do not rely solely on page reloads to clear the session.

       


Reply