-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[NEW] Allows agents to send chat transcript to omnichannel end-users #17774
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
Merged
rodrigok
merged 6 commits into
develop
from
omnichannel/allow-agents-send-chat-transcript
Jun 20, 2020
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a50e900
Add ability to send/request chat transcript from the agent's side.
renatobecker 26ce013
Merge branch 'develop' into omnichannel/allow-agents-send-chat-transc…
renatobecker edbd29d
Improve translations.
renatobecker 7340dfe
Merge branch 'develop' into omnichannel/allow-agents-send-chat-transc…
renatobecker 2257397
Merge branch 'develop' into omnichannel/allow-agents-send-chat-transc…
renatobecker de79165
Fix review.
renatobecker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/livechat/client/views/app/tabbar/visitorTranscript.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <template name="visitorTranscript"> | ||
| <div class="content"> | ||
| <form autocomplete="off"> | ||
| <fieldset> | ||
| <div class="rc-input rc-form-group rc-form-group--small"> | ||
| <label class="rc-input__label"> | ||
| <div class="rc-input__title">{{_ "Visitor_Email"}}</div> | ||
| <div class="rc-input__wrapper"> | ||
| <div class="rc-input__icon"> | ||
| {{> icon icon='mail' }} | ||
| </div> | ||
| <input class="rc-input__element" type="text" name="email" autocomplete="off" value="{{email}}" disabled> | ||
| </div> | ||
| </label> | ||
| </div> | ||
| <div class="rc-input rc-form-group rc-form-group--small"> | ||
| <label class="rc-input__label"> | ||
| <div class="rc-input__title">{{_ "Subject"}}</div> | ||
| <div class="rc-input__wrapper"> | ||
| <div class="rc-input__icon"> | ||
| {{> icon block="rc-input__icon-svg rc-icon--default-size" icon="edit"}} | ||
| </div> | ||
| <input class="rc-input__element" type="text" name="subject" autocomplete="off" value="{{subject}}" disabled="{{transcriptRequested}}"/> | ||
| </div> | ||
| </label> | ||
| </div> | ||
| </fieldset> | ||
| </form> | ||
| {{#if errorMessage}} | ||
| <div class="mail-messages__instructions mail-messages__instructions--warning"> | ||
| <div class="mail-messages__instructions-wrapper"> | ||
| <div class="mail-messages__instructions-text">{{errorMessage}}</div> | ||
| </div> | ||
| </div> | ||
| {{/if}} | ||
| {{#if infoMessage}} | ||
| <div class="mail-messages__instructions mail-messages__instructions--selected"> | ||
| <div class="mail-messages__instructions-wrapper"> | ||
| <div class="mail-messages__instructions-text">{{infoMessage}}</div> | ||
| </div> | ||
| </div> | ||
| {{/if}} | ||
| <div class="rc-user-info__flex rc-user-info__row"> | ||
| <button class='rc-button cancel'><span>{{_ "Cancel"}}</span></button> | ||
| {{#if roomOpen}} | ||
| {{#if transcriptRequested}} | ||
| <button class='rc-button rc-button--cancel discard' type="button"><span>{{_ "Discard"}}</span></button> | ||
| {{else}} | ||
| <button class='rc-button rc-button--primary request'><span>{{_ "Request"}}</span></button> | ||
| {{/if}} | ||
| {{else}} | ||
| <button class='rc-button rc-button--primary send'><span>{{_ "Send"}}</span></button> | ||
| {{/if}} | ||
| </div> | ||
| </div> | ||
| </template> |
170 changes: 170 additions & 0 deletions
170
app/livechat/client/views/app/tabbar/visitorTranscript.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| import { Meteor } from 'meteor/meteor'; | ||
| import { ReactiveVar } from 'meteor/reactive-var'; | ||
| import { Template } from 'meteor/templating'; | ||
| import toastr from 'toastr'; | ||
|
|
||
| import { t, isEmail, handleError, roomTypes } from '../../../../../utils'; | ||
| import { APIClient } from '../../../../../utils/client'; | ||
| import './visitorTranscript.html'; | ||
|
|
||
| const validateTranscriptData = (instance) => { | ||
| const subject = instance.$('[name="subject"]').val(); | ||
| const email = instance.$('[name="email"]').val(); | ||
|
|
||
| if (email === '') { | ||
| instance.errorMessage.set(t('Mail_Message_Missing_to')); | ||
| return false; | ||
| } | ||
|
|
||
| if (!isEmail(email)) { | ||
| instance.errorMessage.set(t('Mail_Message_Invalid_emails', email)); | ||
| return false; | ||
| } | ||
|
|
||
| if (subject === '') { | ||
| instance.errorMessage.set(t('Mail_Message_Missing_subject')); | ||
| return false; | ||
| } | ||
|
|
||
| const visitor = instance.visitor.get(); | ||
| const { visitorEmails: { 0: visitorEmail } } = visitor; | ||
|
|
||
| if (email !== visitorEmail.address) { | ||
| instance.errorMessage.set(t('Livechat_visitor_email_and_transcript_email_do_not_match')); | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| }; | ||
|
|
||
| Template.visitorTranscript.helpers({ | ||
| roomOpen() { | ||
| const room = Template.instance().room.get(); | ||
| return room && room.open === true; | ||
| }, | ||
| email() { | ||
| const room = Template.instance().room.get(); | ||
| if (room?.transcriptRequest) { | ||
| return room.transcriptRequest.email; | ||
| } | ||
|
|
||
| const visitor = Template.instance().visitor.get(); | ||
| if (visitor?.visitorEmails && visitor.visitorEmails.length > 0) { | ||
| return visitor.visitorEmails[0].address; | ||
| } | ||
| }, | ||
| subject() { | ||
| const room = Template.instance().room.get(); | ||
| if (room?.transcriptRequest) { | ||
| return room.transcriptRequest.subject; | ||
| } | ||
|
|
||
| return t('Transcript_of_your_livechat_conversation') || (room && roomTypes.getRoomName(room.t, room)); | ||
| }, | ||
| errorEmail() { | ||
| const instance = Template.instance(); | ||
| return instance && instance.erroredEmails.get().join(', '); | ||
| }, | ||
| errorMessage() { | ||
| return Template.instance().errorMessage.get(); | ||
| }, | ||
| infoMessage() { | ||
| return Template.instance().infoMessage.get(); | ||
| }, | ||
| transcriptRequested() { | ||
| const room = Template.instance().room.get(); | ||
| return room?.hasOwnProperty('transcriptRequest'); | ||
| }, | ||
| }); | ||
|
|
||
| Template.visitorTranscript.events({ | ||
| 'click .send'(e, instance) { | ||
| event.preventDefault(); | ||
|
|
||
| if (!validateTranscriptData(instance)) { | ||
| return; | ||
| } | ||
|
|
||
| const subject = instance.$('[name="subject"]').val(); | ||
| const email = instance.$('[name="email"]').val(); | ||
|
|
||
| const room = instance.room.get(); | ||
| const { _id: rid } = room; | ||
|
|
||
| const visitor = instance.visitor.get(); | ||
| const { token } = visitor; | ||
|
|
||
| Meteor.call('livechat:sendTranscript', token, rid, email, subject, (err) => { | ||
| if (err != null) { | ||
| return handleError(err); | ||
| } | ||
|
|
||
| toastr.success(t('Your_email_has_been_queued_for_sending')); | ||
| this.save(); | ||
| }); | ||
| }, | ||
|
|
||
| 'click .request'(e, instance) { | ||
| event.preventDefault(); | ||
|
|
||
| if (!validateTranscriptData(instance)) { | ||
| return; | ||
| } | ||
|
|
||
| const subject = instance.$('[name="subject"]').val(); | ||
| const email = instance.$('[name="email"]').val(); | ||
|
|
||
| const room = instance.room.get(); | ||
| const { _id: rid } = room; | ||
|
|
||
| Meteor.call('livechat:requestTranscript', rid, email, subject, (err) => { | ||
| if (err != null) { | ||
| return handleError(err); | ||
| } | ||
|
|
||
| toastr.success(t('Livechat_transcript_has_been_requested')); | ||
| this.save(); | ||
| }); | ||
| }, | ||
|
|
||
| 'click .discard'(e, instance) { | ||
| event.preventDefault(); | ||
|
|
||
| const room = instance.room.get(); | ||
| const { _id: rid } = room; | ||
|
|
||
| Meteor.call('livechat:discardTranscript', rid, (err) => { | ||
| if (err != null) { | ||
| return handleError(err); | ||
| } | ||
|
|
||
| toastr.success(t('Livechat_transcript_request_has_been_canceled')); | ||
| this.save(); | ||
| }); | ||
| }, | ||
|
|
||
| 'click .cancel'() { | ||
| this.cancel(); | ||
| }, | ||
| }); | ||
|
|
||
| Template.visitorTranscript.onCreated(async function() { | ||
| this.room = new ReactiveVar(); | ||
| this.visitor = new ReactiveVar(); | ||
| this.errorMessage = new ReactiveVar(''); | ||
| this.infoMessage = new ReactiveVar(''); | ||
|
|
||
| this.autorun(async () => { | ||
| const { visitor } = await APIClient.v1.get(`livechat/visitors.info?visitorId=${ Template.currentData().visitorId }`); | ||
| this.visitor.set(visitor); | ||
| }); | ||
|
|
||
| this.autorun(async () => { | ||
| const { room } = await APIClient.v1.get(`rooms.info?roomId=${ Template.currentData().roomId }`); | ||
| this.room.set(room); | ||
|
|
||
| if (room?.transcriptRequest) { | ||
| this.infoMessage.set(t('Livechat_transcript_already_requested_warning')); | ||
| } | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.