{"id":271659,"date":"2025-07-23T05:04:35","date_gmt":"2025-07-23T05:04:35","guid":{"rendered":"https:\/\/www.revechat.com\/?post_type=help-center&#038;p=271659"},"modified":"2025-07-23T07:01:32","modified_gmt":"2025-07-23T07:01:32","slug":"chat-widget-controller-api","status":"publish","type":"help-center","link":"https:\/\/www.revechat.com\/help-center\/chat-widget-controller-api\/","title":{"rendered":"Chat Widget Controller"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">$_REVECHAT_API(function(){ \u2026 });<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">1. Maximize the widget<\/h2>\n\n\n\n<p>To automatically maximize the widget \u2014 either when a user visits your website or when they click a button \u2014 use this function.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">\nPaste following code snippet into webpage to maximize the chat widget\n\u200b\n&lt;a href=&quot;javascript:void($_REVECHAT_API &amp;&amp; $_REVECHAT_API[&#039;Button&#039;] &amp;&amp;$_REVECHAT_API.Button.maximize())&quot;&gt;chat with us&lt;\/a&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>How to use<\/summary>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">&lt;script type=&#039;text\/javascript&#039;&gt;\n window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account=&#039;12-12-12-12&#039;;w.__revechat_version=2;\n   r._= []; var rc = d.createElement(&#039;script&#039;); rc.type = &#039;text\/javascript&#039;; rc.async = true; rc.setAttribute(&#039;charset&#039;, &#039;utf-8&#039;);\n   rc.src = (&#039;https:&#039; == document.location.protocol ? &#039;https:\/\/&#039; : &#039;http:\/\/&#039;) + &#039;static.revechat.com\/co-browsing\/new-livechat.sjs?&#039;+new Date().getTime();\n   var s = d.getElementsByTagName(&#039;script&#039;)[0]; s.parentNode.insertBefore(rc, s);\n })(document, window);\n&lt;\/script&gt;\n\n&lt;a href=&quot;javascript:void($_REVECHAT_API &amp;&amp; $_REVECHAT_API[&#039;Button&#039;] &amp;&amp;$_REVECHAT_API.Button.maximize())&quot;&gt;chat with us&lt;\/a&gt;<\/code><\/pre>\n<\/details>\n\n\n\n<h2 class=\"wp-block-heading\">2. Minimize the widget<\/h2>\n\n\n\n<p>To minimize the widget, use this function when you want to collapse it back after being opened.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">Paste following code snippet into webpage to minimize the chat widget\n\n&lt;a href=&quot;javascript:void($_REVECHAT_API &amp;&amp; $_REVECHAT_API[&#039;Button&#039;] &amp;&amp;$_REVECHAT_API.Button.minimize())&quot;&gt;chat with us&lt;\/a&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>How to use<\/summary>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">&lt;script type=&#039;text\/javascript&#039;&gt;\n window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account=&#039;12-12-12-12&#039;;w.__revechat_version=2;\n   r._= []; var rc = d.createElement(&#039;script&#039;); rc.type = &#039;text\/javascript&#039;; rc.async = true; rc.setAttribute(&#039;charset&#039;, &#039;utf-8&#039;);\n   rc.src = (&#039;https:&#039; == document.location.protocol ? &#039;https:\/\/&#039; : &#039;http:\/\/&#039;) + &#039;static.revechat.com\/co-browsing\/new-livechat.sjs?&#039;+new Date().getTime();\n   var s = d.getElementsByTagName(&#039;script&#039;)[0]; s.parentNode.insertBefore(rc, s);\n })(document, window);\n&lt;\/script&gt;\n \n\n\n&lt;a href=&quot;javascript:void($_REVECHAT_API &amp;&amp; $_REVECHAT_API[&#039;Button&#039;] &amp;&amp;$_REVECHAT_API.Button.minimize())&quot;&gt;chat with us&lt;\/a&gt;<\/code><\/pre>\n<\/details>\n\n\n\n<h2 class=\"wp-block-heading\">3. Hide the widget<\/h2>\n\n\n\n<p>To completely hide the widget from the page, use this function.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">Paste following code snippet into webpage to hide the chat button\n\n&lt;a href=&quot;javascript:void($_REVECHAT_API &amp;&amp; $_REVECHAT_API[&#039;Button&#039;] &amp;&amp;$_REVECHAT_API.Button.hide())&quot;&gt;chat with us&lt;\/a&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>How to use<\/summary>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">&lt;script type=&#039;text\/javascript&#039;&gt;\n window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account=&#039;12-12-12-12&#039;;w.__revechat_version=2;\n   r._= []; var rc = d.createElement(&#039;script&#039;); rc.type = &#039;text\/javascript&#039;; rc.async = true; rc.setAttribute(&#039;charset&#039;, &#039;utf-8&#039;);\n   rc.src = (&#039;https:&#039; == document.location.protocol ? &#039;https:\/\/&#039; : &#039;http:\/\/&#039;) + &#039;static.revechat.com\/co-browsing\/new-livechat.sjs?&#039;+new Date().getTime();\n   var s = d.getElementsByTagName(&#039;script&#039;)[0]; s.parentNode.insertBefore(rc, s);\n })(document, window);\n&lt;\/script&gt;\n \n\n&lt;a href=&quot;javascript:void($_REVECHAT_API &amp;&amp; $_REVECHAT_API[&#039;Button&#039;] &amp;&amp;$_REVECHAT_API.Button.hide())&quot;&gt;chat with us&lt;\/a&gt;<\/code><\/pre>\n<\/details>\n\n\n\n<h2 class=\"wp-block-heading\">4. Show the widget<\/h2>\n\n\n\n<p>To display the widget on the page (if it was hidden), use this function.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">Paste following code snippet into webpage to show the chat button\n\n&lt;a href=&quot;javascript:void($_REVECHAT_API &amp;&amp; $_REVECHAT_API[&#039;Button&#039;] &amp;&amp;$_REVECHAT_API.Button.show())&quot;&gt;chat with us&lt;\/a&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>How to use<\/summary>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">&lt;script type=&#039;text\/javascript&#039;&gt;\n window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account=&#039;12-12-12-12&#039;;w.__revechat_version=2;\n   r._= []; var rc = d.createElement(&#039;script&#039;); rc.type = &#039;text\/javascript&#039;; rc.async = true; rc.setAttribute(&#039;charset&#039;, &#039;utf-8&#039;);\n   rc.src = (&#039;https:&#039; == document.location.protocol ? &#039;https:\/\/&#039; : &#039;http:\/\/&#039;) + &#039;static.revechat.com\/co-browsing\/new-livechat.sjs?&#039;+new Date().getTime();\n   var s = d.getElementsByTagName(&#039;script&#039;)[0]; s.parentNode.insertBefore(rc, s);\n })(document, window);\n&lt;\/script&gt;\n \n&lt;a href=&quot;javascript:void($_REVECHAT_API &amp;&amp; $_REVECHAT_API[&#039;Button&#039;] &amp;&amp;$_REVECHAT_API.Button.show())&quot;&gt;chat with us&lt;\/a&gt;<\/code><\/pre>\n<\/details>\n\n\n\n<h2 class=\"wp-block-heading\">5. Initiate Audio Call<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">Paste following code snippet into webpage to initiate audio call\n\n&lt;a href=&#039;#&#039; id=&#039;revechatCtCButton&#039; onclick=&quot;$_REVECHAT_API[&#039;Button&#039;] &amp;&amp; $_REVECHAT_API.Button.startVoiceCall()&quot;&gt; &lt;img style=&#039;height: 130px; width: 130px;&#039; src=&#039;https:\/\/static.revechat.com\/client\/images\/click-to-call-audio.png&#039; data-toggle=&quot;modal&quot; data-target=&quot;#exampleModal&quot; data-whatever=&quot;@mdo&quot; \/&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Initiate Video Call<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">Paste following code snippet into webpage to initiate video call\n\n\n&lt;a href=&#039;#&#039; id=&#039;revechatCtCButton&#039; onclick=&quot;$_REVECHAT_API[&#039;Button&#039;] &amp;&amp; $_REVECHAT_API.Button.startVideoCall()&quot;&gt; &lt;img style=&#039;height: 130px; width: 130px;&#039; src=&#039;https:\/\/static.revechat.com\/client\/images\/click-to-call-video.png&#039; data-toggle=&quot;modal&quot; data-target=&quot;#exampleModal&quot; data-whatever=&quot;@mdo&quot; \/&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7. Set language<\/h2>\n\n\n\n<p>To match the chat widget\u2019s language with your website\u2019s language, use this function to set the widget language dynamically.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">&lt;script type=&quot;text\/javascript&quot;&gt;\n\t$_REVECHAT_API(function() \n\t{\n\t\t\/\/ set Arabic language\n \t\t$_REVECHAT_API.setLanguage(&#039;ar&#039;);\n\t});\n&lt;\/script&gt;\n\n OR \n\nExample \nPick a language: English Portuguese Dutch Simplified Chinese\n \nPick a language:\n&lt;a href=&quot;javascript:void($_REVECHAT_API.setLanguage&amp;&amp;$_REVECHAT_API.setLanguage(&#039;en&#039;))&quot;&gt;English&lt;\/a&gt;\n\n&lt;a href=&quot;javascript:void($_REVECHAT_API.setLanguage&amp;&amp;$_REVECHAT_API.setLanguage(&#039;pt&#039;))&quot;&gt;Portuguese&lt;\/a&gt;\n\n&lt;a href=&quot;javascript:void($_REVECHAT_API.setLanguage&amp;&amp;$_REVECHAT_API.setLanguage(&#039;nl&#039;))&quot;&gt;Dutch&lt;\/a&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>How to use<\/summary>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">&lt;script type=&#039;text\/javascript&#039;&gt;\n window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account=&#039;12-12-12-12&#039;;w.__revechat_version=2;\n   r._= []; var rc = d.createElement(&#039;script&#039;); rc.type = &#039;text\/javascript&#039;; rc.async = true; rc.setAttribute(&#039;charset&#039;, &#039;utf-8&#039;);\n   rc.src = (&#039;https:&#039; == document.location.protocol ? &#039;https:\/\/&#039; : &#039;http:\/\/&#039;) + &#039;static.revechat.com\/co-browsing\/new-livechat.sjs?&#039;+new Date().getTime();\n   var s = d.getElementsByTagName(&#039;script&#039;)[0]; s.parentNode.insertBefore(rc, s);\n })(document, window);\n&lt;\/script&gt;\n \n&lt;a href=&quot;javascript:void($_REVECHAT_API.setLanguage&amp;&amp;$_REVECHAT_API.setLanguage(&#039;ar&#039;))&quot;&gt;Arabic&lt;\/a&gt;<\/code><\/pre>\n<\/details>\n\n\n\n<h2 class=\"wp-block-heading\">8. Set Department<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">&lt;script type=&#039;text\/javascript&#039;&gt; \nwindow.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = &quot;function(c) {r._.push(c);}; \nNaNrc.type = &#039;text\/javascript&#039;; rc.async = true; rc.setAttribute(&#039;charset&#039;, &#039;utf-8&#039;); \nrc.src = (&#039;https:&#039; == document.location.protocol ?&#039;https:\/\/&#039; : &#039;http:\/\/&#039;) \n+ &#039;static.revechat.com\/co-browsing\/new-livechat.sjs?&#039;+new Date().getTime();\nvar s = d.getElementsByTagName(&#039;script&#039;)[0]; s.parentNode.insertBefore(rc, s);})(document, window);\n\n$_REVECHAT_API$_REVECHAT_API(function()\n{ \n   $_REVECHAT_API.setOrganization(&#039;DEPARTMENT_NAME&#039;);\n});\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. Close ongoing chat<\/h2>\n\n\n\n<p>To end the ongoing chat session of the visitor, use this function to close the active chat.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">Paste following code snippet into webpage to show the chat button\n\n&lt;a href=&quot;javascript:void($_REVECHAT_API &amp;&amp; $_REVECHAT_API.Form.Online.closeChat()&quot;&gt;close chat&lt;\/a&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>How to use<\/summary>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">&lt;script type=&#039;text\/javascript&#039;&gt;\n window.$_REVECHAT_API || (function(d, w) { var r = $_REVECHAT_API = function(c) {r._.push(c);}; w.__revechat_account=&#039;12-12-12-12&#039;;w.__revechat_version=2;\n   r._= []; var rc = d.createElement(&#039;script&#039;); rc.type = &#039;text\/javascript&#039;; rc.async = true; rc.setAttribute(&#039;charset&#039;, &#039;utf-8&#039;);\n   rc.src = (&#039;https:&#039; == document.location.protocol ? &#039;https:\/\/&#039; : &#039;http:\/\/&#039;) + &#039;static.revechat.com\/co-browsing\/new-livechat.sjs?&#039;+new Date().getTime();\n   var s = d.getElementsByTagName(&#039;script&#039;)[0]; s.parentNode.insertBefore(rc, s);\n })(document, window);\n&lt;\/script&gt;\n \n&lt;a href=&quot;javascript:void($_REVECHAT_API &amp;&amp; $_REVECHAT_API.Form.Online.closeChat()&quot;&gt;close chat&lt;\/a&gt;<\/code><\/pre>\n<\/details>\n\n\n\n<p><em>Note: Use the widget code from your own REVE Chat account. To get it, log in to your REVE Chat account, go to Settings &gt; 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.<\/em><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Any questions? Please email us at <a href=\"mailto:support@revechat.com\">support@revechat.com<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. 1. Maximize the widget To automatically maximize the widget \u2014 either when a user visits your website or when they click a button \u2014 use this function. 2. Minimize [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":0,"menu_order":127,"template":"","meta":{"_acf_changed":false,"footnotes":""},"help_center_type":[1816],"class_list":["post-271659","help-center","type-help-center","status-publish","hentry","help_center_type-javascript-api"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/help-center\/271659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/help-center"}],"about":[{"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/types\/help-center"}],"author":[{"embeddable":true,"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/users\/43"}],"version-history":[{"count":5,"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/help-center\/271659\/revisions"}],"predecessor-version":[{"id":271668,"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/help-center\/271659\/revisions\/271668"}],"wp:attachment":[{"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/media?parent=271659"}],"wp:term":[{"taxonomy":"help_center_type","embeddable":true,"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/help_center_type?post=271659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}