Feature: Inbox greeting message (#927)
Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
This commit is contained in:
@@ -4,6 +4,8 @@ class MessageTemplates::HookExecutionService
|
||||
def perform
|
||||
return if inbox.agent_bot_inbox&.active?
|
||||
|
||||
::MessageTemplates::Template::Greeting.new(conversation: conversation).perform if should_send_greeting?
|
||||
|
||||
::MessageTemplates::Template::EmailCollect.new(conversation: conversation).perform if should_send_email_collect?
|
||||
end
|
||||
|
||||
@@ -16,8 +18,16 @@ class MessageTemplates::HookExecutionService
|
||||
conversation.messages.outgoing.count.zero? && conversation.messages.template.count.zero?
|
||||
end
|
||||
|
||||
def should_send_greeting?
|
||||
first_message_from_contact? && conversation.inbox.greeting_enabled?
|
||||
end
|
||||
|
||||
def email_collect_was_sent?
|
||||
conversation.messages.where(content_type: 'input_email').present?
|
||||
end
|
||||
|
||||
def should_send_email_collect?
|
||||
!contact_has_email? && conversation.inbox.web_widget? && first_message_from_contact?
|
||||
!contact_has_email? && conversation.inbox.web_widget? && !email_collect_was_sent?
|
||||
end
|
||||
|
||||
def contact_has_email?
|
||||
|
||||
Reference in New Issue
Block a user