fix: Send CSAT survey only when agent can reply in conversation (#11637)

This commit is contained in:
Muhsin Keloth
2025-06-11 22:45:32 +05:30
committed by GitHub
parent 459c22054a
commit 7a67799f35
7 changed files with 180 additions and 82 deletions

View File

@@ -17,7 +17,6 @@ class MessageTemplates::HookExecutionService
::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?
@@ -55,23 +54,5 @@ class MessageTemplates::HookExecutionService
def contact_has_email?
contact.email
end
def csat_enabled_conversation?
return false unless conversation.resolved?
# should not sent since the link will be public
return false if conversation.tweet?
return false unless inbox.csat_survey_enabled?
true
end
def should_send_csat_survey?
return unless csat_enabled_conversation?
# only send CSAT once in a conversation
return if conversation.messages.where(content_type: :input_csat).present?
true
end
end
MessageTemplates::HookExecutionService.prepend_mod_with('MessageTemplates::HookExecutionService')