diff --git a/lib/integrations/dialogflow/processor_service.rb b/lib/integrations/dialogflow/processor_service.rb index bb5485296..e9dfa8fb2 100644 --- a/lib/integrations/dialogflow/processor_service.rb +++ b/lib/integrations/dialogflow/processor_service.rb @@ -77,6 +77,8 @@ class Integrations::Dialogflow::ProcessorService case action when 'handoff' message.conversation.open! + when 'resolve' + message.conversation.resolved! end end end diff --git a/spec/lib/integrations/dialogflow/processor_service_spec.rb b/spec/lib/integrations/dialogflow/processor_service_spec.rb index 3971482d9..e002e1c3e 100644 --- a/spec/lib/integrations/dialogflow/processor_service_spec.rb +++ b/spec/lib/integrations/dialogflow/processor_service_spec.rb @@ -75,6 +75,20 @@ describe Integrations::Dialogflow::ProcessorService do end end + context 'when dialogflow returns resolve action' do + let(:dialogflow_response) do + ActiveSupport::HashWithIndifferentAccess.new( + fulfillment_messages: [{ payload: { action: 'resolve' } }, { text: dialogflow_text_double }] + ) + end + + it 'resolves the conversation without moving it to an agent' do + processor.perform + expect(conversation.reload.status).to eql('resolved') + expect(conversation.messages.last.content).to eql('hello payload') + end + end + context 'when conversation is not bot' do let(:conversation) { create(:conversation, account: account, status: :open) }