Intercom Settings Object is not loading

Hi, I want to integrate Intercom Messenger into the app with the custom code option. I did put this code into the section. but it is not loading and not accesable thru the console:

<script>
    window.intercomSettings = {
    api_base: "https://api-iam.intercom.io",
    app_id: "mk7dlaha",
    user_id: wwLib.wwVariable.getValue("1831add6-b7d7-43c1-8b4f-5945b3bf5c4a"), // IMPORTANT: Replace "user.id" with the variable you use to capture the user's ID
    name: wwLib.wwVariable.getValue("ec42d099-6c09-4c95-a824-d351868389a6"), // IMPORTANT: Replace "user.name" with the variable you use to capture the user's name
    email: wwLib.wwVariable.getValue("c72c80ac-6f4d-4a65-96a6-8a431225f6ac"), // IMPORTANT: Replace "user.email" with the variable you use to capture the user's email address
    created_at: wwLib.wwVariable.getValue("edbb2c05-b054-4e64-baa8-7d3bc47d7b6f"), // IMPORTANT: Replace "user.createdAt" with the variable you use to capture the user's sign-up date
  };
</script>


<script>
    // We pre-filled your app ID in the widget URL: 'https://widget.intercom.io/widget/mk7dlaha'
  (function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/mk7dlaha';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})();
</script>

Any Idea?

For window, always use wwLib.getFrontWindow()

Thx for help. Could you share more details? How could I use it? Use

user_id: wwLib.getFrontWindow(“1831add6-b7d7-43c1-8b4f-5945b3bf5c4a”),

instead of

user_id: wwLib.wwVariable.getValue(“1831add6-b7d7-43c1-8b4f-5945b3bf5c4a”),

?

You need to use that instead of the window

I tried:

<script>
    // Log the variable values
    console.log("user_id:", wwLib.wwVariable.getValue("1831add6-b7d7-43c1-8b4f-5945b3bf5c4a"));
    console.log("name:", wwLib.wwVariable.getValue("ec42d099-6c09-4c95-a824-d351868389a6"));
    console.log("email:", wwLib.wwVariable.getValue("c72c80ac-6f4d-4a65-96a6-8a431225f6ac"));
    console.log("created_at:", wwLib.wwVariable.getValue("edbb2c05-b054-4e64-baa8-7d3bc47d7b6f"));

    // Set intercomSettings with the retrieved values
    wwLib.getFrontWindow().intercomSettings = {
        api_base: "https://api-iam.intercom.io",
        app_id: "mk7dlaha",
        user_id: wwLib.wwVariable.getValue("1831add6-b7d7-43c1-8b4f-5945b3bf5c4a"),
        name: wwLib.wwVariable.getValue("ec42d099-6c09-4c95-a824-d351868389a6"),
        email: wwLib.wwVariable.getValue("c72c80ac-6f4d-4a65-96a6-8a431225f6ac"),
        created_at: wwLib.wwVariable.getValue("edbb2c05-b054-4e64-baa8-7d3bc47d7b6f")
    };
</script>

<script>
    (function(){
        var w = wwLib.getFrontWindow();
        var ic = w.Intercom;

        if(typeof ic === "function"){
            ic('reattach_activator');
            ic('update', w.intercomSettings);
        } else {
            var d = w.document;
            var i = function(){ i.c(arguments); };
            i.q = [];
            i.c = function(args){ i.q.push(args); };
            w.Intercom = i;
            var l = function(){
                var s = d.createElement('script');
                s.type = 'text/javascript';
                s.async = true;
                s.src = 'https://widget.intercom.io/widget/mk7dlaha';
                var x = d.getElementsByTagName('script')[0];
                x.parentNode.insertBefore(s, x);
            };
            if (d.readyState === 'complete'){
                l();
            } else if (w.attachEvent){
                w.attachEvent('onload', l);
            } else {
                w.addEventListener('load', l, false);
            }
        }
    })();
</script>

but it is still not working. Any Ideas?

image

It looks like wwLib isn´t loaded when weweb is injecting the java script.

Did you find a solution for it?