mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-10 09:06:19 +00:00
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Sojan Jose <sojan@pepalo.com>
27 lines
752 B
Ruby
27 lines
752 B
Ruby
class Captain::Tools::AddContactNoteTool < Captain::Tools::BasePublicTool
|
|
description 'Add a note to a contact profile'
|
|
param :note, type: 'string', desc: 'The note content to add to the contact'
|
|
|
|
def perform(tool_context, note:)
|
|
contact = find_contact(tool_context.state)
|
|
return 'Contact not found' unless contact
|
|
|
|
return 'Note content is required' if note.blank?
|
|
|
|
log_tool_usage('add_contact_note', { contact_id: contact.id, note_length: note.length })
|
|
|
|
create_contact_note(contact, note)
|
|
"Note added successfully to contact #{contact.name} (ID: #{contact.id})"
|
|
end
|
|
|
|
private
|
|
|
|
def create_contact_note(contact, note)
|
|
contact.notes.create!(content: note)
|
|
end
|
|
|
|
def permissions
|
|
%w[contact_manage]
|
|
end
|
|
end
|