feat: allow bots to handle campaigns when sender_id is nil (#12805)

This commit is contained in:
Shivam Mishra
2025-11-06 14:00:47 +05:30
committed by GitHub
parent 48ba273730
commit ec6c3b3571
2 changed files with 38 additions and 6 deletions

View File

@@ -228,14 +228,17 @@ class Conversation < ApplicationRecord
def determine_conversation_status
self.status = :resolved and return if contact.blocked?
# Message template hooks aren't executed for conversations from campaigns
# So making these conversations open for agent visibility
return if campaign.present?
return handle_campaign_status if campaign.present?
# TODO: make this an inbox config instead of assuming bot conversations should start as pending
self.status = :pending if inbox.active_bot?
end
def handle_campaign_status
# If campaign has no sender (bot-initiated) and inbox has active bot, let bot handle it
self.status = :pending if campaign.sender_id.nil? && inbox.active_bot?
end
def notify_conversation_creation
dispatcher_dispatch(CONVERSATION_CREATED)
end