diff --git a/lib/integrations/dialogflow/processor_service.rb b/lib/integrations/dialogflow/processor_service.rb index 66911313f..bb5485296 100644 --- a/lib/integrations/dialogflow/processor_service.rb +++ b/lib/integrations/dialogflow/processor_service.rb @@ -18,7 +18,7 @@ class Integrations::Dialogflow::ProcessorService # TODO: might needs to change this to a way that we fetch the updated value from event data instead # cause the message.updated event could be that that the message was deleted - return message.content_attributes['submitted_values']&.dig 'value' if event_name == 'message.updated' + return message.content_attributes['submitted_values']&.first&.dig('value') if event_name == 'message.updated' message.content end diff --git a/spec/lib/integrations/dialogflow/processor_service_spec.rb b/spec/lib/integrations/dialogflow/processor_service_spec.rb index a0bf083f9..dc2208cd0 100644 --- a/spec/lib/integrations/dialogflow/processor_service_spec.rb +++ b/spec/lib/integrations/dialogflow/processor_service_spec.rb @@ -89,5 +89,17 @@ describe Integrations::Dialogflow::ProcessorService do expect(processor.perform).to be(nil) end end + + context 'when message updated' do + let(:message) do + create(:message, account: account, conversation: conversation, private: true, + submitted_values: [{ 'title' => 'Support', 'value' => 'selected_gas' }]) + end + let(:event_name) { 'message.updated' } + + it 'returns submitted value for message content' do + expect(processor.send(:message_content, message)).to eql('selected_gas') + end + end end end