From 8dcb4a5ed418128be4dd8aa07d38d2091798a8f9 Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Thu, 3 Feb 2022 12:05:39 +0530 Subject: [PATCH] chore: Add resolve action in Dialogflow Integration (#3900) --- lib/integrations/dialogflow/processor_service.rb | 2 ++ .../dialogflow/processor_service_spec.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) 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) }