<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Prevent bot from loading immediately in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297694#M27962</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/66274"&gt;@WendyGoh&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the code you provided and I am still having a problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code in my script file.&lt;/P&gt;&lt;PRE&gt;$(document).ready(function() {
  console.log('bot test 1');

  if (window.HubSpotConversations) {
    console.log('The api is ready already');
    window.hsConversationsSettings = {
      loadImmediately: false,
    };
  }else {
    window.hsConversationsOnReady = [
      () =&amp;gt; {
        console.log('The api is now ready');
        window.hsConversationsSettings = {
          loadImmediately: false,
        };
      },
    ];
  }
});&lt;/PRE&gt;&lt;P&gt;I have the example running here:&amp;nbsp;&lt;A href="https://campaign.bupaglobal.com/test-page" target="_blank"&gt;https://campaign.bupaglobal.com/test-page&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issues I am seeing are that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The code to prevent the bot from loading inside the "if (window.HubSpotConversations) {" statement, does not work.&amp;nbsp; The bot still shows when we go into that IF statement.&lt;/P&gt;&lt;P&gt;2. The "window.hsConversationsOnReady" deferrer is not always called. (try refreshing a few times and you'll see that the message I am logging does not always come through)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Oct 2019 07:02:47 GMT</pubDate>
    <dc:creator>Siyabonga</dc:creator>
    <dc:date>2019-10-21T07:02:47Z</dc:date>
    <item>
      <title>Prevent bot from loading immediately</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297539#M27942</link>
      <description>&lt;P&gt;if (window.HubSpotConversations) {&lt;BR /&gt;console.log('The api is ready already');&lt;BR /&gt;&lt;BR /&gt;window.hsConversationsSettings = {&lt;BR /&gt;loadImmediately: false,&lt;BR /&gt;};&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I am trying to prevent my chatbot from loading immediately on my page using the above code, but for some reason the code doesn't work, the bot is loading on the page.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bot.PNG" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/20753i1A9D89AF1115CB4A/image-size/large?v=v2&amp;amp;px=999" role="button" title="bot.PNG" alt="bot.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 15:04:25 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297539#M27942</guid>
      <dc:creator>Siyabonga</dc:creator>
      <dc:date>2019-10-18T15:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent bot from loading immediately</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297683#M27959</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/93739"&gt;@Siyabonga&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope all is well with you &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned on this documentation -&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/methods/conversations_api/hubspot-conversations-javascript-api#loadImmediately" target="_blank"&gt;HubSpot Conversations JavaScript API:&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;The API is housed in the&amp;nbsp;&lt;CODE&gt;window.HubSpotConversations&lt;/CODE&gt;&amp;nbsp;object. All available methods can be accessed via this object. The HubSpot script loader on your page will create this object for you, but it may not be available immediately. To defer accessing the API until it has been initialized, you may use the&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/methods/conversations_api/hubspot-conversations-javascript-api#hsConversationsOnReady" target="_blank"&gt;&lt;CODE&gt;window.hsConversationsOnReady&lt;/CODE&gt;&lt;/A&gt;&amp;nbsp;helper.&lt;/EM&gt; "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And so, can you try the following code and see if this works for you:&lt;/P&gt;
&lt;PRE&gt;&amp;lt;script &amp;gt;
        if (window.HubSpotConversations) {
            window.hsConversationsSettings = {
                loadImmediately: false,
            };
        }else {
            window.hsConversationsOnReady = [
                () =&amp;gt; {
                    window.hsConversationsSettings = {
                        loadImmediately: false,
                    };
                },
            ];
        }
&amp;lt;/script&amp;gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2019 04:32:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297683#M27959</guid>
      <dc:creator>WendyGoh</dc:creator>
      <dc:date>2019-10-21T04:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent bot from loading immediately</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297694#M27962</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/66274"&gt;@WendyGoh&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the code you provided and I am still having a problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code in my script file.&lt;/P&gt;&lt;PRE&gt;$(document).ready(function() {
  console.log('bot test 1');

  if (window.HubSpotConversations) {
    console.log('The api is ready already');
    window.hsConversationsSettings = {
      loadImmediately: false,
    };
  }else {
    window.hsConversationsOnReady = [
      () =&amp;gt; {
        console.log('The api is now ready');
        window.hsConversationsSettings = {
          loadImmediately: false,
        };
      },
    ];
  }
});&lt;/PRE&gt;&lt;P&gt;I have the example running here:&amp;nbsp;&lt;A href="https://campaign.bupaglobal.com/test-page" target="_blank"&gt;https://campaign.bupaglobal.com/test-page&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issues I am seeing are that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The code to prevent the bot from loading inside the "if (window.HubSpotConversations) {" statement, does not work.&amp;nbsp; The bot still shows when we go into that IF statement.&lt;/P&gt;&lt;P&gt;2. The "window.hsConversationsOnReady" deferrer is not always called. (try refreshing a few times and you'll see that the message I am logging does not always come through)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 07:02:47 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297694#M27962</guid>
      <dc:creator>Siyabonga</dc:creator>
      <dc:date>2019-10-21T07:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent bot from loading immediately</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297711#M27963</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/93739"&gt;@Siyabonga&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for sharing the page.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On my end, I have clone out the page and name it as hstest that is using a clone template and a clone javascript file. I made two changes here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#1&amp;nbsp;When looking at the placement of your javascript file, I noticed you added both the tracking code and chatbot-script javascript in the '&lt;EM&gt;Additional markup before &amp;lt;/body&amp;gt;&lt;/EM&gt;'. I shifted it to the '&lt;EM&gt;Additional &amp;lt;head&amp;gt; markup&lt;/EM&gt;' so that the script is loaded before anything else.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#2 In the javascript file, I removed&amp;nbsp;&lt;EM&gt;$(document).ready(function() {&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, if you look at this page -&amp;nbsp;&lt;A href="https://campaign.bupaglobal.com/test-page-0-0-0?hs_preview=vJdsHqyx-18747364193?adsfd" target="_blank"&gt;https://campaign.bupaglobal.com/test-page-0-0-0?hs_preview=vJdsHqyx-18747364193?adsfd&lt;/A&gt;&amp;nbsp;&amp;gt; It is working! &amp;gt; I tried refresh multiple times and the chat bot didn't appear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do get it a try and see if it's working well for you.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 08:11:05 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297711#M27963</guid>
      <dc:creator>WendyGoh</dc:creator>
      <dc:date>2019-10-21T08:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent bot from loading immediately</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297866#M27977</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/66274"&gt;@WendyGoh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code works well for me, however I am still having a problem with my first point .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. &lt;SPAN&gt;The code to prevent the bot from loading inside the "if (window.HubSpotConversations) {" statement, does not work.&amp;nbsp; The bot still shows when we go into that IF statement.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 17:01:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297866#M27977</guid>
      <dc:creator>Siyabonga</dc:creator>
      <dc:date>2019-10-21T17:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent bot from loading immediately</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297984#M27986</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/93739"&gt;@Siyabonga&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Glad to know that it's working well for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's because the HubSpot script loader on your page will create the window.HubSpotConversations for you, but it may not be available immediately and hence we need another else statement to defer accessing the API until it has been initialized by using window.hsConversationsOnReady.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 01:33:39 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Prevent-bot-from-loading-immediately/m-p/297984#M27986</guid>
      <dc:creator>WendyGoh</dc:creator>
      <dc:date>2019-10-22T01:33:39Z</dc:date>
    </item>
  </channel>
</rss>

