Feature: Send chat transcript via email (#1152)
Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
parent
4b70e4e3d6
commit
22880df429
31 changed files with 559 additions and 59 deletions
|
@ -25,6 +25,11 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
|
||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def transcript
|
||||||
|
ConversationReplyMailer.conversation_transcript(@conversation, params[:email])&.deliver_later if params[:email].present?
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
|
|
||||||
def toggle_status
|
def toggle_status
|
||||||
if params[:status]
|
if params[:status]
|
||||||
@conversation.status = params[:status]
|
@conversation.status = params[:status]
|
||||||
|
|
|
@ -13,6 +13,16 @@ class Api::V1::Widget::ConversationsController < Api::V1::Widget::BaseController
|
||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def transcript
|
||||||
|
if permitted_params[:email].present? && conversation.present?
|
||||||
|
ConversationReplyMailer.conversation_transcript(
|
||||||
|
conversation,
|
||||||
|
permitted_params[:email]
|
||||||
|
)&.deliver_later
|
||||||
|
end
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
|
|
||||||
def toggle_typing
|
def toggle_typing
|
||||||
head :ok && return if conversation.nil?
|
head :ok && return if conversation.nil?
|
||||||
|
|
||||||
|
@ -32,6 +42,6 @@ class Api::V1::Widget::ConversationsController < Api::V1::Widget::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def permitted_params
|
def permitted_params
|
||||||
params.permit(:id, :typing_status, :website_token)
|
params.permit(:id, :typing_status, :website_token, :email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,6 +53,10 @@ class ConversationApi extends ApiClient {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendEmailTranscript({ conversationId, email }) {
|
||||||
|
return axios.post(`${this.url}/${conversationId}/transcript`, { email });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new ConversationApi();
|
export default new ConversationApi();
|
||||||
|
|
|
@ -15,5 +15,6 @@ describe('#ConversationAPI', () => {
|
||||||
expect(conversationAPI).toHaveProperty('toggleTyping');
|
expect(conversationAPI).toHaveProperty('toggleTyping');
|
||||||
expect(conversationAPI).toHaveProperty('mute');
|
expect(conversationAPI).toHaveProperty('mute');
|
||||||
expect(conversationAPI).toHaveProperty('meta');
|
expect(conversationAPI).toHaveProperty('meta');
|
||||||
|
expect(conversationAPI).toHaveProperty('sendEmailTranscript');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -235,3 +235,12 @@ $spinner-before-border-color: rgba(255, 255, 255, 0.7);
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.justify-space-between {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.w-100 {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
|
@ -15,10 +15,9 @@
|
||||||
.multiselect-box {
|
.multiselect-box {
|
||||||
@include flex;
|
@include flex;
|
||||||
@include flex-align($x: justify, $y: middle);
|
@include flex-align($x: justify, $y: middle);
|
||||||
@include margin(0 $space-small);
|
|
||||||
@include border-light;
|
@include border-light;
|
||||||
border-radius: $space-smaller;
|
border-radius: $space-smaller;
|
||||||
margin-right: $space-normal;
|
margin-right: var(--space-small);
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
color: $medium-gray;
|
color: $medium-gray;
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/* eslint no-console: 0 */
|
|
||||||
/* global bus */
|
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import Spinner from 'shared/components/Spinner';
|
import Spinner from 'shared/components/Spinner';
|
||||||
import wootConstants from '../../constants';
|
import wootConstants from '../../constants';
|
||||||
|
@ -22,7 +20,7 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
Spinner,
|
Spinner,
|
||||||
},
|
},
|
||||||
props: ['conversationId'],
|
props: { conversationId: { type: [String, Number], required: true } },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
@ -32,22 +30,19 @@ export default {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
currentChat: 'getSelectedChat',
|
currentChat: 'getSelectedChat',
|
||||||
}),
|
}),
|
||||||
|
isOpen() {
|
||||||
|
return this.currentChat.status === wootConstants.STATUS_TYPE.OPEN;
|
||||||
|
},
|
||||||
currentStatus() {
|
currentStatus() {
|
||||||
const ButtonName =
|
return this.isOpen
|
||||||
this.currentChat.status === wootConstants.STATUS_TYPE.OPEN
|
? this.$t('CONVERSATION.HEADER.RESOLVE_ACTION')
|
||||||
? this.$t('CONVERSATION.HEADER.RESOLVE_ACTION')
|
: this.$t('CONVERSATION.HEADER.REOPEN_ACTION');
|
||||||
: this.$t('CONVERSATION.HEADER.REOPEN_ACTION');
|
|
||||||
return ButtonName;
|
|
||||||
},
|
},
|
||||||
buttonClass() {
|
buttonClass() {
|
||||||
return this.currentChat.status === wootConstants.STATUS_TYPE.OPEN
|
return this.isOpen ? 'success' : 'warning';
|
||||||
? 'success'
|
|
||||||
: 'warning';
|
|
||||||
},
|
},
|
||||||
buttonIconClass() {
|
buttonIconClass() {
|
||||||
return this.currentChat.status === wootConstants.STATUS_TYPE.OPEN
|
return this.isOpen ? 'ion-checkmark' : 'ion-refresh';
|
||||||
? 'ion-checkmark'
|
|
||||||
: 'ion-refresh';
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
|
@ -2,6 +2,7 @@
|
||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
import AvatarUploader from './widgets/forms/AvatarUploader.vue';
|
import AvatarUploader from './widgets/forms/AvatarUploader.vue';
|
||||||
import Bar from './widgets/chart/BarChart';
|
import Bar from './widgets/chart/BarChart';
|
||||||
|
import Button from './widgets/Button';
|
||||||
import Code from './Code';
|
import Code from './Code';
|
||||||
import ColorPicker from './widgets/ColorPicker';
|
import ColorPicker from './widgets/ColorPicker';
|
||||||
import DeleteModal from './widgets/modal/DeleteModal.vue';
|
import DeleteModal from './widgets/modal/DeleteModal.vue';
|
||||||
|
@ -21,6 +22,7 @@ import Thumbnail from './widgets/Thumbnail.vue';
|
||||||
const WootUIKit = {
|
const WootUIKit = {
|
||||||
AvatarUploader,
|
AvatarUploader,
|
||||||
Bar,
|
Bar,
|
||||||
|
Button,
|
||||||
Code,
|
Code,
|
||||||
ColorPicker,
|
ColorPicker,
|
||||||
DeleteModal,
|
DeleteModal,
|
||||||
|
|
49
app/javascript/dashboard/components/widgets/Button.vue
Normal file
49
app/javascript/dashboard/components/widgets/Button.vue
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<template>
|
||||||
|
<button :type="type" class="button nice" :class="variant" @click="onClick">
|
||||||
|
<i
|
||||||
|
v-if="!isLoading && icon"
|
||||||
|
class="icon"
|
||||||
|
:class="buttonIconClass + ' ' + icon"
|
||||||
|
/>
|
||||||
|
<spinner v-if="isLoading" />
|
||||||
|
<slot></slot>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
isLoading: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
buttonIconClass: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: 'button',
|
||||||
|
},
|
||||||
|
variant: {
|
||||||
|
type: String,
|
||||||
|
default: 'primary',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onClick(e) {
|
||||||
|
this.$emit('click', e);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.icon {
|
||||||
|
font-size: var(--font-size-large) !important;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -4,7 +4,7 @@
|
||||||
v-if="currentChat.id"
|
v-if="currentChat.id"
|
||||||
:inbox-id="inboxId"
|
:inbox-id="inboxId"
|
||||||
:is-contact-panel-open="isContactPanelOpen"
|
:is-contact-panel-open="isContactPanelOpen"
|
||||||
@contactPanelToggle="onToggleContactPanel"
|
@contact-panel-toggle="onToggleContactPanel"
|
||||||
/>
|
/>
|
||||||
<empty-state v-else />
|
<empty-state v-else />
|
||||||
</div>
|
</div>
|
||||||
|
@ -43,7 +43,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onToggleContactPanel() {
|
onToggleContactPanel() {
|
||||||
this.$emit('contactPanelToggle');
|
this.$emit('contact-panel-toggle');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="conv-header">
|
<div class="conv-header">
|
||||||
<div class="user">
|
<div v-if="!isContactPanelOpen" class="user">
|
||||||
<Thumbnail
|
<Thumbnail
|
||||||
:src="currentContact.thumbnail"
|
:src="currentContact.thumbnail"
|
||||||
size="40px"
|
size="40px"
|
||||||
|
@ -14,13 +14,20 @@
|
||||||
</h3>
|
</h3>
|
||||||
<button
|
<button
|
||||||
class="user--profile__button clear button small"
|
class="user--profile__button clear button small"
|
||||||
@click="$emit('contactPanelToggle')"
|
@click="$emit('contact-panel-toggle')"
|
||||||
>
|
>
|
||||||
{{ viewProfileButtonLabel }}
|
{{
|
||||||
|
`${$t('CONVERSATION.HEADER.OPEN')} ${$t(
|
||||||
|
'CONVERSATION.HEADER.DETAILS'
|
||||||
|
)}`
|
||||||
|
}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-container">
|
<div
|
||||||
|
class="flex-container"
|
||||||
|
:class="{ 'justify-space-between w-100': isContactPanelOpen }"
|
||||||
|
>
|
||||||
<div class="multiselect-box ion-headphone">
|
<div class="multiselect-box ion-headphone">
|
||||||
<multiselect
|
<multiselect
|
||||||
v-model="currentChat.meta.assignee"
|
v-model="currentChat.meta.assignee"
|
||||||
|
@ -38,24 +45,20 @@
|
||||||
<span slot="noResult">{{ $t('AGENT_MGMT.SEARCH.NO_RESULTS') }}</span>
|
<span slot="noResult">{{ $t('AGENT_MGMT.SEARCH.NO_RESULTS') }}</span>
|
||||||
</multiselect>
|
</multiselect>
|
||||||
</div>
|
</div>
|
||||||
<ResolveButton />
|
|
||||||
|
<more-actions :conversation-id="currentChat.id" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
/* eslint no-console: 0 */
|
|
||||||
/* eslint no-param-reassign: 0 */
|
|
||||||
/* eslint no-shadow: 0 */
|
|
||||||
/* global bus */
|
|
||||||
|
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
|
import MoreActions from './MoreActions';
|
||||||
import Thumbnail from '../Thumbnail';
|
import Thumbnail from '../Thumbnail';
|
||||||
import ResolveButton from '../../buttons/ResolveButton';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
MoreActions,
|
||||||
Thumbnail,
|
Thumbnail,
|
||||||
ResolveButton,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
@ -104,13 +107,6 @@ export default {
|
||||||
...this.agents,
|
...this.agents,
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
viewProfileButtonLabel() {
|
|
||||||
return `${
|
|
||||||
this.isContactPanelOpen
|
|
||||||
? this.$t('CONVERSATION.HEADER.CLOSE')
|
|
||||||
: this.$t('CONVERSATION.HEADER.OPEN')
|
|
||||||
} ${this.$t('CONVERSATION.HEADER.DETAILS')}`;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -0,0 +1,153 @@
|
||||||
|
<template>
|
||||||
|
<woot-modal :show.sync="show" :on-close="onCancel">
|
||||||
|
<div class="column content-box">
|
||||||
|
<woot-modal-header
|
||||||
|
:header-title="$t('EMAIL_TRANSCRIPT.TITLE')"
|
||||||
|
:header-content="$t('EMAIL_TRANSCRIPT.DESC')"
|
||||||
|
/>
|
||||||
|
<form @submit.prevent="onSubmit">
|
||||||
|
<div class="medium-12 columns">
|
||||||
|
<div v-if="currentChat.meta.sender && currentChat.meta.sender.email">
|
||||||
|
<input
|
||||||
|
id="contact"
|
||||||
|
v-model="selectedType"
|
||||||
|
type="radio"
|
||||||
|
name="selectedType"
|
||||||
|
value="contact"
|
||||||
|
/>
|
||||||
|
<label for="contact">{{
|
||||||
|
$t('EMAIL_TRANSCRIPT.FORM.SEND_TO_CONTACT')
|
||||||
|
}}</label>
|
||||||
|
</div>
|
||||||
|
<div v-if="currentChat.meta.assignee">
|
||||||
|
<input
|
||||||
|
id="assignee"
|
||||||
|
v-model="selectedType"
|
||||||
|
type="radio"
|
||||||
|
name="selectedType"
|
||||||
|
value="assignee"
|
||||||
|
/>
|
||||||
|
<label for="assignee">{{
|
||||||
|
$t('EMAIL_TRANSCRIPT.FORM.SEND_TO_AGENT')
|
||||||
|
}}</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
id="other_email_address"
|
||||||
|
v-model="selectedType"
|
||||||
|
type="radio"
|
||||||
|
name="selectedType"
|
||||||
|
value="other_email_address"
|
||||||
|
/>
|
||||||
|
<label for="other_email_address">{{
|
||||||
|
$t('EMAIL_TRANSCRIPT.FORM.SEND_TO_OTHER_EMAIL_ADDRESS')
|
||||||
|
}}</label>
|
||||||
|
</div>
|
||||||
|
<div v-if="sentToOtherEmailAddress" class="medium-6 columns">
|
||||||
|
<label :class="{ error: $v.email.$error }">
|
||||||
|
<input
|
||||||
|
v-model.trim="email"
|
||||||
|
type="text"
|
||||||
|
:placeholder="$t('EMAIL_TRANSCRIPT.FORM.EMAIL.PLACEHOLDER')"
|
||||||
|
@input="$v.email.$touch"
|
||||||
|
/>
|
||||||
|
<span v-if="$v.email.$error" class="message">
|
||||||
|
{{ $t('EMAIL_TRANSCRIPT.FORM.EMAIL.ERROR') }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<div class="medium-12 row">
|
||||||
|
<woot-submit-button
|
||||||
|
:button-text="$t('EMAIL_TRANSCRIPT.SUBMIT')"
|
||||||
|
:disabled="!isFormValid"
|
||||||
|
/>
|
||||||
|
<button class="button clear" @click.prevent="onCancel">
|
||||||
|
{{ $t('EMAIL_TRANSCRIPT.CANCEL') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</woot-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { required, minLength, email } from 'vuelidate/lib/validators';
|
||||||
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
|
export default {
|
||||||
|
mixins: [alertMixin],
|
||||||
|
props: {
|
||||||
|
show: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
currentChat: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
email: '',
|
||||||
|
selectedType: '',
|
||||||
|
isSubmitting: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
validations: {
|
||||||
|
email: {
|
||||||
|
required,
|
||||||
|
email,
|
||||||
|
minLength: minLength(4),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
sentToOtherEmailAddress() {
|
||||||
|
return this.selectedType === 'other_email_address';
|
||||||
|
},
|
||||||
|
isFormValid() {
|
||||||
|
if (this.selectedType) {
|
||||||
|
if (this.sentToOtherEmailAddress) {
|
||||||
|
return !!this.email && !this.$v.email.$error;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
selectedEmailAddress() {
|
||||||
|
const { meta } = this.currentChat;
|
||||||
|
switch (this.selectedType) {
|
||||||
|
case 'contact':
|
||||||
|
return meta.sender.email;
|
||||||
|
case 'assignee':
|
||||||
|
return meta.assignee.email;
|
||||||
|
case 'other_email_address':
|
||||||
|
return this.email;
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onCancel() {
|
||||||
|
this.$emit('cancel');
|
||||||
|
},
|
||||||
|
async onSubmit() {
|
||||||
|
this.isSubmitting = false;
|
||||||
|
try {
|
||||||
|
await this.$store.dispatch('sendEmailTranscript', {
|
||||||
|
email: this.selectedEmailAddress,
|
||||||
|
conversationId: this.currentChat.id,
|
||||||
|
});
|
||||||
|
this.showAlert(this.$t('EMAIL_TRANSCRIPT.SEND_EMAIL_SUCCESS'));
|
||||||
|
this.onCancel();
|
||||||
|
} catch (error) {
|
||||||
|
this.showAlert(this.$t('EMAIL_TRANSCRIPT.SEND_EMAIL_ERROR'));
|
||||||
|
} finally {
|
||||||
|
this.isSubmitting = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -3,7 +3,7 @@
|
||||||
<conversation-header
|
<conversation-header
|
||||||
:chat="currentChat"
|
:chat="currentChat"
|
||||||
:is-contact-panel-open="isContactPanelOpen"
|
:is-contact-panel-open="isContactPanelOpen"
|
||||||
@contactPanelToggle="onToggleContactPanel"
|
@contact-panel-toggle="onToggleContactPanel"
|
||||||
/>
|
/>
|
||||||
<div v-if="!currentChat.can_reply" class="banner messenger-policy--banner">
|
<div v-if="!currentChat.can_reply" class="banner messenger-policy--banner">
|
||||||
<span>
|
<span>
|
||||||
|
@ -238,7 +238,7 @@ export default {
|
||||||
this.conversationPanel.scrollTop = this.conversationPanel.scrollHeight;
|
this.conversationPanel.scrollTop = this.conversationPanel.scrollHeight;
|
||||||
},
|
},
|
||||||
onToggleContactPanel() {
|
onToggleContactPanel() {
|
||||||
this.$emit('contactPanelToggle');
|
this.$emit('contact-panel-toggle');
|
||||||
},
|
},
|
||||||
setScrollParams() {
|
setScrollParams() {
|
||||||
this.heightBeforeLoad = this.conversationPanel.scrollHeight;
|
this.heightBeforeLoad = this.conversationPanel.scrollHeight;
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
<template>
|
||||||
|
<div class="flex-container actions--container">
|
||||||
|
<resolve-action
|
||||||
|
:conversation-id="currentChat.id"
|
||||||
|
:status="currentChat.status"
|
||||||
|
/>
|
||||||
|
<woot-button
|
||||||
|
class="success hollow more--button"
|
||||||
|
icon="ion-more"
|
||||||
|
:class="buttonClass"
|
||||||
|
@click="toggleConversationActions"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-if="showConversationActions"
|
||||||
|
v-on-clickaway="hideConversationActions"
|
||||||
|
class="dropdown-pane"
|
||||||
|
:class="{ 'dropdown-pane--open': showConversationActions }"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
v-if="!currentChat.muted"
|
||||||
|
class="button small clear row nice alert small-6 action--button"
|
||||||
|
@click="mute"
|
||||||
|
>
|
||||||
|
<i class="icon ion-volume-mute" />
|
||||||
|
<span>{{ $t('CONTACT_PANEL.MUTE_CONTACT') }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="button small clear row nice small-6 action--button"
|
||||||
|
@click="toggleEmailActionsModal"
|
||||||
|
>
|
||||||
|
<i class="icon ion-ios-copy" />
|
||||||
|
{{ $t('CONTACT_PANEL.SEND_TRANSCRIPT') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<email-transcript-modal
|
||||||
|
v-if="showEmailActionsModal"
|
||||||
|
:show="showEmailActionsModal"
|
||||||
|
:current-chat="currentChat"
|
||||||
|
@cancel="toggleEmailActionsModal"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import { mixin as clickaway } from 'vue-clickaway';
|
||||||
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
|
import EmailTranscriptModal from './EmailTranscriptModal';
|
||||||
|
import ResolveAction from '../../buttons/ResolveAction';
|
||||||
|
import wootConstants from '../../../constants';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
EmailTranscriptModal,
|
||||||
|
ResolveAction,
|
||||||
|
},
|
||||||
|
mixins: [alertMixin, clickaway],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showConversationActions: false,
|
||||||
|
showEmailActionsModal: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
currentChat: 'getSelectedChat',
|
||||||
|
}),
|
||||||
|
|
||||||
|
buttonClass() {
|
||||||
|
return this.currentChat.status !== wootConstants.STATUS_TYPE.OPEN
|
||||||
|
? 'warning'
|
||||||
|
: 'success';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
mute() {
|
||||||
|
this.$store.dispatch('muteConversation', this.currentChat.id);
|
||||||
|
this.showAlert(this.$t('CONTACT_PANEL.MUTED_SUCCESS'));
|
||||||
|
this.toggleConversationActions();
|
||||||
|
},
|
||||||
|
toggleEmailActionsModal() {
|
||||||
|
this.showEmailActionsModal = !this.showEmailActionsModal;
|
||||||
|
this.hideConversationActions();
|
||||||
|
},
|
||||||
|
toggleConversationActions() {
|
||||||
|
this.showConversationActions = !this.showConversationActions;
|
||||||
|
},
|
||||||
|
hideConversationActions() {
|
||||||
|
this.showConversationActions = false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.more--button {
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
margin-left: var(--space-small);
|
||||||
|
padding: var(--space-small);
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions--container {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-pane {
|
||||||
|
right: 0;
|
||||||
|
top: 48px;
|
||||||
|
border: 1px solid var(--s-100);
|
||||||
|
border-radius: var(--space-smaller);
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-pane--open {
|
||||||
|
display: block;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action--button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
padding: var(--space-small) 0;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
margin-right: var(--space-small);
|
||||||
|
min-width: var(--space-normal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -23,7 +23,9 @@
|
||||||
"NO_LABELS_TO_ADD": "There are no more labels defined in the account.",
|
"NO_LABELS_TO_ADD": "There are no more labels defined in the account.",
|
||||||
"NO_AVAILABLE_LABELS": "There are no labels added to this conversation."
|
"NO_AVAILABLE_LABELS": "There are no labels added to this conversation."
|
||||||
},
|
},
|
||||||
"MUTE_CONTACT": "Mute Contact",
|
"MUTE_CONTACT": "Mute Conversation",
|
||||||
|
"MUTED_SUCCESS": "This conversation is muted for 6 hours",
|
||||||
|
"SEND_TRANSCRIPT": "Send Transcript",
|
||||||
"EDIT_LABEL": "Edit"
|
"EDIT_LABEL": "Edit"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,5 +36,22 @@
|
||||||
"VISIBLE_TO_AGENTS": "Private Note: Only visible to you and your team",
|
"VISIBLE_TO_AGENTS": "Private Note: Only visible to you and your team",
|
||||||
"CHANGE_STATUS": "Conversation status changed",
|
"CHANGE_STATUS": "Conversation status changed",
|
||||||
"CHANGE_AGENT": "Conversation Assignee changed"
|
"CHANGE_AGENT": "Conversation Assignee changed"
|
||||||
|
},
|
||||||
|
"EMAIL_TRANSCRIPT": {
|
||||||
|
"TITLE": "Send conversation transcript",
|
||||||
|
"DESC": "Send a copy of the conversation transcript to the specified email address",
|
||||||
|
"SUBMIT": "Submit",
|
||||||
|
"CANCEL": "Cancel",
|
||||||
|
"SEND_EMAIL_SUCCESS": "The chat transcript was sent successfully",
|
||||||
|
"SEND_EMAIL_ERROR": "There was an error, please try again",
|
||||||
|
"FORM": {
|
||||||
|
"SEND_TO_CONTACT": "Send the transcript to the customer",
|
||||||
|
"SEND_TO_AGENT": "Send the transcript of the assigned agent",
|
||||||
|
"SEND_TO_OTHER_EMAIL_ADDRESS": "Send the transcript to another email address",
|
||||||
|
"EMAIL": {
|
||||||
|
"PLACEHOLDER": "Enter an email address",
|
||||||
|
"ERROR": "Please enter a valid email address"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
"NO_AVAILABLE_LABELS": "There are no labels added to this conversation."
|
"NO_AVAILABLE_LABELS": "There are no labels added to this conversation."
|
||||||
},
|
},
|
||||||
"MUTE_CONTACT": "Mettre en sourdine le contact",
|
"MUTE_CONTACT": "Mettre en sourdine le contact",
|
||||||
|
"MUTED_SUCCESS": "Cette conversation est coupée pendant 6 heures",
|
||||||
|
"SEND_TRANSCRIPT": "Envoyer la transcription",
|
||||||
"EDIT_LABEL": "Modifier"
|
"EDIT_LABEL": "Modifier"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,5 +31,22 @@
|
||||||
"VISIBLE_TO_AGENTS": "Note privée : uniquement visible par vous et votre équipe",
|
"VISIBLE_TO_AGENTS": "Note privée : uniquement visible par vous et votre équipe",
|
||||||
"CHANGE_STATUS": "Statut de la conversation modifié",
|
"CHANGE_STATUS": "Statut de la conversation modifié",
|
||||||
"CHANGE_AGENT": "Responsable de la conversation modifié"
|
"CHANGE_AGENT": "Responsable de la conversation modifié"
|
||||||
|
},
|
||||||
|
"EMAIL_TRANSCRIPT": {
|
||||||
|
"TITLE": "Envoyer la transcription de la conversation",
|
||||||
|
"DESC": "Envoyer une copie de la transcription de la conversation à l'adresse e-mail spécifiée",
|
||||||
|
"SUBMIT": "Soumettre",
|
||||||
|
"CANCEL": "Annuler",
|
||||||
|
"SEND_EMAIL_SUCCESS": "La transcription du chat a été envoyée avec succès",
|
||||||
|
"SEND_EMAIL_ERROR": "Une erreur s'est produite, veuillez réessayer",
|
||||||
|
"FORM": {
|
||||||
|
"SEND_TO_CONTACT": "Envoyez la transcription au client",
|
||||||
|
"SEND_TO_AGENT": "Envoyer la transcription de l'agent désigné",
|
||||||
|
"SEND_TO_OTHER_EMAIL_ADDRESS": "Envoyez la transcription à une autre adresse e-mail",
|
||||||
|
"EMAIL": {
|
||||||
|
"PLACEHOLDER": "Entrez une adresse email",
|
||||||
|
"ERROR": "S'il vous plaît, mettez une adresse email valide"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
"NO_LABELS_TO_ADD": "There are no more labels defined in the account.",
|
"NO_LABELS_TO_ADD": "There are no more labels defined in the account.",
|
||||||
"NO_AVAILABLE_LABELS": "There are no labels added to this conversation."
|
"NO_AVAILABLE_LABELS": "There are no labels added to this conversation."
|
||||||
},
|
},
|
||||||
"MUTE_CONTACT": "Mute Contact",
|
"MUTE_CONTACT": "Contact muet",
|
||||||
|
"MUTED_SUCCESS": "Cette conversation est coupée pendant 6 heures",
|
||||||
|
"SEND_TRANSCRIPT": "Envoyer la transcription",
|
||||||
"EDIT_LABEL": "Bewerken"
|
"EDIT_LABEL": "Bewerken"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,5 +31,22 @@
|
||||||
"VISIBLE_TO_AGENTS": "Privéopmerking: alleen zichtbaar voor jou en je team",
|
"VISIBLE_TO_AGENTS": "Privéopmerking: alleen zichtbaar voor jou en je team",
|
||||||
"CHANGE_STATUS": "Gespreksstatus veranderd",
|
"CHANGE_STATUS": "Gespreksstatus veranderd",
|
||||||
"CHANGE_AGENT": "Toegewezen persoon voor dit gesprek is veranderd"
|
"CHANGE_AGENT": "Toegewezen persoon voor dit gesprek is veranderd"
|
||||||
|
},
|
||||||
|
"EMAIL_TRANSCRIPT": {
|
||||||
|
"TITLE": "Stuur conversatie transcriptie",
|
||||||
|
"DESC": "Stuur een kopie van het conversatietranscript naar het opgegeven e-mailadres",
|
||||||
|
"SUBMIT": "Verzenden",
|
||||||
|
"CANCEL": "Annuleer",
|
||||||
|
"SEND_EMAIL_SUCCESS": "Het chattranscript is succesvol verzonden",
|
||||||
|
"SEND_EMAIL_ERROR": "Er is een fout opgetreden, probeer het opnieuw",
|
||||||
|
"FORM": {
|
||||||
|
"SEND_TO_CONTACT": "Stuur het transcript naar de klant",
|
||||||
|
"SEND_TO_AGENT": "Stuur het transcript van de toegewezen agent",
|
||||||
|
"SEND_TO_OTHER_EMAIL_ADDRESS": "Stuur het transcript naar een ander e-mailadres",
|
||||||
|
"EMAIL": {
|
||||||
|
"PLACEHOLDER": "Voer een e-mail adres in",
|
||||||
|
"ERROR": "Vul een geldig e-mailadres in"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,15 +57,6 @@
|
||||||
>
|
>
|
||||||
{{ contact.additional_attributes.description }}
|
{{ contact.additional_attributes.description }}
|
||||||
</div>
|
</div>
|
||||||
<div class="contact--actions">
|
|
||||||
<button
|
|
||||||
v-if="!currentChat.muted"
|
|
||||||
class="button small clear contact--mute small-6"
|
|
||||||
@click="mute"
|
|
||||||
>
|
|
||||||
{{ $t('CONTACT_PANEL.MUTE_CONTACT') }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="browser.browser_name" class="conversation--details">
|
<div v-if="browser.browser_name" class="conversation--details">
|
||||||
<contact-details-item
|
<contact-details-item
|
||||||
|
@ -185,14 +176,14 @@ export default {
|
||||||
onPanelToggle() {
|
onPanelToggle() {
|
||||||
this.onToggle();
|
this.onToggle();
|
||||||
},
|
},
|
||||||
mute() {
|
|
||||||
this.$store.dispatch('muteConversation', this.conversationId);
|
|
||||||
},
|
|
||||||
getContactDetails() {
|
getContactDetails() {
|
||||||
if (this.contactId) {
|
if (this.contactId) {
|
||||||
this.$store.dispatch('contacts/show', { id: this.contactId });
|
this.$store.dispatch('contacts/show', { id: this.contactId });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
openTranscriptModal() {
|
||||||
|
this.showTranscriptModal = true;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -295,11 +286,12 @@ export default {
|
||||||
.contact--mute {
|
.contact--mute {
|
||||||
color: $alert-color;
|
color: $alert-color;
|
||||||
display: block;
|
display: block;
|
||||||
text-align: center;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact--actions {
|
.contact--actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<conversation-box
|
<conversation-box
|
||||||
:inbox-id="inboxId"
|
:inbox-id="inboxId"
|
||||||
:is-contact-panel-open="isContactPanelOpen"
|
:is-contact-panel-open="isContactPanelOpen"
|
||||||
@contactPanelToggle="onToggleContactPanel"
|
@contact-panel-toggle="onToggleContactPanel"
|
||||||
>
|
>
|
||||||
</conversation-box>
|
</conversation-box>
|
||||||
<contact-panel
|
<contact-panel
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/* eslint no-console: 0 */
|
/* eslint no-console: 0 */
|
||||||
/* global bus */
|
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
import ChatList from '../../../components/ChatList';
|
import ChatList from '../../../components/ChatList';
|
||||||
|
|
|
@ -223,6 +223,14 @@ const actions = {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
sendEmailTranscript: async (_, { conversationId, email }) => {
|
||||||
|
try {
|
||||||
|
await ConversationApi.sendEmailTranscript({ conversationId, email });
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default actions;
|
export default actions;
|
||||||
|
|
|
@ -177,4 +177,16 @@ describe('#actions', () => {
|
||||||
expect(commit.mock.calls).toEqual([]);
|
expect(commit.mock.calls).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#sendEmailTranscript', () => {
|
||||||
|
it('sends correct mutations if api is successful', async () => {
|
||||||
|
axios.post.mockResolvedValue({});
|
||||||
|
await actions.sendEmailTranscript(
|
||||||
|
{ commit },
|
||||||
|
{ conversationId: 1, email: 'testemail@example.com' }
|
||||||
|
);
|
||||||
|
expect(commit).toHaveBeenCalledTimes(0);
|
||||||
|
expect(commit.mock.calls).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,6 @@ class ConversationReplyMailer < ApplicationMailer
|
||||||
|
|
||||||
recap_messages = @conversation.messages.chat.where('created_at < ?', message_queued_time).last(10)
|
recap_messages = @conversation.messages.chat.where('created_at < ?', message_queued_time).last(10)
|
||||||
new_messages = @conversation.messages.chat.where('created_at >= ?', message_queued_time)
|
new_messages = @conversation.messages.chat.where('created_at >= ?', message_queued_time)
|
||||||
|
|
||||||
@messages = recap_messages + new_messages
|
@messages = recap_messages + new_messages
|
||||||
@messages = @messages.select(&:reportable?)
|
@messages = @messages.select(&:reportable?)
|
||||||
|
|
||||||
|
@ -41,6 +40,20 @@ class ConversationReplyMailer < ApplicationMailer
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def conversation_transcript(conversation, to_email)
|
||||||
|
return unless smtp_config_set_or_development?
|
||||||
|
|
||||||
|
init_conversation_attributes(conversation)
|
||||||
|
|
||||||
|
@messages = @conversation.messages.chat.select(&:reportable?)
|
||||||
|
|
||||||
|
mail({
|
||||||
|
to: to_email,
|
||||||
|
from: from_email,
|
||||||
|
subject: "[##{@conversation.display_id}] #{I18n.t('conversations.reply.transcript_subject')}"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def init_conversation_attributes(conversation)
|
def init_conversation_attributes(conversation)
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<% @messages.each do |message| %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b><%= message.sender&.try(:available_name) || message.sender&.name || '' %></b>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-bottom: 16px;">
|
||||||
|
<% if message.content %>
|
||||||
|
<%= message.content %>
|
||||||
|
<% end %>
|
||||||
|
<% if message.attachments %>
|
||||||
|
<% message.attachments.each do |attachment| %>
|
||||||
|
Attachment [<a href="<%= attachment.file_url %>" _target="blank">Click here to view</a>]
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<br />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
|
@ -15,7 +15,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if message.attachments %>
|
<% if message.attachments %>
|
||||||
<% message.attachments.each do |attachment| %>
|
<% message.attachments.each do |attachment| %>
|
||||||
attachment [<a href="<%= attachment.file_url %>" _target="blank">click here to view</a>]
|
Attachment [<a href="<%= attachment.file_url %>" _target="blank">Click here to view</a>]
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -56,3 +56,4 @@ en:
|
||||||
email_input_box_message_body: "Get notified by email"
|
email_input_box_message_body: "Get notified by email"
|
||||||
reply:
|
reply:
|
||||||
email_subject: "New messages on this conversation"
|
email_subject: "New messages on this conversation"
|
||||||
|
transcript_subject: "Conversation Transcript"
|
||||||
|
|
|
@ -54,6 +54,7 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
member do
|
member do
|
||||||
post :mute
|
post :mute
|
||||||
|
post :transcript
|
||||||
post :toggle_status
|
post :toggle_status
|
||||||
post :toggle_typing_status
|
post :toggle_typing_status
|
||||||
post :update_last_seen
|
post :update_last_seen
|
||||||
|
@ -117,6 +118,7 @@ Rails.application.routes.draw do
|
||||||
collection do
|
collection do
|
||||||
post :update_last_seen
|
post :update_last_seen
|
||||||
post :toggle_typing
|
post :toggle_typing
|
||||||
|
post :transcript
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resource :contact, only: [:update]
|
resource :contact, only: [:update]
|
||||||
|
|
|
@ -212,4 +212,32 @@ RSpec.describe 'Conversations API', type: :request do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'POST /api/v1/accounts/{account.id}/conversations/:id/transcript' do
|
||||||
|
let(:conversation) { create(:conversation, account: account) }
|
||||||
|
|
||||||
|
context 'when it is an unauthenticated user' do
|
||||||
|
it 'returns unauthorized' do
|
||||||
|
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/transcript"
|
||||||
|
|
||||||
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when it is an authenticated user' do
|
||||||
|
let(:agent) { create(:user, account: account, role: :agent) }
|
||||||
|
let(:params) { { email: 'test@test.com' } }
|
||||||
|
|
||||||
|
it 'mutes conversation' do
|
||||||
|
allow(ConversationReplyMailer).to receive(:conversation_transcript)
|
||||||
|
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/transcript",
|
||||||
|
headers: agent.create_new_auth_token,
|
||||||
|
params: params,
|
||||||
|
as: :json
|
||||||
|
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
expect(ConversationReplyMailer).to have_received(:conversation_transcript).with(conversation, 'test@test.com')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,4 +60,20 @@ RSpec.describe '/api/v1/widget/conversations/toggle_typing', type: :request do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'POST /api/v1/widget/conversations/transcript' do
|
||||||
|
context 'with a conversation' do
|
||||||
|
it 'sends transcript email' do
|
||||||
|
allow(ConversationReplyMailer).to receive(:conversation_transcript)
|
||||||
|
|
||||||
|
post '/api/v1/widget/conversations/transcript',
|
||||||
|
headers: { 'X-Auth-Token' => token },
|
||||||
|
params: { website_token: web_widget.website_token, email: 'test@test.com' },
|
||||||
|
as: :json
|
||||||
|
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
expect(ConversationReplyMailer).to have_received(:conversation_transcript).with(conversation, 'test@test.com')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue