From b5000c7bc4deaa3c10206bf2ce070f9e1348db69 Mon Sep 17 00:00:00 2001 From: Abhinav Raut Date: Fri, 15 May 2026 11:59:38 +0530 Subject: [PATCH] skip auto-reply and csat send when contact has no email --- internal/conversation/conversation.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/conversation/conversation.go b/internal/conversation/conversation.go index 220bfe02..cfcf9303 100644 --- a/internal/conversation/conversation.go +++ b/internal/conversation/conversation.go @@ -1287,6 +1287,9 @@ func (m *Manager) ApplyAction(action amodels.RuleAction, conv models.Conversatio case amodels.ActionReply: // Automated replies always go to the contact only. CCs from the // conversation history are deliberately not carried forward. + if conv.Contact.Email.String == "" { + return fmt.Errorf("auto-reply skipped: contact has no email for conversation: %s", conv.UUID) + } _, err := m.QueueReply( []mmodels.Media{}, conv.InboxID, @@ -1356,8 +1359,12 @@ func (m *Manager) RemoveConversationAssignee(uuid, typ string, actor umodels.Use return nil } -// SendCSATReply sends a CSAT reply message to a conversation. No-op if one was already sent. +// SendCSATReply sends a CSAT reply message to a conversation. No-op if one was already sent or contact has no email. func (m *Manager) SendCSATReply(actorUserID int, conversation models.Conversation) error { + if conversation.Contact.Email.String == "" { + m.lo.Info("CSAT reply skipped: contact has no email for conversation: %s", "conversation_uuid", conversation.UUID) + return nil + } csatResp, err := m.csatStore.Create(conversation.ID) if err != nil { if errors.Is(err, csat.ErrCSATAlreadyExists) {