Author Topic: Identifying Party Count in Chat Session  (Read 2854 times)

Offline genesys_kumar

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Identifying Party Count in Chat Session
« on: April 11, 2022, 03:33:40 PM »
Hi,

is there a way we can find participant count in Chat conference?  I need to capture participant count (including customer and agents) when any one left the chat conference session, In the cometD event "ParticipantLeft" - there is no property shows the party count.

Thanks,
Kumar


Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Identifying Party Count in Chat Session
« Reply #1 on: April 11, 2022, 05:14:55 PM »
I don't think that there is a direct way to do that - at least, none that I know.

As an alternative, I think that you could use the "/genesys/2/chat/{serviceName}/{chatId}/refresh" endpoint with transcriptPosition = 1 and count the number of ParticipantJoined messages minus the number of ParticipantLeft messages.

Offline genesys_kumar

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Identifying Party Count in Chat Session
« Reply #2 on: April 14, 2022, 12:37:51 PM »
Thanks for the reply, I have tried as given below

Called this function on page load and it worked as expected

async function getParticipants() {
            [b]const requestPath = "/api/v2/me/chats?fields=*";
            const response = await callGWSAPI("GET", requestPath);[/b]

            if (response.statusCode == 0) {
                for (let i = 0; i < response.chats.length; i++) {
                    for (let j = 0; j < response.chats[i].participants.length; j++) {
                        if (response.chats[i].participants[j].type == "Agent" || response.chats[i].participants[j].type == "Supervisor") {
                            participants.push(response.chats[i].participants[j].id);
                        }
                    }
                }

                if (participants.length == 1) {
                    chatTimeoutEnabled = true;
                }
            } else {
                console.log("getParticipants response.statusCode != 0: " + response.statusCode);
            }

            console.log("chatTimeoutEnabled: " + chatTimeoutEnabled);
        }

Thanks,
Kumar