From 340c2ee49501f5a6d0dffb815f9d923d56b0bacf Mon Sep 17 00:00:00 2001 From: aakashb95 Date: Fri, 16 Jan 2026 14:17:16 +0530 Subject: [PATCH] fix: ux if agent is involved in conversation, don't send email collect on incoming user message --- app/services/message_templates/hook_execution_service.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/services/message_templates/hook_execution_service.rb b/app/services/message_templates/hook_execution_service.rb index 6205c8f3c..3dde57a06 100644 --- a/app/services/message_templates/hook_execution_service.rb +++ b/app/services/message_templates/hook_execution_service.rb @@ -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