You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a need for allowing agents to access their chat transcripts immediately after finishing a chat session. Given that streaming CTRs is not a suitable solution for our use case due to its asynchronous nature, I have developed a solution around this by using a combination of chatSession.getTranscript() and chatSession.onMessage(). A simplification of the solution looks like this:
connect.contact(contact=>{if(contact.getType()===connect.ContactType.CHAT){contact.onAccepted(async()=>{constsession=awaitcontact.getConnections().find((c)=>c.getType()===connect.ConnectionType.AGENT).getMediaController();consttranscript=newTranscriptCustomClass();// uses session.getTranscript()transcript.populatePreviousMessages(session);// dedupes message if present in session.getTranscript(), sorts messagessession.onMessage(event=>transcript.appendMessage(event));// waits for transcript.populatePreviousMessages() to completesession.onEnded(event=>transcript.complete(event));});}});
So far, I've used the chatSession.onEnded() event to detect when the chat transcript can be considered "complete" and be made available for consumption. However, I've realized that this method is not called when the agent uses /connect/ccp-v2's "quick connect" feature to perform a transfer.
For the purposes explaining the problem, I'm going to refer to the transferred contact (i.e. initial contact) chat session as initialSession and the current contact (i.e. transferred contact) as currentSession.
Currently, the following behaviors occur:
When the contact is transferred and accepted by another agent, initialSession.onEnded() event is never triggered (I wonder whether this translates to a memory leak).
When the contact is transferred and accepted by the initial agent (e.g. the queue has only one available agent), a new contact is created (as expected), however:
When events/messages are sent to the current contact, both initialSession.onMessage() and currentSession.onMessage() trigger. I believe only currentSession.onMessage() should trigger.
When the current contact session finishes, both initialSession.onEnded() and currentSession.onEnded() trigger. I believe initialSession.onEnded() should trigger when the transfer completes, and only currentSession.onEnded() should trigger.
I've worked around this problem by examining the received messages and stop capturing in initialSession when I receive the following sequence of events I've noticed always occur before a transfer:
Note: I've also noticed these events/messages can sometimes come out-of-order to .onMessage(), so I have to sort them first by their AbsoluteTime before performing the detection.
Questions:
Is this by design?
If so, is the workaround guaranteed to always be true (i.e. the sequence of events before a transfer will not change)?
The text was updated successfully, but these errors were encountered:
marcogrcr
changed the title
chatSession.onEnded() does not trigger on contact transfers
agentChatSession.onEnded() does not trigger on contact transfers
Jun 10, 2020
Update: After examining the code, it looks like that happens because amazon-connect-chatjs triggers .onEnded() only when it encounters an application/vnd.amazonaws.connect.event.chat.ended event:
I have a need for allowing agents to access their chat transcripts immediately after finishing a chat session. Given that streaming CTRs is not a suitable solution for our use case due to its asynchronous nature, I have developed a solution around this by using a combination of
chatSession.getTranscript()
andchatSession.onMessage()
. A simplification of the solution looks like this:So far, I've used the
chatSession.onEnded()
event to detect when the chat transcript can be considered "complete" and be made available for consumption. However, I've realized that this method is not called when the agent uses/connect/ccp-v2
's "quick connect" feature to perform a transfer.For the purposes explaining the problem, I'm going to refer to the transferred contact (i.e. initial contact) chat session as
initialSession
and the current contact (i.e. transferred contact) ascurrentSession
.Currently, the following behaviors occur:
initialSession.onEnded()
event is never triggered (I wonder whether this translates to a memory leak).initialSession.onMessage()
andcurrentSession.onMessage()
trigger. I believe onlycurrentSession.onMessage()
should trigger.initialSession.onEnded()
andcurrentSession.onEnded()
trigger. I believeinitialSession.onEnded()
should trigger when the transfer completes, and onlycurrentSession.onEnded()
should trigger.I've worked around this problem by examining the received messages and stop capturing in
initialSession
when I receive the following sequence of events I've noticed always occur before a transfer:Note: I've also noticed these events/messages can sometimes come out-of-order to
.onMessage()
, so I have to sort them first by theirAbsoluteTime
before performing the detection.Questions:
The text was updated successfully, but these errors were encountered: