Feat: Out of office autoresponder (#2992)

This change allows the user to enable autoresponder during the out-of-office time.

Fixes: #2035
This commit is contained in:
Aswin Dev P.S
2021-09-17 22:17:11 +05:30
committed by GitHub
parent 6ad5a7452c
commit 794a56d4cc
5 changed files with 68 additions and 26 deletions

View File

@@ -392,6 +392,10 @@ export default {
key: 'collaborators',
name: this.$t('INBOX_MGMT.TABS.COLLABORATORS'),
},
{
key: 'businesshours',
name: this.$t('INBOX_MGMT.TABS.BUSINESS_HOURS'),
},
];
if (this.isAWebWidgetInbox) {
@@ -401,10 +405,6 @@ export default {
key: 'preChatForm',
name: this.$t('INBOX_MGMT.TABS.PRE_CHAT_FORM'),
},
{
key: 'businesshours',
name: this.$t('INBOX_MGMT.TABS.BUSINESS_HOURS'),
},
{
key: 'configuration',
name: this.$t('INBOX_MGMT.TABS.CONFIGURATION'),

View File

@@ -43,10 +43,10 @@ class WorkingHour < ApplicationRecord
def open_at?(time)
return false if closed_all_day?
time.hour >= open_hour &&
time.min >= open_minutes &&
time.hour <= close_hour &&
time.min <= close_minutes
open_time = Time.zone.now.in_time_zone(inbox.timezone).change({ hour: open_hour, min: open_minutes })
close_time = Time.zone.now.in_time_zone(inbox.timezone).change({ hour: close_hour, min: close_minutes })
time.between?(open_time, close_time)
end
def open_now?

View File

@@ -14,14 +14,16 @@ class MessageTemplates::HookExecutionService
delegate :contact, to: :conversation
def trigger_templates
# TODO: let's see whether this is needed and remove this and related logic if not
# ::MessageTemplates::Template::OutOfOffice.new(conversation: conversation).perform if should_send_out_of_office_message?
::MessageTemplates::Template::OutOfOffice.new(conversation: conversation).perform if should_send_out_of_office_message?
::MessageTemplates::Template::Greeting.new(conversation: conversation).perform if should_send_greeting?
::MessageTemplates::Template::EmailCollect.new(conversation: conversation).perform if inbox.enable_email_collect && should_send_email_collect?
::MessageTemplates::Template::CsatSurvey.new(conversation: conversation).perform if should_send_csat_survey?
end
def should_send_out_of_office_message?
# should not send if its a tweet message
return false if conversation.tweet?
inbox.out_of_office? && conversation.messages.today.template.empty? && inbox.out_of_office_message.present?
end