Skip to content

Commit

Permalink
chore: Campaign conversations should be created in open state (#8209)
Browse files Browse the repository at this point in the history
- Ensure that conversations originating from campaigns are created in the open state.
  • Loading branch information
sojan-official committed Oct 25, 2023
1 parent 54bc4c2 commit 8c67ea5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/conversation.rb
Expand Up @@ -226,6 +226,10 @@ def validate_additional_attributes
end

def mark_conversation_pending_if_bot
# Message template hooks aren't executed for conversations from campaigns
# So making these conversations open for agent visibility
return 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
Expand Down
5 changes: 5 additions & 0 deletions spec/models/conversation_spec.rb
Expand Up @@ -556,6 +556,11 @@
it 'returns conversation status as pending' do
expect(conversation.status).to eq('pending')
end

it 'returns conversation as open if campaign is present' do
conversation = create(:conversation, inbox: bot_inbox.inbox, campaign: create(:campaign))
expect(conversation.status).to eq('open')
end
end

describe '#botintegration: when conversation created in inbox with dialogflow integration' do
Expand Down

0 comments on commit 8c67ea5

Please sign in to comment.