chore: Updated prompt for Article Bot (#7872)

This commit is contained in:
Sojan Jose
2023-09-07 22:41:07 -07:00
committed by GitHub
parent 3e8b6e1aee
commit 6e13d22ff7
2 changed files with 55 additions and 36 deletions

View File

@@ -4,13 +4,22 @@ class Enterprise::MessageTemplates::ResponseBotService
def perform
ActiveRecord::Base.transaction do
response = get_response(conversation.messages.last.content)
process_response(conversation.messages.last, response)
process_response(conversation.messages.last, response['response'])
end
rescue StandardError => e
ChatwootExceptionTracker.new(e, account: conversation.account).capture_exception
true
end
def response_sections(content)
sections = ''
inbox.get_responses(content).each do |response|
sections += "{context_id: #{response.id}, context: #{response.question} ? #{response.answer}},"
end
sections
end
private
delegate :contact, :account, :inbox, to: :conversation
@@ -34,15 +43,6 @@ class Enterprise::MessageTemplates::ResponseBotService
message.message_type == 'incoming' ? 'user' : 'system'
end
def response_sections(content)
sections = ''
inbox.get_responses(content).each do |response|
sections += "{context_id: #{response.id}, context: #{response.question} ? #{response.answer}}"
end
sections
end
def process_response(message, response)
if response == 'conversation_handoff'
process_action(message, 'handoff')