Integrate and Customize the Business Messaging (BM) Widget Using JavaScript APIs

Integrating Custom Actions in the Business Messaging Widget


This guide explains how to integrate and customize the Business Messaging (BM) widget within your web application. It covers setting up an IM channel, creating a global ZOHOIM object, and customising the widget’s layout and appearance.
  

JavaScript API Overview

JavaScript APIs for business messaging are client-side APIs designed to manage contact information, events, and API calls related to the BM widget. You can use these APIs to pre-fill data, retrieve contact details, and customize the widget’s appearance.


Using the JavaScript API

To use the necessary JavaScript API, you need to copy and paste the relevant code into the source code of your website within the <script> tags. Before executing the BM script, ensure that you have set the respective JavaScript API details in the code.
 

BM Widget  Setup

To display the BM widget:
  1. Create a Channel in IM.
  2. Obtain the channel's Embedded Code Script.
  3. Inject the Embedded Code Script into your webpage.
  4. Initialize the ZOHOIM object before injecting the script:
    1. window.ZOHOIM = window.ZOHOIM || {};
  5. Set the necessary properties for rendering the BM widget within the window.ZOHOIM variable.

BM widget script sample 

  1. <script type="text/javascript" nonce="{place_your_nonce_value_here}" src="https://im.zoho.com/api/v1/public/channel/435798000000140015/widget" defer> var _d=document;_d.prefilledMessage=</script>


Set API 

Define the following properties in window.ZOHOIM before rendering the widget:

Prop Name
Type
Description
widgetContainerId
string
Element ID in which ZBM will be rendered
widgetLayout
object
Describes the options required for customising the ZBM Widget layout
widgetLayout.showWidget
boolean
Whether to show the BM widget
widgetLayout.needWidgetBubble
boolean
Whether to render the BM widget with the Bubble Icon or not
widgetLayout.needCloseIcon
boolean
In the ZBM Widget header, whether the close Icon is required or not
widgetProps.sessionVariableValues
array
To set a session variable for GC bot
Refer here
**customStyles
string
Describes the options required for customizing the styles of ZBM Widget
customStyles.mode
string
In which mode ZBM needs to be rendered. expected values : "light", "dark"
customStyles.theme
string
Describes the theme of ZBM widget.   expected value : Hex Color Code
customStyles.actionTheme
string
Describes the action theme of ZBM widget. expected value : Hex Color Code
customStyles.wallpaper
object
Describes the options required for ZBM widget wallpaper.
customStyles.wallpaper.src
object
Describes the options required for ZBM widget wallpaper in different modes.
customStyles.wallpaper.src.light
string
Wallpaper needs to be rendered in light mode. expected value : Image URL
customStyles.wallpaper.src.dark
string
Wallpaper needs to be rendered in dark mode. expected value : Image URL
poweredByTag
object
Describes the options required for rendering the powered by tag in ZBM Widget footer.
poweredByTag.isChecked
boolean
Whether to display the powered by tag or not in the ZBM footer
customHandlers
object
Describes the options required for the functionality of the ZBM Widget
customHandlers.closeButtonHandler
function
Executes when the close icon is clicked
customHandlers.backButtonHandler
function
Executes when the back icon is clicked
customHandlers.openArticle
function
Executes when the article message is clicked
Refer here

Trigger API 

The following methods allow communication between the BM widget and your application.
Method Name
Description
Arguments
Return Value
triggerEvent
triggers a particular event that executes all the methods which are subscribed to the triggered event
ZOHOIM.triggerEvent('eventName',...args)
NIL
subscribeToEvent
A method can subscribe to a particular event
ZOHOIM.subscribeToEvent( 'eventName', method)
NIL
 
 
 Below is a sample code snippet illustrating how to render the BM widget. 
       

<html>

<head>

<title>Page Title</title>

<script>

window.ZOHOIM = window.ZOHOIM || {};

window.ZOHOIM.widgetContainerId = "test";

window.ZOHOIM.widgetLayout = { needWidgetWithBubble : false, needCloseIcon : true};

window.ZOHOIM.customStyles = '{ "mode": "light", "theme": "#71198c","actionTheme":"#1a7063", "wallpaper": {"src": {"light":"https://fastly.picsum.photos/id/703/536/354.jpg?hmac=1NZ7SzrTrnA-1O2S18kJC-IFIOZyYeHt8x98Iqdd5kM"}},"poweredByTag": { "isChecked": false } }';

customCloseButtonHandler = ()=>{alert('clicked the close button');}

customBackButtonHandler = ()=>{

  if(a===1){

    a=0;

    window.ZOHOIM.triggerEvent('showCloseIcon',true);

  }else{

    a=1;

    window.ZOHOIM.triggerEvent('showCloseIcon',false);

  }

}

window.ZOHOIM.customHandlers = {

closeButtonHandler : customCloseButtonHandler,

backButtonHandler : customBackButtonHandler

}

</script>

 

<script type="text/javascript" nonce="{place_your_nonce_value_here}" src="https://implus.localzoho.com/api/v1/public/channel/c572beb392335194a3f8e528fb092408/widget" defer> var _d=document;_d.prefilledMessage= </script>

</head>

 

<body>

<div id="test" style="height: 500px; width: 400px; border: 1px solid black;"></div>

</body>

</html>



Get Contact Info API

You can provide custom contact information using widgetProps.

Prop Name
Type
Description
ContactInfo
object
Describes the details of the contact

 
Sample
  1. window.ZOHOIM.widgetProps = { 'contactInfo': {'name':'Manoj','phone': '+91203354', 'email': 'abc@gmail.com'}};

 

Authenticated Cases  API

