feat: allow bots to handle campaigns when sender_id is nil (#12805)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user