Table of Content

    Chat Widget Controller

    • July 23, 2025
    • 2 mins read

    Table of Content

      Using the Chat Widget Controller API, you can control the behavior of the chat widget when a user clicks any button or hyperlink on your website.

      $_REVECHAT_API(function(){ … });

      1. Maximize the widget

      To automatically maximize the widget — either when a user visits your website or when they click a button — use this function.

      
      Paste following code snippet into webpage to maximize the chat widget
      ​
      <a href="javascript:void($_REVECHAT_API && $_REVECHAT_API['Button'] &&$_REVECHAT_API.Button.maximize())">chat with us</a>

      How to use
      <script type='text/javascript'>
       window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account='12-12-12-12';w.__revechat_version=2;
         r._= []; var rc = d.createElement('script'); rc.type = 'text/javascript'; rc.async = true; rc.setAttribute('charset', 'utf-8');
         rc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'static.revechat.com/co-browsing/new-livechat.sjs?'+new Date().getTime();
         var s = d.getElementsByTagName('script')[0]; s.parentNode.insertBefore(rc, s);
       })(document, window);
      </script>
      
      <a href="javascript:void($_REVECHAT_API && $_REVECHAT_API['Button'] &&$_REVECHAT_API.Button.maximize())">chat with us</a>

      2. Minimize the widget

      To minimize the widget, use this function when you want to collapse it back after being opened.

      Paste following code snippet into webpage to minimize the chat widget
      
      <a href="javascript:void($_REVECHAT_API && $_REVECHAT_API['Button'] &&$_REVECHAT_API.Button.minimize())">chat with us</a>

      How to use
      <script type='text/javascript'>
       window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account='12-12-12-12';w.__revechat_version=2;
         r._= []; var rc = d.createElement('script'); rc.type = 'text/javascript'; rc.async = true; rc.setAttribute('charset', 'utf-8');
         rc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'static.revechat.com/co-browsing/new-livechat.sjs?'+new Date().getTime();
         var s = d.getElementsByTagName('script')[0]; s.parentNode.insertBefore(rc, s);
       })(document, window);
      </script>
       
      
      
      <a href="javascript:void($_REVECHAT_API && $_REVECHAT_API['Button'] &&$_REVECHAT_API.Button.minimize())">chat with us</a>

      3. Hide the widget

      To completely hide the widget from the page, use this function.

      Paste following code snippet into webpage to hide the chat button
      
      <a href="javascript:void($_REVECHAT_API && $_REVECHAT_API['Button'] &&$_REVECHAT_API.Button.hide())">chat with us</a>

      How to use
      <script type='text/javascript'>
       window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account='12-12-12-12';w.__revechat_version=2;
         r._= []; var rc = d.createElement('script'); rc.type = 'text/javascript'; rc.async = true; rc.setAttribute('charset', 'utf-8');
         rc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'static.revechat.com/co-browsing/new-livechat.sjs?'+new Date().getTime();
         var s = d.getElementsByTagName('script')[0]; s.parentNode.insertBefore(rc, s);
       })(document, window);
      </script>
       
      
      <a href="javascript:void($_REVECHAT_API && $_REVECHAT_API['Button'] &&$_REVECHAT_API.Button.hide())">chat with us</a>

      4. Show the widget

      To display the widget on the page (if it was hidden), use this function.

      Paste following code snippet into webpage to show the chat button
      
      <a href="javascript:void($_REVECHAT_API && $_REVECHAT_API['Button'] &&$_REVECHAT_API.Button.show())">chat with us</a>

      How to use
      <script type='text/javascript'>
       window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account='12-12-12-12';w.__revechat_version=2;
         r._= []; var rc = d.createElement('script'); rc.type = 'text/javascript'; rc.async = true; rc.setAttribute('charset', 'utf-8');
         rc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'static.revechat.com/co-browsing/new-livechat.sjs?'+new Date().getTime();
         var s = d.getElementsByTagName('script')[0]; s.parentNode.insertBefore(rc, s);
       })(document, window);
      </script>
       
      <a href="javascript:void($_REVECHAT_API && $_REVECHAT_API['Button'] &&$_REVECHAT_API.Button.show())">chat with us</a>

      5. Initiate Audio Call

      To initiate an audio call to the visitor directly from your website (e.g., on a button click), use this function. The business can proactively start the call.

      Paste following code snippet into webpage to initiate audio call
      
      <a href='#' id='revechatCtCButton' onclick="$_REVECHAT_API['Button'] && $_REVECHAT_API.Button.startVoiceCall()"> <img style='height: 130px; width: 130px;' src='https://static.revechat.com/client/images/click-to-call-audio.png' data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo" />

      6. Initiate Video Call

      To initiate a video call to the visitor directly from your website (e.g., on a button click), use this function. The business can proactively start the call.

      Paste following code snippet into webpage to initiate video call
      
      
      <a href='#' id='revechatCtCButton' onclick="$_REVECHAT_API['Button'] && $_REVECHAT_API.Button.startVideoCall()"> <img style='height: 130px; width: 130px;' src='https://static.revechat.com/client/images/click-to-call-video.png' data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo" />

      7. Set language

      To match the chat widget’s language with your website’s language, use this function to set the widget language dynamically.

      <script type="text/javascript">
      	$_REVECHAT_API(function() 
      	{
      		// set Arabic language
       		$_REVECHAT_API.setLanguage('ar');
      	});
      </script>
      
       OR 
      
      Example 
      Pick a language: English Portuguese Dutch Simplified Chinese
       
      Pick a language:
      <a href="javascript:void($_REVECHAT_API.setLanguage&&$_REVECHAT_API.setLanguage('en'))">English</a>
      
      <a href="javascript:void($_REVECHAT_API.setLanguage&&$_REVECHAT_API.setLanguage('pt'))">Portuguese</a>
      
      <a href="javascript:void($_REVECHAT_API.setLanguage&&$_REVECHAT_API.setLanguage('nl'))">Dutch</a>

      How to use
      <script type='text/javascript'>
       window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account='12-12-12-12';w.__revechat_version=2;
         r._= []; var rc = d.createElement('script'); rc.type = 'text/javascript'; rc.async = true; rc.setAttribute('charset', 'utf-8');
         rc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'static.revechat.com/co-browsing/new-livechat.sjs?'+new Date().getTime();
         var s = d.getElementsByTagName('script')[0]; s.parentNode.insertBefore(rc, s);
       })(document, window);
      </script>
       
      <a href="javascript:void($_REVECHAT_API.setLanguage&&$_REVECHAT_API.setLanguage('ar'))">Arabic</a>

      8. Set Department

      To route chats to a specific department (e.g., based on the page or context), use this function to set the desired department for the chat session.

      <script type='text/javascript'> 
      window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = "function(c) {r._.push(c);}; 
      NaNrc.type = 'text/javascript'; rc.async = true; rc.setAttribute('charset', 'utf-8'); 
      rc.src = ('https:' == document.location.protocol ?'https://' : 'http://') 
      + 'static.revechat.com/co-browsing/new-livechat.sjs?'+new Date().getTime();
      var s = d.getElementsByTagName('script')[0]; s.parentNode.insertBefore(rc, s);})(document, window);
      
      $_REVECHAT_API$_REVECHAT_API(function()
      { 
         $_REVECHAT_API.setOrganization('DEPARTMENT_NAME');
      });
      </script>

      9. Close ongoing chat

      To end the ongoing chat session of the visitor, use this function to close the active chat.

      Paste following code snippet into webpage to show the chat button
      
      <a href="javascript:void($_REVECHAT_API && $_REVECHAT_API.Form.Online.closeChat()">close chat</a>

      How to use
      <script type='text/javascript'>
       window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account='12-12-12-12';w.__revechat_version=2;
         r._= []; var rc = d.createElement('script'); rc.type = 'text/javascript'; rc.async = true; rc.setAttribute('charset', 'utf-8');
         rc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'static.revechat.com/co-browsing/new-livechat.sjs?'+new Date().getTime();
         var s = d.getElementsByTagName('script')[0]; s.parentNode.insertBefore(rc, s);
       })(document, window);
      </script>
       
      <a href="javascript:void($_REVECHAT_API && $_REVECHAT_API.Form.Online.closeChat()">close chat</a>

      Note: Use the widget code from your own REVE Chat account. To get it, log in to your REVE Chat account, go to Settings > Chat Widget, select your widget, then navigate to the Code Snippet tab. Copy your widget code and replace the example code shown above with your own.

      Any questions? Please email us at [email protected]

      AUTHOR’S BIO

      Mohaimin Talha is a seasoned Product Manager, known for his ability to combine creativity with analytical thinking. His strategic vision and customer-centric approach make him a key driver of product success and business growth.

      0:00 / 0:00