MyChat add-ons: developing, technical questions, testing, documentation and other useful information
User avatar
Alona Kutsenko
Description of the website chat parameters

Code: Select all
text  — button text for opening the chat;
position  — placement of the button (from 1 (on the right, above) and to 12, clockwise);
_type — users selection type, true — for groups, and false — for particular operators;
uin — UIN of who to open the chat with or the list of UINs (can be specified as [1,2,3] or "1,2,3", one random will be chosen for the chat;
group — ID of operators group;
height — chat window height (when opening in a separate window);
width — chat window width (when opening in a separate window);
btnID — the list of ID buttons or other HTML elements, the detailed description below;
select — show or not the selection of operators before the chat starts: true/false (yes/no);
inFrame — display the chat, not in a separate window, but in the middle of the page (in a frame): true/false (yes/no);
hideMain — hide the chat button if only the user's button is used for opening the chat: true/false (by default - false, the button is displayed);
custom — random text string that is sent to an operator without any changes in the field Reflink;
url — a chat's server address (protocol HTTPS or HTTP should not be in the address );
fields — fields that must be filled by a user when entering the chat for the first time, the text string: "email,name" or "name", or "email", or "" — nothing.

The parameter "btnID" can contain the list of ID HTML elements. When clicking on it, the chat opens with a particular operator. Also, in the attributes of this element, specify the UIN of who to open the chat with (uin="3") or the support group's ID (group="1"). For example:

Code: Select all
<div id="mcGifer" uin="3" style="cursor:pointer;">
    <img src="img/Live_Chat.png" onmouseout="this.src='/img/Live_Chat.png';" onmouseover="this.src='/img/Live_Chat_2.png';">
</div>

This code is displaying the picture with the text "Open online chat":
open online chat.png
Open the online chat with an operator
open online chat.png (67.06 KiB) Viewed 7197 times

And the script example:
Code: Select all
<!--== MyChat Web Support ==-->
<script type="text/javascript">
    window.__setMyChatOption = function (opt) {
        try {
            window.mc_uho_opt = Object.prototype.toString.call( opt ) === '[object Object]' ? opt : JSON.parse(opt);

            window.mc_uho_opt.btnID = ["mcGifer", "mcHobit", "mcGlubber", "mcHelen"];

            var run   = document.createElement("script");
            run.type  = "text/javascript";
            run.async = true;
            run.src   = "https://mychat-server.com/chat/uho/supportUho.js";
            var s     = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(run, s);
        } catch (e) {
            console.warn(e.message);
        }
    }
</script>
<script src="https://mychat-server.com/getSupportOptions.js" async type="text/javascript"></script>

In the line window.mc_uho_opt.btnID = ["mcGifer", "mcHobit", "mcGlubber", "mcHelen"]; specified all the button IDs to open the chat.

Similar to that, the parameter window.mc_uho_opt can be specified in any other fields listed above. The example:

Code: Select all
window.mc_uho_opt.position = 2; // the chat's button on the center-right
window.mc_uho_opt._type  = true; // users of a group 1
window.mc_uho_opt.group = 1; // group number 1
window.mc_uho_opt.select = true; // display selection for operators when connecting for the first time
window.mc_uho_opt.inFrame = true; // display the chat in the middle, in a frame
window.mc_uho_opt.fields = "name,email"; // require a name and email address from the visitor
window.mc_uho_opt.url = "192.168.10.10:8080"; // is relevant when a WEB server of the chat works on one port, but you open it via port mapping on another one. Notice, the address is without "http(s)://"

Specified fields in the script have priority over settings on the Admin Control Panel on the server.

Thus, you can specify window.mc_uho_opt.group on different websites or pages to use a particular user group.

A few words about the parameter custom. You can use it for additional user identification. For example, when you have a couple of websites and somehow Reflink does not display for visitors. This field is added in the login, in the field Reflink that is processed by a server script "OnPrivateRequest" — "WebGuestInfo".