chore: Add resolve action in Dialogflow Integration (#3900)

This commit is contained in:
Pranav Raj S 2022-02-03 12:05:39 +05:30 committed by GitHub
parent dbb50e5923
commit 8dcb4a5ed4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -77,6 +77,8 @@ class Integrations::Dialogflow::ProcessorService
case action case action
when 'handoff' when 'handoff'
message.conversation.open! message.conversation.open!
when 'resolve'
message.conversation.resolved!
end end
end end
end end

View file

@ -75,6 +75,20 @@ describe Integrations::Dialogflow::ProcessorService do
end end
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 context 'when conversation is not bot' do
let(:conversation) { create(:conversation, account: account, status: :open) } let(:conversation) { create(:conversation, account: account, status: :open) }