diff --git a/app/javascript/dashboard/api/captain/messageReports.js b/app/javascript/dashboard/api/captain/messageReports.js new file mode 100644 index 000000000..2df1e5747 --- /dev/null +++ b/app/javascript/dashboard/api/captain/messageReports.js @@ -0,0 +1,9 @@ +import ApiClient from '../ApiClient'; + +class MessageReports extends ApiClient { + constructor() { + super('captain/message_reports', { accountScoped: true }); + } +} + +export default new MessageReports(); diff --git a/app/javascript/dashboard/components-next/message/Message.vue b/app/javascript/dashboard/components-next/message/Message.vue index 0ef64eedf..cd3c7d5dc 100644 --- a/app/javascript/dashboard/components-next/message/Message.vue +++ b/app/javascript/dashboard/components-next/message/Message.vue @@ -147,8 +147,14 @@ const { t } = useI18n(); const route = useRoute(); const inboxGetter = useMapGetter('inboxes/getInbox'); const inbox = computed(() => inboxGetter.value(props.inboxId) || {}); +const isOnChatwootCloud = useMapGetter('globalConfig/isOnChatwootCloud'); const { replaceInstallationName } = useBranding(); +const isCaptainMessage = computed(() => { + const senderType = props.sender?.type ?? props.senderType; + return senderType === SENDER_TYPES.CAPTAIN_ASSISTANT; +}); + /** * Computes the message variant based on props * @type {import('vue').ComputedRef<'user'|'agent'|'activity'|'private'|'bot'|'template'>} @@ -390,6 +396,10 @@ const contextMenuEnabledOptions = computed(() => { !props.private && props.inboxSupportsReplyTo.outgoing && !isFailedOrProcessing, + report: + isOnChatwootCloud.value && + isCaptainMessage.value && + !isMessageDeleted.value, }; }); diff --git a/app/javascript/dashboard/i18n/locale/en/conversation.json b/app/javascript/dashboard/i18n/locale/en/conversation.json index 045b8d0d9..c34ed44de 100644 --- a/app/javascript/dashboard/i18n/locale/en/conversation.json +++ b/app/javascript/dashboard/i18n/locale/en/conversation.json @@ -304,6 +304,25 @@ "MESSAGE": "You cannot undo this action", "DELETE": "Delete", "CANCEL": "Cancel" + }, + "REPORT_MESSAGE": { + "LABEL": "Report message", + "TITLE": "Report Captain message", + "DESCRIPTION": "Found an issue with this AI response? Let us know what went wrong and our team will review it to help improve Captain's accuracy.", + "PROBLEM_TYPE": "Problem type", + "PROBLEM_TYPE_PLACEHOLDER": "Select a problem type", + "DESCRIPTION_LABEL": "Description", + "DESCRIPTION_PLACEHOLDER": "Describe the problem in detail", + "SUBMIT": "Report", + "SUCCESS": "Thanks for reporting. Our team will take a look.", + "ERROR": "Could not report this message. Please try again.", + "REASONS": { + "incorrect_information": "Incorrect information", + "inappropriate_response": "Inappropriate response", + "incomplete_response": "Incomplete response", + "outdated_information": "Outdated information", + "other": "Other" + } } }, "SIDEBAR": { diff --git a/app/javascript/dashboard/modules/conversations/components/MessageContextMenu.vue b/app/javascript/dashboard/modules/conversations/components/MessageContextMenu.vue index a100b379f..4cfde97aa 100644 --- a/app/javascript/dashboard/modules/conversations/components/MessageContextMenu.vue +++ b/app/javascript/dashboard/modules/conversations/components/MessageContextMenu.vue @@ -14,6 +14,7 @@ import { import MenuItem from '../../../components/widgets/conversation/contextMenu/menuItem.vue'; import { useTrack } from 'dashboard/composables'; import NextButton from 'dashboard/components-next/button/Button.vue'; +import ReportCaptainMessageDialog from './ReportCaptainMessageDialog.vue'; export default { components: { @@ -21,6 +22,7 @@ export default { MenuItem, ContextMenu, NextButton, + ReportCaptainMessageDialog, }, props: { message: { @@ -152,6 +154,10 @@ export default { closeDeleteModal() { this.showDeleteModal = false; }, + openReportDialog() { + this.handleClose(); + this.$refs.reportDialog?.open(); + }, }, }; @@ -243,6 +249,16 @@ export default { variant="icon" @click.stop="showCannedResponseModal" /> +
+
+ diff --git a/app/javascript/dashboard/modules/conversations/components/ReportCaptainMessageDialog.vue b/app/javascript/dashboard/modules/conversations/components/ReportCaptainMessageDialog.vue new file mode 100644 index 000000000..4d36efe78 --- /dev/null +++ b/app/javascript/dashboard/modules/conversations/components/ReportCaptainMessageDialog.vue @@ -0,0 +1,119 @@ + + +