amazon-connect/amazon-connect-chat-interface

Participant Idle message is not displaying in chat

Closed this issue · 5 comments

Do we have functionality to show Participant Idle message on chat window if Chat user getting Idle?

I need Implement custom text message for participants idle condition.

Hi @vkumar-exl,

Team is not planning to add this functionality to code base, but this is possible to implement.

By modifying ChatSession.js, you can utilize the session.onParticipantIdle() which is provided by ChatJS API.

The chatSession state is then stored in ChatContainer.js, which can be passed down as a prop into component.

Keep in mind this code base does not use React Context, so it might not follow common pattern.

Please reach out if you have further questions. Will auto-resolve in 7 days if there are no further concerns.

Thanks,
Spencer

Hello @spencerlepine

I can see below log in console but could not capture it in code. Chat end event is working and captured within the code but participant idle event is not working in same way.

INFO [2023-09-06T13:23:28.729Z] ChatJS-LPCConnectionHelperBase: this.eventBus trigger Websocket incoming message IncomingMessage {"AbsoluteTime":"2023-09-06T13:23:28.561Z","ContentType":"application/vnd.amazonaws.connect.event.participant.idle","Id":"XXXXX-fa8c-4247-9e14-a7c7b7c3aa8e","Type":"EVENT","ParticipantId":"XXXXX-8e00-4fb9-b638-f3acda4c4476","DisplayName":"vivek-XXXX","ParticipantRole":"CUSTOMER","InitialContactId":"XXXXX-1c09-4692-9ae4-a8c4933ab8fa"}

Will need time to investigate and reproduce this.

In meantime, maybe the session.onMessage() listener will work instead, this might be capturing all websocket events.

WIll double check ChatJS version that is used here too, the commit was added in this PR not sure when it was published to npm

@spencerlepine

onMessage() is triggering for other events but not for participantIdle.

We are using this https://github.com/amazon-connect/amazon-connect-chat-interface interface code.

@spencerlepine

I have resolved this issue by implementing below methods and add method in event handler.

onParticipantIdle(handler) {
return this.session.onParticipantIdle(handler);
}
onAutoDisconnection(handler) {
return this.session.onAutoDisconnection(handler);
}

_addEventListeners() {
this.client.onParticipantIdle(data => {
this._handleIncomingData(data);
});
this.client.onAutoDisconnection(data => {
this._handleIncomingData(data);
});
}