fix: Send CSAT survey only when agent can reply in conversation (#11584)
Fixes https://github.com/chatwoot/chatwoot/issues/11569 ## Problem On platforms like WhatsApp and Facebook Messenger, customers cannot reply to messages after 24 hours (or other channel-specific messaging windows). Despite this limitation, the system continued sending CSAT surveys to customers outside their messaging window, making it impossible for them to respond. ## Solution Added a check for `conversation.can_reply?` in the `should_send_csat_survey?` method. This leverages the existing `MessageWindowService` which already handles all channel-specific messaging window logic.
This commit is contained in:
@@ -435,6 +435,20 @@ RSpec.describe Conversation do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#create_csat_not_sent_activity_message' do
|
||||
subject(:create_csat_not_sent_activity_message) { conversation.create_csat_not_sent_activity_message }
|
||||
|
||||
let(:conversation) { create(:conversation) }
|
||||
|
||||
it 'creates CSAT not sent activity message' do
|
||||
create_csat_not_sent_activity_message
|
||||
expect(Conversations::ActivityMessageJob)
|
||||
.to(have_been_enqueued.at_least(:once).with(conversation, { account_id: conversation.account_id, inbox_id: conversation.inbox_id,
|
||||
message_type: :activity,
|
||||
content: 'CSAT survey not sent due to outgoing message restrictions' }))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'unread_messages' do
|
||||
subject(:unread_messages) { conversation.unread_messages }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user