Updated: 1/8/2025

How to integrate your webchat to your site?


These methods can be used anywhere on the web and called as a javascript function.

  • Hide webchat: bmHide()
  • Show webchat: bmShow()
  • Minimize webchat: bmMinimize()
  • Maximize webchat: bmMaximize()
  • Webchat information: bmInfo()
  • Set variables: bmSetVariables({“variable1”: “value1”, “name”: “updated name”})
  • Send message: bmSendMessage(‘message to send’). This message will be sent automatically by the client.




Using Variables in Webchat

You can edit existing variables at the beginning of a Webchat conversation.

Set variables

Within the code snippet used to integrate webchat into your site, you can set variables with external information.

A new object must be added to contain the variables with the values ​​to be edited. The object is BOTMAKER_VAR.



<script>
    /* Aquí deben ser definidas todas las variables- */
    var BOTMAKER_VAR = {
        firstName: 'newValueForFirstName',
        lastName: 'newValueForLastName',
        customVar: 'newValueForCustomVar'
    };

    (function () {
        let js = document.createElement('script');
        js.type = 'text/javascript';
        js.async = 1;
        js.src = 'https://go.botmaker.com/rest/webchat/p/XXXXX/init.js';
        document.body.appendChild(js);
    })();
</script>


                                                                                              

You can edit your own variables, such as firstName and lastName, or new variables. The only condition is that these variables already exist in the bot.                                                                          



How to maintain your system ID? 

                                                                                              

If you want to keep or use a unique ID or one from your system associated with the chat, you can send that data in the userIdOnBusiness variable inside BOTMAKER_VAR

 


<script>
    /* Aquí deben ser definidas todas las variables */
    var BOTMAKER_VAR = {
        userIdOnBusiness: 'myBusinessId',
        ...otherVariables
    };
    (function () {
        let js = document.createElement('script');
        js.type = 'text/javascript';
        js.async = 1;
        js.src = 'https://go.botmaker.com/rest/webchat/p/XXXXX/init.js';
        document.body.appendChild(js);
    })();
</script>


                                                                                                                                                                      

 Integration into Mobile App   

                                                                                                                                                                      

To integrate webchat on your mobile, you can choose to:

- Embed the webchat in a **webview**. The same script is used as for the web. For a better mobile experience, it is recommended to use the methods described in the webchat. 

 Ej:    

                                                                                                                                                                       

 ![](https://storage.googleapis.com/m-infra.appspot.com/public/res/SoporteBotmaker/20220322-SvahnYKi5mNUcM3FPWR2itGvP9h2-ZDOBA-.png)  

                                                                                                                                                                       

 - Integrate it into your own mobile app chat by integrating and processing incoming and outgoing messages through the Botmaker API.