Skip to content

Commit 9481a8c

Browse files
authored
Merge pull request RocketChat#30 from Kailash0311/upstream-merge
Upstream Merge
2 parents c5ea518 + b61d8d4 commit 9481a8c

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

config/Settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export enum AppSetting {
2222

2323
export enum DefaultMessage {
2424
DEFAULT_DialogflowServiceUnavailableMessage = 'Sorry, I\'m having trouble answering your question.',
25+
DEFAULT_DialogflowRequestFailedMessage = 'Sorry, something went wrong.',
2526
DEFAULT_DialogflowHandoverMessage = 'Transferring to an online agent',
2627
DEFAULT_DialogflowHandoverFailedMessage = 'Sorry I\'m unable to transfer you to an agent.',
2728
DEFAULT_DialogflowCloseChatMessage = 'Closing the chat, Goodbye',
2829
DEFAULT_DialogflowWelcomeMessage = 'Thanks for connecting',
29-
DEFAULT_DialogflowRequestFailedMessage = 'Apologies but your request cannot be completed.',
3030
}
3131

3232
export const settings: Array<ISetting> = [

docs/QuickReplies.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ These buttons perform a specific action in the app. You can add them by simply p
6767

6868
### Handover Button
6969

70-
- On clicking this button, the visitor will be handed over to another departement. You can set the target department in the app setting called **Target Department for Handover**. Add the following block in your Quick Replies payload, with **actionId** set as `df_perform_handover`, to include this button in your response:
70+
- On clicking this button, the visitor will be handed over to another departement. You can set the target department in the app setting called **Target Department for Handover** or add a `departmentName` param in your payload. On failing to provide a department name in either way, will send a request failure message back to the visitor, when visitor clicks the button.
71+
72+
- Add the following block in your Quick Replies payload, with **actionId** set as `df_perform_handover`, to include this button in your response:
7173

7274
- Parameters:
7375

@@ -84,7 +86,8 @@ These buttons perform a specific action in the app. You can add them by simply p
8486
{
8587
"text": "Perform Handover",
8688
"buttonStyle": "primary",
87-
"actionId": "df_perform_handover"
89+
"actionId": "df_perform_handover",
90+
"departmentName": "sales"
8891
}
8992
```
9093

@@ -113,4 +116,3 @@ These buttons perform a specific action in the app. You can add them by simply p
113116
## Example
114117

115118
![Pre-Programmed Example Payload](https://user-images.githubusercontent.com/41849970/92283593-d5e70a80-ef1d-11ea-8860-e91a4980515f.png)
116-

enum/Dialogflow.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export interface IDialogflowQuickReplyOptions {
3939
actionId?: string;
4040
buttonStyle?: ButtonStyle;
4141
salesforceButtonId?: string;
42+
data?: {
43+
[prop: string]: any;
44+
};
4245
}
4346

4447
export interface IDialogflowAccessToken {

handler/ExecuteLivechatBlockActionHandler.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { IUser } from '@rocket.chat/apps-engine/definition/users';
77
import { AppSetting, DefaultMessage } from '../config/Settings';
88
import { ActionIds } from '../enum/ActionIds';
99
import { createLivechatMessage, createMessage, deleteAllActionBlocks } from '../lib/Message';
10-
import { closeChat, performHandover, updateRoomCustomFields } from '../lib/Room';
10+
import { closeChat, performHandover } from '../lib/Room';
1111
import { getAppSettingValue } from '../lib/Settings';
1212

1313
export class ExecuteLivechatBlockActionHandler {
@@ -39,12 +39,10 @@ export class ExecuteLivechatBlockActionHandler {
3939
switch (actionId) {
4040
case ActionIds.PERFORM_HANDOVER:
4141
const targetDepartment: string = value || await getAppSettingValue(this.read, AppSetting.FallbackTargetDepartment);
42-
4342
if (!targetDepartment) {
4443
await createMessage(rid, this.read, this.modify, { text: DefaultMessage.DEFAULT_DialogflowRequestFailedMessage });
4544
break;
4645
}
47-
4846
await performHandover(this.modify, this.read, rid, visitor.token, targetDepartment);
4947
break;
5048

0 commit comments

Comments
 (0)