fix: handoff tool reason

This commit is contained in:
Shivam Mishra
2025-08-01 15:49:18 +05:30
parent 5fb40e0b2e
commit 9c9c1c301d
+4 -15
View File
@@ -24,31 +24,20 @@ class Captain::Tools::HandoffTool < Captain::Tools::BasePublicTool
private
def trigger_handoff(conversation, reason)
# Create handoff message (using existing logic from ResponseBuilderJob)
handoff_message = build_handoff_message(reason)
# post the reason as a private note
conversation.messages.create!(
message_type: :outgoing,
private: true,
sender: @assistant,
account: conversation.account,
inbox: conversation.inbox,
content: handoff_message
content: reason
)
# Trigger the bot handoff (sets status to open + dispatches events)
conversation.bot_handoff!
end
def build_handoff_message(reason)
base_message = @assistant.config['handoff_message'].presence ||
I18n.t('conversations.messages.handoff_message')
if reason.present?
"#{base_message}\n\nReason: #{reason}"
else
base_message
end
end
# TODO: Future enhancement - Add team assignment capability
# This tool could be enhanced to:
# 1. Accept team_id parameter for routing to specific teams