-
Notifications
You must be signed in to change notification settings - Fork 1
[NEW] Catch AgentDisconnect and Send AgentDisconnect Event #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| [EventName.ESCALATION_FAILED_DUE_TO_DISCONNECTED_AGENT]: { | ||
| category: EventCatagory.ESCALATION, | ||
| eventType: EventType.SESSION, | ||
| action: 'failed', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should be a unique action, since it's not really a failed escalation. It's more like "interrupted" maybe. In order to do that however we'll need the Pixel team to sign off on a new action. I can work on that.
|
I'd like to make sure that this is handling mid conversation interruptions with a live agent during a successful escalated session. Can you point out please, for my own edification, which lines in the PR are checking for the message type: "AgentDisconnect" from the SF response body? |
| } else if (isChatAccepted === false) { | ||
| const isChatRequestFail = checkForEvent(messageArray, 'ChatRequestFail'); | ||
| const isChatEnded = checkForEvent(messageArray, 'ChatEnded'); | ||
| const isAgentDisconnected = checkForEvent(messageArray, 'AgentDisconnect'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this condition exactly..... "isChatAccepted"? Is this during an initial escalation? And if so, is there actually such a thing as AgentDisconnected before a session is actually instantiated with a real live agent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
| await checkAgentStatusDirectCallback.checkAgentStatusCallbackError(this.technicalDifficultyMessage); | ||
| return; | ||
| } else if (isAgentDisconnected === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case can you show me where isAgentDisconnected was set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 123 in d1615f7
| const isAgentDisconnected = checkForEvent(messageArray, 'AgentDisconnect'); |
|
Lets use a new category for this please: "Agent Disconnect": [ |
In most cases we will be seeing The one exception is the case where the chat with the liveagent is established but there is a disconnection right before an automated liveagent 'auto greeting' is sent right after escalation, which is handled in |
enum/Analytics.ts
Outdated
| }, | ||
| }, | ||
| [EventName.AGENT_TRANSFER_FAILED_DUE_TO_DISCONNECTED_AGENT]: { | ||
| category: EventCatagory.AGENT_TRANSFER, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Category: Agent_Disconnected, not Agent_Transfer, right?
enum/Analytics.ts
Outdated
| AGENT_TRANSFER_SUCCESSFUL = 'agent_transfer_successful', | ||
| CHAT_CLOSED_BY_AGENT = 'chat_closed_by_agent', | ||
| CHAT_CLOSED_BY_TIMEOUT = 'chat_closed_by_timeout', | ||
| AGENT_TRANSFER_FAILED_DUE_TO_DISCONNECTED_AGENT = 'chat_closed_due_to_disconnected_agent', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an agent disconnected event, not an agent transfer event? And, what we see in the field is that after an agentDisconnect message type is recieved, it is generally the case that the conversation gets transferred to another agent, not that the chat is closed. However, in this PR we are not describing the 'transfer' that occurs yet, we just want to be capturing the disconnect when it happens.
So..... 'chat_closed_due_to_disconnected_agent' is not necessarily accurate here. Maybe something like "agent_disconnected_mid_chat" is more accurate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently have some chatclosed handlers after we catch a message with AgentDisconnect type. Do we want to remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently have some chatclosed handlers after we catch a message with AgentDisconnect type. Do we want to remove them?
Is that true? In production we see many AgentDisconnected events (looking at debug SF response logging) and those conversations are generally routed to another agent and continue. Are you saying that it looks to you like our SF.app should be closing sessions when it sees the AgentDisconnected flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ear-dev Clarifcation. I added them in this PR. Removed them later, as per @Shailesh351 instructions.
| }, | ||
| [EventName.AGENT_TRANSFER_FAILED_DUE_TO_DISCONNECTED_AGENT]: { | ||
| category: EventCatagory.AGENT_DISCONNECTED, | ||
| eventType: EventType.SESSION, | ||
| action: 'triggered', | ||
| properties: { | ||
| failure_reason: 'livechat agent disconnnected', | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AGENT_TRANSFER_FAILED_DUE_TO_DISCONNECTED_AGENT It's not actually Agent Transfer FAILURE, right? As @ear-dev mentioned we are receiving this message when the salesforce agent transfers chat to another salesforce agent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderKanakis to clarify..... in the case of this AgentDisconnected event, we don't know and are not reporting anything about the state of the chat, the ONLY thing this event is meant to convey is that we received an 'AgentDisconnected' message type from salesforce.
If the chat was also closed, I am hoping that we'll catch that event somewhere else. If the chat was transferred to another agent, I'm hoping we'll catch that event somewhere else..... etc.... thanks.
However..... is it possible to use a property or action in this event? If we have the information it might be a good way to go..... i.e. 'action == chatTransferred or chatEnded'? @Shailesh351 do we have that information at the time we are trying to throw this event?
| await checkAgentStatusDirectCallback.checkAgentStatusCallbackError( | ||
| CloseMessages.CHAT_CLOSED_DUE_TO_DISCONNECTED_AGENT, | ||
| EventName.AGENT_TRANSFER_FAILED_DUE_TO_DISCONNECTED_AGENT, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will close the chat, right? As @ear-dev mentioned we are receiving this message when the salesforce agent transfers chat to another salesforce agent. So it will just close the chat in between.
- Removed AgentDisconnected from Error Logs, as it is not an error - Removed unnecessary close chat functionality when agent is disconnected
|
@AlexanderKanakis can you resolve the new conflicts please? Probably due to having merged your other PR. Thanks. |
|
I will test this today.... @Shailesh351 when you have time please take a final look. |
| console.log(InfoLogs.LIVEAGENT_SESSION_CLOSED); | ||
| await this.modify.getUpdater().getLivechatUpdater().closeRoom(room, 'Chat closed by visitor.'); | ||
| if (closeMessage) { | ||
| await this.modify.getUpdater().getLivechatUpdater().closeRoom(room, closeMessage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is where we are closing a room, we should also at some point be sending an event for:
"Chat Session": [
{"closed": [
{"close_method": "liveagent_disconnected"} <- SF.app
]}]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused, I thought that we are not closing the room in the case a liveagent is disconnected.
| if (eventName) { | ||
| this.modify.getAnalytics().sendEvent(getEventData(this.data.room.id, eventName)); | ||
| } | ||
| await handleEndChatCallback.handleEndChat(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderKanakis In this PR it still looks like we are closing the chat when we receive the AgentDisconnected flag. We should not be doing that because Salesforce itself will instead route the visitor to a new agent if one is available. Can you fix please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ear-dev I did catch a missed case where the room is closed when the agent is disconnected, but it was from here:
Line 78 in ad13d93
| await handleEndChatCallback.handleEndChat(CloseMessages.CHAT_CLOSED_DUE_TO_DISCONNECTED_AGENT); |
Are you sure that there are cases we close the chat on AgentDisconnect through checkAgentStatusCallbackError()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderKanakis it looks like you found the spot where we were closing the chat? So this is resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
|
@AlexanderKanakis I just tested your latest, and I'm seeing another issue. It is not closing the chat on the widget side any more, so that is good, but the session itself is still getting disconnected when we receive the AgentDisconnected flag. However, the session still gets transferred to a new liveagent in Salesforce, which is the correct behavior. So still, we messed something up here. Have you tested this with two agents logged in? Can you fix please? If you run the test with the current master branch, and two logged in agents, you will see the correct behavior. Thanks. |
|
The conditional block checking for |
|
@Shailesh351 it looks like we need to fix the conflicts please. Did you have a chance to review again? Oh shoot...... I had asked @bhardwajaditya to look at this.... @bhardwajaditya do you have time for this? thanks. |
…LiveAgent into catch_agent_disconnect
|
@ear-dev fixed the conflicts for this one |
ear-dev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and it looks good.

Solves: WideChat/Rocket.Chat#1316