RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.07k stars 10.34k forks source link

Register a visitor and try to get/create a room and produce two rooms #17822

Closed gustavopuga closed 4 years ago

gustavopuga commented 4 years ago

Hi Rocket.Chat team.

I am using the Livechat API and REST API together to establish Omnichannel chats, but this combination produce two chest to the same guest/visitor:

image

The code that I use to register visitor (Livechat API):

                    RocketChat(function () {
            this.registerGuest({
                token: guestToken,
                name: nome,
                email: email,
                department: departamento
            });
            this.setCustomField('cpf', cpf);
            this.setCustomField('numeroDol', numeroDol);
        });

The call to the REST API using JQUERY to store room id:

                    $.ajax({
                    type: 'GET',
                    url: "http://10.92.0.26:3000/api/v1/livechat/room",
                    data: { "token": guestToken },
                    success: function (data) {
                        RocketChat(function () {
                            this.showWidget();
                            this.maximizeWidget();
                        });

                        document.getElementById("site").style.display = "block";
                        document.getElementById("iframe").src = "https://www.defensoria.sp.def.br/dpesp/Default.aspx?idPagina=1";
                        document.getElementById("login").style.display = "none";
                        setCookie("fm_rid", data.room._id, 1);
                    },
                    error: function (data) {
                        $("#alert").show();
                    },
                });
github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.