Skip to content

Conversation

@AlexanderKanakis
Copy link
Collaborator

[EventName.ESCALATION_FAILED_DUE_TO_DISCONNECTED_AGENT]: {
category: EventCatagory.ESCALATION,
eventType: EventType.SESSION,
action: 'failed',
Copy link

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.

@ear-dev
Copy link

ear-dev commented Oct 11, 2022

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?

@ear-dev ear-dev requested a review from Shailesh351 October 11, 2022 14:52
} else if (isChatAccepted === false) {
const isChatRequestFail = checkForEvent(messageArray, 'ChatRequestFail');
const isChatEnded = checkForEvent(messageArray, 'ChatEnded');
const isAgentDisconnected = checkForEvent(messageArray, 'AgentDisconnect');
Copy link

@ear-dev ear-dev Oct 11, 2022

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?

Copy link
Collaborator Author

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) {
Copy link

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const isAgentDisconnected = checkForEvent(messageArray, 'AgentDisconnect');

@ear-dev
Copy link

ear-dev commented Oct 11, 2022

Lets use a new category for this please:

"Agent Disconnect": [
{"triggered": []} <- SF.app?
],

@AlexanderKanakis
Copy link
Collaborator Author

AlexanderKanakis commented Oct 11, 2022

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?

In most cases we will be seeing AgentDisconnect from subscribeToLiveAgent() which tracks messages mid conversation.

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 checkCurrentChatStatus().

image

},
},
[EventName.AGENT_TRANSFER_FAILED_DUE_TO_DISCONNECTED_AGENT]: {
category: EventCatagory.AGENT_TRANSFER,
Copy link

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?

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',
Copy link

@ear-dev ear-dev Oct 11, 2022

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?

Copy link
Collaborator Author

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?

Copy link

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?

Copy link
Collaborator Author

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.

Comment on lines 50 to 58
},
[EventName.AGENT_TRANSFER_FAILED_DUE_TO_DISCONNECTED_AGENT]: {
category: EventCatagory.AGENT_DISCONNECTED,
eventType: EventType.SESSION,
action: 'triggered',
properties: {
failure_reason: 'livechat agent disconnnected',
},
},
Copy link
Collaborator

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

Copy link

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?

Comment on lines 155 to 158
await checkAgentStatusDirectCallback.checkAgentStatusCallbackError(
CloseMessages.CHAT_CLOSED_DUE_TO_DISCONNECTED_AGENT,
EventName.AGENT_TRANSFER_FAILED_DUE_TO_DISCONNECTED_AGENT,
);
Copy link
Collaborator

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
@ear-dev
Copy link

ear-dev commented Oct 14, 2022

@AlexanderKanakis can you resolve the new conflicts please? Probably due to having merged your other PR. Thanks.

@ear-dev
Copy link

ear-dev commented Oct 18, 2022

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);
Copy link

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
]}]

Copy link
Collaborator Author

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);
Copy link

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?

Copy link
Collaborator Author

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:

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()?

Copy link

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@ear-dev
Copy link

ear-dev commented Oct 20, 2022

@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.

@AlexanderKanakis
Copy link
Collaborator Author

The conditional block checking for AgentDisconnect prevented the app from updating correctly. Moved the check to a more appropriate function where it does not interrupt the subscribeToLiveAgent functionality.

@ear-dev
Copy link

ear-dev commented Oct 31, 2022

@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.

@bhardwajaditya
Copy link

@ear-dev fixed the conflicts for this one

Copy link

@ear-dev ear-dev left a 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.

@ear-dev ear-dev merged commit 56a7316 into master Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SNS Logging] New SF event for message type=AgentDisconnect

5 participants