Placing web widget on the website

To allow website users to access the chat widget, its code must be placed on your webpage. The widget loads asynchronously, so its presence on the page should not affect its performance.

On every page where the widget should be visible, place its code. The code consists of two parts: one that calls the external SDK file and a function that initializes the web widget.

Script calling the SDK:

<script> (function () {var kb = document.createElement('script'); kb.type = 'text/javascript'; kb.async = true; kb.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'web.kodabots.com/web.sdk.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(kb, s); })(); </script>

Script initializing the web widget:

<script> window.initKBWebSDK = function(SDK) { SDK.initKBChatbot({ "token":"43552f88-daca-XXXX-XXXX-XXXXXXXXXXXX"}); } </script>

Remember to check if the token pasted on the website matches with the one assigned to your bot.

Both scripts should be placed in the HTML code of each page where the chatbot is to function, just before the closing </body> tag. The scripts should be placed one after the other.

Table of contents