feat: Add an action on automation to change the priority (#6925)
This commit is contained in:
@@ -16,6 +16,29 @@ const MESSAGE_CONDITION_VALUES = [
|
||||
},
|
||||
];
|
||||
|
||||
export const PRIORITY_CONDITION_VALUES = [
|
||||
{
|
||||
id: 'nil',
|
||||
name: 'None',
|
||||
},
|
||||
{
|
||||
id: 'low',
|
||||
name: 'Low',
|
||||
},
|
||||
{
|
||||
id: 'medium',
|
||||
name: 'Medium',
|
||||
},
|
||||
{
|
||||
id: 'high',
|
||||
name: 'High',
|
||||
},
|
||||
{
|
||||
id: 'urgent',
|
||||
name: 'Urgent',
|
||||
},
|
||||
];
|
||||
|
||||
export const getCustomAttributeInputType = key => {
|
||||
const customAttributeMap = {
|
||||
date: 'date',
|
||||
@@ -103,6 +126,7 @@ export const getActionOptions = ({ agents, teams, labels, type }) => {
|
||||
assign_team: teams,
|
||||
send_email_to_team: teams,
|
||||
add_label: generateConditionOptions(labels, 'title'),
|
||||
change_priority: PRIORITY_CONDITION_VALUES,
|
||||
};
|
||||
return actionsMap[type];
|
||||
};
|
||||
|
||||
@@ -575,4 +575,9 @@ export const AUTOMATION_ACTION_TYPES = [
|
||||
label: 'Send a message',
|
||||
inputType: 'textarea',
|
||||
},
|
||||
{
|
||||
key: 'change_priority',
|
||||
label: 'Change Priority',
|
||||
inputType: 'search_select',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -33,7 +33,7 @@ class AutomationRule < ApplicationRecord
|
||||
CONDITIONS_ATTRS = %w[content email country_code status message_type browser_language assignee_id team_id referer city company inbox_id
|
||||
mail_subject phone_number conversation_language].freeze
|
||||
ACTIONS_ATTRS = %w[send_message add_label send_email_to_team assign_team assign_agent send_webhook_event mute_conversation send_attachment
|
||||
change_status resolve_conversation snooze_conversation send_email_transcript].freeze
|
||||
change_status resolve_conversation snooze_conversation change_priority send_email_transcript].freeze
|
||||
|
||||
def file_base_data
|
||||
files.map do |file|
|
||||
|
||||
@@ -19,6 +19,10 @@ class ActionService
|
||||
@conversation.update!(status: status[0])
|
||||
end
|
||||
|
||||
def change_priority(priority)
|
||||
@conversation.update!(priority: (priority[0] == 'nil' ? nil : priority[0]))
|
||||
end
|
||||
|
||||
def add_label(labels)
|
||||
return if labels.empty?
|
||||
|
||||
|
||||
@@ -11,5 +11,21 @@ describe ::ActionService do
|
||||
expect(conversation.reload.status).to eq('resolved')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#change_priority' do
|
||||
let(:conversation) { create(:conversation) }
|
||||
let(:action_service) { described_class.new(conversation) }
|
||||
|
||||
it 'changes the priority of the conversation to medium' do
|
||||
action_service.change_priority(['medium'])
|
||||
expect(conversation.reload.priority).to eq('medium')
|
||||
end
|
||||
|
||||
it 'changes the priority of the conversation to nil' do
|
||||
action_service.change_priority(['nil'])
|
||||
expect(conversation.reload.priority).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: Expand this test suite
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user