We provide the following methods to handle authenticated flows with Business Messaging.

Method to set Csrfcookie: 

  1. window.ZOHOIM.setCsrfParamName(csrfParamName);

  2. window.ZOHOIM.setCsrfToken(csrfToken);

 

Method to set OAuth (JWT case):

  1. window.ZOHOIM.setAuthtoken(token);


Method to set Domain:

  1. window.ZOHOIM.setCustomDomainUrl(DomainURL);

  

Method to add ZohoAccountId to BM:

  1. window.ZOHOIM.setZaid(zaid);


Pre-Render Action API:

You can execute actions before rendering the widget.

  1. window.ZOHOIM.beforeRenderCallback= () => {

  2.         //todo

  3. }


BM Widget Control Changes

We've introduced a set of public methods that allow end users to control the Business Messaging (BM) widget directly from the page. These methods enable dynamic interaction with the widget interface.

Supported Events

Event Name
Description
openWidget
Opens the BM widget
closeWidget
Closes the BM widget
toggleWidget
Toggles the widget between open and closed states
showBubble
Displays the widget's bubble icon
hideBubble
Hides the widget's bubble icon

Sample Implementation

The following code snippet is only a sample to demonstrate how you can use the new widget control methods.


  1. <script>  
  2. window.ZOHOIM = window.ZOHOIM || {};
  3. function closeWidget() { 
  4.     const { triggerEvent } = window.ZOHOIM;
  5.     triggerEvent('closeWidget');
  6. } 
  7. function openWidget() {  
  8.     const { triggerEvent } = window.ZOHOIM;
  9.     triggerEvent('openWidget');
  10. } 
  11. function toggleWidget() {  
  12.     const { triggerEvent } = window.ZOHOIM;
  13.     triggerEvent('toggleWidget');
  14. }
  15. </script>  

  16. <button type="button" onclick="openWidget()">Open</button>
  17. <button type="button" onclick="closeWidget()">Close</button>
  18. <button type="button" onclick="toggleWidget()">Toggle</button>




      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsRetailOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceForms for Solopreneurs
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit
                              Forms for Government
                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic FormsInsurance
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsWufoo alternativeEncrypted Forms
                              Accessible FormsTypeform alternativeSecure Forms

                              WCAG

                                          Create. Review. Publish.

                                          Write, edit, collaborate on, and publish documents to different content management platforms.

                                          Get Started Now






                                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                                Manage your brands on social media

                                                                  Use cases

                                                                  Make the most of Zoho Desk with the use cases.

                                                                   
                                                                    

                                                                  eBooks

                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                                   
                                                                    

                                                                  Videos

                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                                   
                                                                    

                                                                  Webinar

                                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                                   
                                                                    
                                                                  • Desk Community Learning Series


                                                                  • Meetups


                                                                  • Ask the Experts


                                                                  • Kbase


                                                                  • Resources


                                                                  • Glossary


                                                                  • Desk Marketplace


                                                                  • MVP Corner



                                                                    Zoho Sheet Resources

                                                                     

                                                                        Zoho Forms Resources


                                                                          Secure your business
                                                                          communication with Zoho Mail


                                                                          Mail on the move with
                                                                          Zoho Mail mobile application

                                                                            Stay on top of your schedule
                                                                            at all times


                                                                            Carry your calendar with you
                                                                            Anytime, anywhere




                                                                                  Zoho Sign Resources

                                                                                    Sign, Paperless!

                                                                                    Sign and send business documents on the go!

                                                                                    Get Started Now




                                                                                            Zoho TeamInbox Resources





                                                                                                      Zoho DataPrep Demo

                                                                                                      Get a personalized demo or POC

                                                                                                      REGISTER NOW


                                                                                                        Design. Discuss. Deliver.

                                                                                                        Create visually engaging stories with Zoho Show.

                                                                                                        Get Started Now










                                                                                                                            • Related Articles

                                                                                                                            • Guided Conversations in Business Messaging

                                                                                                                              What is Guided Conversations? Guided Conversations (GC) is a powerful conversation builder platform that allows you to create structured, automated chat flows. With a variety of ready-to-use blocks and seamless integration capabilities, GC helps ...
                                                                                                                            • Add an embeddable Business Messaging chat bubble to your website

                                                                                                                              You can handle your customer questions instantly from a dedicated Business Messaging channel facilitated by Zoho Desk. This feature also allows businesses to communicate the latest trends, track their sales, and more. The Business Messaging user ...
                                                                                                                            • Working With Custom Actions Gallery

                                                                                                                              Zoho Desk offers numerous functionalities to automate, customize, and simplify your customer support process. It allows you to create webhooks and write custom functions to automate your repetitive support workflows, reduce the manual ...
                                                                                                                            • FAQs: Custom Actions Gallery

                                                                                                                              What is Custom Actions Gallery? Custom actions gallery includes a set of custom actions that help you automate key tasks, like assigning tickets, adding/removing tags, adding followers/comments, sending email replies, replying and notifying via ...
                                                                                                                            • Session Variables in Business Messaging

                                                                                                                              A session variable is a temporary piece of information that captures user-specific details, such as name, email, or phone number, while they’re using the chat or flow in your website. It helps the Business Messaging widget remember who the user is ...
                                                                                                                              Wherever you are is as good as
                                                                                                                              your workplace

                                                                                                                                Resources

                                                                                                                                Videos

                                                                                                                                Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                                eBooks

                                                                                                                                Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                                Webinars

                                                                                                                                Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                                CRM Tips

                                                                                                                                Make the most of Zoho CRM with these useful tips.



                                                                                                                                  Zoho Show Resources