From a4fc0eef4b70d344b4cf01791571f26f994da91c Mon Sep 17 00:00:00 2001 From: Tejaswini Chile Date: Thu, 2 Mar 2023 21:33:07 +0530 Subject: [PATCH] fix: Exception tracking for dialogflow bot service (#6593) --- lib/integrations/bot_processor_service.rb | 2 +- .../integrations/dialogflow/processor_service_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/integrations/bot_processor_service.rb b/lib/integrations/bot_processor_service.rb index a76c3706d..c8d220eca 100644 --- a/lib/integrations/bot_processor_service.rb +++ b/lib/integrations/bot_processor_service.rb @@ -7,7 +7,7 @@ class Integrations::BotProcessorService process_content(message) rescue StandardError => e - ChatwootExceptionTracker.new(e, account: agent_bot).capture_exception + ChatwootExceptionTracker.new(e, account: hook).capture_exception end private diff --git a/spec/lib/integrations/dialogflow/processor_service_spec.rb b/spec/lib/integrations/dialogflow/processor_service_spec.rb index 003fd7c57..835dbc71b 100644 --- a/spec/lib/integrations/dialogflow/processor_service_spec.rb +++ b/spec/lib/integrations/dialogflow/processor_service_spec.rb @@ -35,6 +35,15 @@ describe Integrations::Dialogflow::ProcessorService do end end + context 'when dilogflow raises exception' do + it 'tracks hook into exception tracked' do + last_message = conversation.reload.messages.last.content + allow(dialogflow_service).to receive(:query_result).and_raise(StandardError) + processor.perform + expect(conversation.reload.messages.last.content).to eql(last_message) + end + end + context 'when dialogflow returns fullfillment text to be empty' do let(:dialogflow_response) do ActiveSupport::HashWithIndifferentAccess.new(