From 146bdd2f834da86060dd13781353034e243c1e80 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Tue, 4 Jul 2023 15:28:42 +0530 Subject: [PATCH] Update command bar to accomdate more AI options --- .../components/widgets/AIAssistanceButton.vue | 32 +++++++- .../components/widgets/AIAssistanceModal.vue | 75 ++++++++++++++++++ .../i18n/locale/en/generalSettings.json | 4 +- .../i18n/locale/en/integrations.json | 1 + .../dashboard/commands/CommandBarIcons.js | 3 + .../dashboard/commands/commandBarBusEvents.js | 1 + .../dashboard/commands/conversationHotKeys.js | 78 +++++++++++++++++++ 7 files changed, 189 insertions(+), 5 deletions(-) create mode 100644 app/javascript/dashboard/components/widgets/AIAssistanceModal.vue diff --git a/app/javascript/dashboard/components/widgets/AIAssistanceButton.vue b/app/javascript/dashboard/components/widgets/AIAssistanceButton.vue index 1da4109da..9a416e867 100644 --- a/app/javascript/dashboard/components/widgets/AIAssistanceButton.vue +++ b/app/javascript/dashboard/components/widgets/AIAssistanceButton.vue @@ -1,7 +1,16 @@ + + + + diff --git a/app/javascript/dashboard/i18n/locale/en/generalSettings.json b/app/javascript/dashboard/i18n/locale/en/generalSettings.json index 63b597a53..aeafa9d54 100644 --- a/app/javascript/dashboard/i18n/locale/en/generalSettings.json +++ b/app/javascript/dashboard/i18n/locale/en/generalSettings.json @@ -110,7 +110,8 @@ "SNOOZE_CONVERSATION": "Snooze Conversation", "ADD_LABEL": "Add label to the conversation", "REMOVE_LABEL": "Remove label from the conversation", - "SETTINGS": "Settings" + "SETTINGS": "Settings", + "AI_ASSIST": "AI Assist" }, "COMMANDS": { "GO_TO_CONVERSATION_DASHBOARD": "Go to Conversation Dashboard", @@ -132,6 +133,7 @@ "GO_TO_NOTIFICATIONS": "Go to Notifications", "ADD_LABELS_TO_CONVERSATION": "Add label to the conversation", "ASSIGN_AN_AGENT": "Assign an agent", + "AI_ASSIST": "AI Assist", "ASSIGN_PRIORITY": "Assign priority", "ASSIGN_A_TEAM": "Assign a team", "MUTE_CONVERSATION": "Mute conversation", diff --git a/app/javascript/dashboard/i18n/locale/en/integrations.json b/app/javascript/dashboard/i18n/locale/en/integrations.json index e3104bd4b..78087b20e 100644 --- a/app/javascript/dashboard/i18n/locale/en/integrations.json +++ b/app/javascript/dashboard/i18n/locale/en/integrations.json @@ -83,6 +83,7 @@ "CREATE_ERROR": "There was an error creating a meeting link, please try again" }, "OPEN_AI": { + "AI_ASSIST": "AI Assist", "TITLE": "Improve With AI", "SUMMARY_TITLE": "Summary with AI", "REPLY_TITLE": "Reply suggestion with AI", diff --git a/app/javascript/dashboard/routes/dashboard/commands/CommandBarIcons.js b/app/javascript/dashboard/routes/dashboard/commands/CommandBarIcons.js index 97831ae53..526c2a9b4 100644 --- a/app/javascript/dashboard/routes/dashboard/commands/CommandBarIcons.js +++ b/app/javascript/dashboard/routes/dashboard/commands/CommandBarIcons.js @@ -58,3 +58,6 @@ export const ICON_PRIORITY_NONE = ` `; + +export const ICON_AI_ASSIST = ``; +export const ICON_AI_SUMMARY = ``; diff --git a/app/javascript/dashboard/routes/dashboard/commands/commandBarBusEvents.js b/app/javascript/dashboard/routes/dashboard/commands/commandBarBusEvents.js index 1c10fd5bb..e291248e3 100644 --- a/app/javascript/dashboard/routes/dashboard/commands/commandBarBusEvents.js +++ b/app/javascript/dashboard/routes/dashboard/commands/commandBarBusEvents.js @@ -14,3 +14,4 @@ export const CMD_TOGGLE_CONTACT_SIDEBAR = 'CMD_TOGGLE_CONTACT_SIDEBAR'; export const CMD_REOPEN_CONVERSATION = 'CMD_REOPEN_CONVERSATION'; export const CMD_RESOLVE_CONVERSATION = 'CMD_RESOLVE_CONVERSATION'; export const CMD_SNOOZE_CONVERSATION = 'CMD_SNOOZE_CONVERSATION'; +export const CMD_AI_ASSIST = 'CMD_AI_ASSIST'; diff --git a/app/javascript/dashboard/routes/dashboard/commands/conversationHotKeys.js b/app/javascript/dashboard/routes/dashboard/commands/conversationHotKeys.js index 7cb41eed9..2ef234612 100644 --- a/app/javascript/dashboard/routes/dashboard/commands/conversationHotKeys.js +++ b/app/javascript/dashboard/routes/dashboard/commands/conversationHotKeys.js @@ -1,6 +1,10 @@ import { mapGetters } from 'vuex'; import wootConstants from 'dashboard/constants/globals'; +import { LocalStorage } from 'shared/helpers/localStorage'; +import { LOCAL_STORAGE_KEYS } from 'dashboard/constants/localStorage'; + import { + CMD_AI_ASSIST, CMD_MUTE_CONVERSATION, CMD_REOPEN_CONVERSATION, CMD_RESOLVE_CONVERSATION, @@ -26,6 +30,8 @@ import { ICON_PRIORITY_LOW, ICON_PRIORITY_MEDIUM, ICON_PRIORITY_NONE, + ICON_AI_ASSIST, + ICON_AI_SUMMARY, } from './CommandBarIcons'; const SNOOZE_OPTIONS = wootConstants.SNOOZE_OPTIONS; @@ -337,6 +343,77 @@ export default { ]); }, + AIAssistActions() { + const savedDraftMessages = + LocalStorage.get(LOCAL_STORAGE_KEYS.DRAFT_MESSAGES) || {}; + const replyType = 'REPLY'; + const key = `draft-${this.currentChat.id}-${replyType}`; + const message = `${savedDraftMessages[key] || ''}`; + let aiOptions = []; + + if (!message) { + aiOptions = [ + { + label: this.$t('INTEGRATION_SETTINGS.OPEN_AI.REPLY_TITLE'), + key: 'reply_suggestion', + icon: ICON_AI_ASSIST, + }, + { + label: this.$t('INTEGRATION_SETTINGS.OPEN_AI.SUMMARY_TITLE'), + key: 'summarize', + icon: ICON_AI_SUMMARY, + }, + ]; + } else { + aiOptions = [ + { + label: this.$t('CONVERSATION.PRIORITY.OPTIONS.NONE'), + key: null, + icon: ICON_PRIORITY_NONE, + }, + { + label: this.$t('CONVERSATION.PRIORITY.OPTIONS.URGENT'), + key: 'urgent', + icon: ICON_PRIORITY_URGENT, + }, + { + label: this.$t('CONVERSATION.PRIORITY.OPTIONS.HIGH'), + key: 'high', + icon: ICON_PRIORITY_HIGH, + }, + { + label: this.$t('CONVERSATION.PRIORITY.OPTIONS.MEDIUM'), + key: 'medium', + icon: ICON_PRIORITY_MEDIUM, + }, + { + label: this.$t('CONVERSATION.PRIORITY.OPTIONS.LOW'), + key: 'low', + icon: ICON_PRIORITY_LOW, + }, + ]; + } + const options = aiOptions.map(item => ({ + id: `ai-assist-${item.key}`, + title: item.label, + parent: 'ai_assist', + section: this.$t('COMMAND_BAR.SECTIONS.AI_ASSIST'), + priority: item, + icon: item.icon, + handler: () => bus.$emit(CMD_AI_ASSIST, item.key), + })); + return [ + { + id: 'ai_assist', + title: this.$t('COMMAND_BAR.COMMANDS.AI_ASSIST'), + section: this.$t('COMMAND_BAR.SECTIONS.AI_ASSIST'), + icon: ICON_AI_ASSIST, + children: options.map(option => option.id), + }, + ...options, + ]; + }, + conversationHotKeys() { if (isAConversationRoute(this.$route.name)) { return [ @@ -346,6 +423,7 @@ export default { ...this.assignTeamActions, ...this.labelActions, ...this.assignPriorityActions, + ...this.AIAssistActions, ]; }