-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Fix] Send Close Chat Message to Client #172
Changes from 5 commits
91b7711
d036be1
3bbad29
ce9cf71
b456094
6102356
3aebc17
cc75af4
4fc90cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,3 +148,14 @@ export enum Message { | |
CLOSED_BY_VISITOR = 'Closed by visitor', | ||
CUSTOMER_IDLE_TIMEOUT = 'customer_idle_timeout', | ||
} | ||
|
||
export enum CloseChatDescription { | ||
CLOSED_BY_VISITOR = 'Closed by visitor', | ||
CUSTOMER_IDLE_TIMEOUT = 'Customer Timeout', | ||
INVALID_TARGET_DEPARTMENT = 'Escalation failed due to invalid target department', | ||
SAME_TARGET_DEPARTMENT = 'Escalation failed due to same target department', | ||
LIVEAGENT_BOT_OFFLINE_OR_DISABLED = 'Escalation failed due to liveagent bot offline or disabled', | ||
NETWORK_OR_APP_ERROR = 'Escalation failed due to network or app error', | ||
Shailesh351 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
AGENT_UNASSIGNED = 'Agent is unassigned', | ||
INVALID_EVENT_DATA = 'Invalid Dialogflow event data', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will these messages end up in the widget appearing to visitors? Can we keep the message more specific? i.e. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { ILivechatRoom } from '@rocket.chat/apps-engine/definition/livechat'; | |
import { AppSetting } from '../config/Settings'; | ||
import { ActionIds } from '../enum/ActionIds'; | ||
import { | ||
CloseChatDescription, | ||
DialogflowRequestType, | ||
IDialogflowAction, | ||
IDialogflowCustomFields, | ||
|
@@ -77,7 +78,7 @@ export const handlePayloadActions = async ( | |
} else if (actionName === ActionIds.CLOSE_CHAT) { | ||
const livechatRoom = (await read.getRoomReader().getById(rid)) as ILivechatRoom; | ||
if (livechatRoom && livechatRoom.isOpen) { | ||
await closeChat(modify, read, rid); | ||
await closeChat(modify, read, rid, app, CloseChatDescription.CLOSED_BY_VISITOR); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also confusing, it's closed when we receive close chat action from DF Agent. So it's not closed by visitor |
||
} | ||
} else if (actionName === ActionIds.NEW_WELCOME_EVENT) { | ||
const livechatRoom = (await read.getRoomReader().getById(rid)) as ILivechatRoom; | ||
|
@@ -115,6 +116,7 @@ export const handlePayloadActions = async ( | |
console.error(error); | ||
const serviceUnavailable: string = await getLivechatAgentConfig(read, rid, AppSetting.DialogflowServiceUnavailableMessage); | ||
await createMessage(rid, read, modify, { text: serviceUnavailable }, app); | ||
await closeChat(modify, read, rid, app, CloseChatDescription.NETWORK_OR_APP_ERROR); | ||
return; | ||
} | ||
} else if (actionName === ActionIds.CHANGE_LANGUAGE_CODE) { | ||
|
@@ -148,6 +150,7 @@ const sendChangeLanguageEvent = async (app: IApp, read: IRead, modify: IModify, | |
console.error(`${Logs.DIALOGFLOW_REST_API_ERROR}: { roomID: ${rid} } ${getError(error)}`); | ||
const serviceUnavailable: string = await getLivechatAgentConfig(read, rid, AppSetting.DialogflowServiceUnavailableMessage); | ||
await createMessage(rid, read, modify, { text: serviceUnavailable }, app); | ||
await closeChat(modify, read, rid, app, CloseChatDescription.NETWORK_OR_APP_ERROR); | ||
return; | ||
} | ||
}; | ||
|
@@ -210,6 +213,7 @@ export const sendWelcomeEventToDialogFlow = async ( | |
console.error(`${Logs.DIALOGFLOW_REST_API_ERROR}: { roomID: ${rid} } ${getError(error)}`); | ||
const serviceUnavailable: string = await getLivechatAgentConfig(read, rid, AppSetting.DialogflowServiceUnavailableMessage); | ||
await createMessage(rid, read, modify, { text: serviceUnavailable }, app); | ||
await closeChat(modify, read, rid, app, CloseChatDescription.NETWORK_OR_APP_ERROR); | ||
return; | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 confusing. Chat closed by the
/incoming
endpoint is not necessarily closed by the visitor.