Show captain messages under the name of the assistant which generated the message. - Add support for `Captain::Assistant` sender type - Add push_event_data for captain_assistants - Add activity message handler for captain_assistants - Update UI to show captain messages under the name of the assistant - Fix the issue where openAI errors when image is sent - Add support for custom name of the assistant --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
33 lines
1.0 KiB
Ruby
33 lines
1.0 KiB
Ruby
class Captain::InboxPendingConversationsResolutionJob < ApplicationJob
|
|
queue_as :low
|
|
|
|
def perform(inbox)
|
|
Current.executed_by = inbox.captain_assistant
|
|
|
|
resolvable_conversations = inbox.conversations.pending.where('last_activity_at < ? ', Time.now.utc - 1.hour).limit(Limits::BULK_ACTIONS_LIMIT)
|
|
resolvable_conversations.each do |conversation|
|
|
create_outgoing_message(conversation, inbox)
|
|
conversation.resolved!
|
|
end
|
|
ensure
|
|
Current.reset
|
|
end
|
|
|
|
private
|
|
|
|
def create_outgoing_message(conversation, inbox)
|
|
I18n.with_locale(inbox.account.locale) do
|
|
resolution_message = inbox.captain_assistant.config['resolution_message']
|
|
conversation.messages.create!(
|
|
{
|
|
message_type: :outgoing,
|
|
account_id: conversation.account_id,
|
|
inbox_id: conversation.inbox_id,
|
|
content: resolution_message.presence || I18n.t('conversations.activity.auto_resolution_message'),
|
|
sender: inbox.captain_assistant
|
|
}
|
|
)
|
|
end
|
|
end
|
|
end
|