fix: ux if agent is involved in conversation, don't send email collect on incoming user message

This commit is contained in:
aakashb95
2026-01-16 14:17:16 +05:30
parent afea1c44c6
commit 340c2ee495
@@ -49,6 +49,11 @@ class MessageTemplates::HookExecutionService
# TODO: we should be able to reduce this logic once we have a toggle for email collect messages
def should_send_email_collect?
# Don't send email collect if a human agent has already replied
# It breaks UX if an automated template shows up during a human conversation
# The agent can manually collect email if needed
return false if conversation.messages.outgoing.exists?(private: false, sender_type: 'User')
!contact_has_email? && inbox.web_widget? && !email_collect_was_sent?
end