feat(ee): Add reporting events for bots (#9027)
Added a new event conversation_bot_resolved and added a job to auto resolve the bot conversations if there was no activity for the last 1 hour.
This commit is contained in:
@@ -7,3 +7,4 @@ class Account::ConversationsResolutionSchedulerJob < ApplicationJob
|
||||
end
|
||||
end
|
||||
end
|
||||
Account::ConversationsResolutionSchedulerJob.prepend_mod_with('Account::ConversationsResolutionSchedulerJob')
|
||||
|
||||
@@ -17,6 +17,8 @@ class ReportingEventListener < BaseListener
|
||||
event_start_time: conversation.created_at,
|
||||
event_end_time: conversation.updated_at
|
||||
)
|
||||
|
||||
create_bot_resolved_event(conversation, reporting_event)
|
||||
reporting_event.save!
|
||||
end
|
||||
|
||||
@@ -83,4 +85,16 @@ class ReportingEventListener < BaseListener
|
||||
)
|
||||
reporting_event.save!
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_bot_resolved_event(conversation, reporting_event)
|
||||
return unless conversation.inbox.active_bot?
|
||||
# We don't want to create a bot_resolved event if there is user interaction on the conversation
|
||||
return if conversation.messages.exists?(message_type: :outgoing, sender_type: 'User')
|
||||
|
||||
bot_resolved_event = reporting_event.dup
|
||||
bot_resolved_event.name = 'conversation_bot_resolved'
|
||||
bot_resolved_event.save!
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user