fix(captain): add activity message when resolve tool is used
- Add resolve tool to Captain assistant agent_tools - Add Current.tool_name to track active tool execution - Set tool_name in resolve tool before resolving conversation - Add tool_resolved i18n key for tool-based resolution - Refactor ActivityMessageHandler for better readability Fixes issue where conversations resolved via the resolve tool would silently change status with no timeline/audit entry.
This commit is contained in:
@@ -214,6 +214,7 @@ en:
|
||||
activity:
|
||||
captain:
|
||||
resolved: 'Conversation was marked resolved by %{user_name} due to inactivity'
|
||||
tool_resolved: 'Conversation was resolved by %{user_name}'
|
||||
open: 'Conversation was marked open by %{user_name}'
|
||||
agent_bot:
|
||||
error_moved_to_open: 'Conversation was marked open by system due to an error with the agent bot.'
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
module Enterprise::ActivityMessageHandler
|
||||
def automation_status_change_activity_content
|
||||
if Current.executed_by.instance_of?(Captain::Assistant)
|
||||
locale = Current.executed_by.account.locale
|
||||
if resolved?
|
||||
I18n.t(
|
||||
'conversations.activity.captain.resolved',
|
||||
user_name: Current.executed_by.name,
|
||||
locale: locale
|
||||
)
|
||||
elsif open?
|
||||
I18n.t(
|
||||
'conversations.activity.captain.open',
|
||||
user_name: Current.executed_by.name,
|
||||
locale: locale
|
||||
)
|
||||
end
|
||||
else
|
||||
super
|
||||
end
|
||||
return super unless Current.executed_by.instance_of?(Captain::Assistant)
|
||||
return unless resolved? || open?
|
||||
|
||||
locale = Current.executed_by.account.locale
|
||||
user_name = Current.executed_by.name
|
||||
key = captain_activity_key
|
||||
|
||||
I18n.t(key, user_name: user_name, locale: locale)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def captain_activity_key
|
||||
return 'conversations.activity.captain.open' if open?
|
||||
return 'conversations.activity.captain.tool_resolved' if Current.tool_name == 'resolve'
|
||||
|
||||
'conversations.activity.captain.resolved'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,7 +37,10 @@ class Captain::Tools::ResolveTool < Captain::Tools::BasePublicTool
|
||||
end
|
||||
|
||||
# Mark conversation as resolved
|
||||
Current.tool_name = 'resolve'
|
||||
conversation.resolved!
|
||||
ensure
|
||||
Current.tool_name = nil
|
||||
end
|
||||
|
||||
def permissions
|
||||
|
||||
@@ -4,6 +4,7 @@ module Current
|
||||
thread_mattr_accessor :account_user
|
||||
thread_mattr_accessor :executed_by
|
||||
thread_mattr_accessor :contact
|
||||
thread_mattr_accessor :tool_name
|
||||
|
||||
def self.reset
|
||||
Current.user = nil
|
||||
@@ -11,5 +12,6 @@ module Current
|
||||
Current.account_user = nil
|
||||
Current.executed_by = nil
|
||||
Current.contact = nil
|
||||
Current.tool_name = nil
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user