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
[NEW][ENTERPRISE] Auto close abandoned Omnichannel rooms #17055
Conversation
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.
@MarcosSpessatto I suggest renaming all of the terms inactive
by abandoned
.
Thanks.
ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.js
Outdated
Show resolved
Hide resolved
ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.js
Outdated
Show resolved
Hide resolved
ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.js
Outdated
Show resolved
Hide resolved
@MarcosSpessatto We need to add a new setting to set a custom close message when the room is closed by visitor inactivity. The closeRoom method accepts a comment parameter, so, if there is a custom message defined, we need to pass it as the comment parameter. |
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.
@MarcosSpessatto we almost done, but I left some comments to improve specific parts of the code.
Also, we need to update the predicted Visitor Abandonment
value when a room is forward from a department to another, did you get it?
We can have a different department.visitorInactivityTimeoutInSeconds
value between the old and the new department, so we need to check it and if the values are not equal, we need to update the room.
We already have a callback
for this purpose, please take a look at here:
https://github.com/RocketChat/Rocket.Chat/blob/develop/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.js#L5-L24
Thanks.
@@ -23,4 +23,51 @@ overwriteClassOnLicense('livechat-enterprise', LivechatRooms, { | |||
}, | |||
}); | |||
|
|||
|
|||
LivechatRooms.prototype.setTimeWhenRoomWillBeAbandoned = function(roomId, willBeAbandonedAt) { |
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.
LivechatRooms.prototype.setTimeWhenRoomWillBeAbandoned = function(roomId, willBeAbandonedAt) { | |
LivechatRooms.prototype.setPredictedVisitorAbandonment = function(roomId, willBeAbandonedAt) { |
@@ -58,5 +58,5 @@ callbacks.add('livechat.closeRoom', (room) => { | |||
return; | |||
} | |||
const secondsSinceLastAgentResponse = getSecondsSinceLastAgentResponse(room, agentLastMessage); | |||
LivechatRooms.setVisitorInactivityInSecondsByRoomId(room._id, secondsSinceLastAgentResponse); | |||
LivechatRooms.setVisitorInactivityInSecondsById(room._id, secondsSinceLastAgentResponse); |
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 method needs to be renamed on the Model as well.
The old name is still there.
<div class="input-line"> | ||
<label>{{_ "Livechat_abandoned_rooms_closed_custom_message"}}</label> | ||
<div> | ||
<input type="text" class="rc-input__element customFormField" name="abandonedRoomsCloseCustomMessage" value="{{department.abandonedRoomsCloseCustomMessage}}" placeholder="{{_ "Livechat_abandoned_rooms_closed_custom_message"}}" /> |
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.
<input type="text" class="rc-input__element customFormField" name="abandonedRoomsCloseCustomMessage" value="{{department.abandonedRoomsCloseCustomMessage}}" placeholder="{{_ "Livechat_abandoned_rooms_closed_custom_message"}}" /> | |
<input type="text" class="rc-input__element customFormField" name="abandonedRoomsCloseCustomMessage" value="{{department.abandonedRoomsCloseCustomMessage}}" placeholder="{{_ "Enter_a_custom_message"}}" /> |
}; | ||
|
||
export const updatePredictedVisitorAbandonment = (closeRooms) => { | ||
if (closeRooms) { |
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 think we should check this setting here: settings.get('Livechat_auto_close_abandoned_rooms')
We can avoid an unnecessary loop here.
} | ||
|
||
closeRooms(room) { | ||
let comment = settings.get('Livechat_abandoned_rooms_closed_custom_message') || TAPi18n.__('Closed_automatically'); |
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.
How about creating a custom message cache
(array), at the beginning of the closeRooms
method and store the department custom messages there?
This would avoid unnecessary searches in the DB.
const department = LivechatDepartment.findOneById(room.departmentId); | ||
comment = department.abandonedRoomsCloseCustomMessage || comment; | ||
} | ||
Livechat.closeRoom({ |
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.
The user who is closing the chats is required here. So, my suggestion is to use rocket.cat
to as a user to perform this action.
Then you don't need to set system
here:
https://github.com/RocketChat/Rocket.Chat/pull/17055/files#diff-3e725e94e4a647e422a10d903b96cf59R349
This pull request introduces 1 alert when merging 3077a4b into 58b14d1 - view on LGTM.com new alerts:
|
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.
When an agent sends a message, we set the room as responded, as you can see here:
https://github.com/RocketChat/Rocket.Chat/blob/develop/app/livechat/server/hooks/markRoomResponded.js#L20-L29
But when the visitor sends a message, and the status of the room is not waiting for response, we need to set it, otherwise the rooms will be closed by inactivity due to this test(which is correct):
https://github.com/RocketChat/Rocket.Chat/pull/17055/files#diff-a5636aa5e27e8717c18539b084e2348aR43
This pull request introduces 1 alert when merging 1d2c721 into c180a53 - view on LGTM.com new alerts:
|
…users_and_rooms * 'develop' of github.com:RocketChat/Rocket.Chat: [FIX] Omnichannel SMS / WhatsApp integration errors due to missing location data (#17288) [FIX] User search on directory not working correctly (#17299) [FIX] Can not save Unread Tray Icon Alert user preference (#16288) (#16313) [FIX] Variable rendering problem on Import recent history page (#15997) [FIX] Admin panel custom sounds, multiple sound playback fix and added single play/pause button (#16215) [FIX] Discussions created from inside DMs were not working (#17282) [FIX] translation for nl (#16742) [FIX] No maxlength defined for custom user status (#16534) [FIX] Directory users email sort button (#16606) [FIX] In Create a New Channel, input should be focused on channel name instead of invite users (#16405) [FIX] Email not verified message (#16236) [FIX] Directory default tab (#17283) Update ru.i18n.json (#16869) [FIX] Avatar on sidebar when showing real names (#17286) Update Apps-Engine to stable version (#17287) [NEW][ENTERPRISE] Auto close abandoned Omnichannel rooms (#17055) Static props for Administration route components (#17285) [NEW] Default favorite channels (#16025) Apply $and helper to message template (#17280)
This new feature allows
administrators
to automatically close Omnichannel rooms when a chat is considered abandoned by the visitor. We already have a setting to define how long to wait before considering an abandoned chat, so now we can also close chats that have been abandoned.