From 73054c6a94ae42e609f4edbb1085207833d1c989 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Mon, 6 Jul 2026 22:23:16 -0700 Subject: [PATCH] refactor: clarify connected agent bot conversation setup --- app/models/conversation.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/models/conversation.rb b/app/models/conversation.rb index e21410451..cc2fbdb4e 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -282,17 +282,21 @@ class Conversation < ApplicationRecord return handle_campaign_status if campaign.present? - # TODO: make this an inbox config instead of assuming bot conversations should start as pending - assign_connected_agent_bot if inbox.agent_bot_inbox&.active? - self.status = :pending if inbox.active_bot? + return unless inbox.active_bot? + + self.status = :pending + assign_connected_agent_bot if connected_agent_bot_inbox? end def handle_campaign_status - # If campaign has no sender (bot-initiated) and inbox has active bot, let bot handle it return unless campaign.sender_id.nil? && inbox.active_bot? - assign_connected_agent_bot if inbox.agent_bot_inbox&.active? self.status = :pending + assign_connected_agent_bot if connected_agent_bot_inbox? + end + + def connected_agent_bot_inbox? + inbox.agent_bot_inbox&.active? end def assign_connected_agent_bot