feat: Introduce last responding agent option to automation assign agent (#12326)
Introduce a `Last Responding Agent` options to assign_agents action in automations to cover the following use cases. - Assign conversations to first responding agent : ( automation message created at , if assignee is nil, assign last responding agent ) - Ensure conversations are not resolved with out an assignee : ( automation conversation resolved at : if assignee is nil, assign last responding agent ) and potential other cases. fixes: #1592
This commit is contained in:
@@ -92,7 +92,9 @@ describe('useAutomation', () => {
|
||||
case 'assign_team':
|
||||
return teams;
|
||||
case 'assign_agent':
|
||||
return agents;
|
||||
return options.addNoneToListFn
|
||||
? options.addNoneToListFn(options.agents)
|
||||
: options.agents;
|
||||
case 'send_email_to_team':
|
||||
return teams;
|
||||
case 'send_message':
|
||||
@@ -240,7 +242,11 @@ describe('useAutomation', () => {
|
||||
|
||||
expect(getActionDropdownValues('add_label')).toEqual(labels);
|
||||
expect(getActionDropdownValues('assign_team')).toEqual(teams);
|
||||
expect(getActionDropdownValues('assign_agent')).toEqual(agents);
|
||||
expect(getActionDropdownValues('assign_agent')).toEqual([
|
||||
{ id: 'nil', name: 'AUTOMATION.NONE_OPTION' },
|
||||
{ id: 'last_responding_agent', name: 'AUTOMATION.LAST_RESPONDING_AGENT' },
|
||||
...agents,
|
||||
]);
|
||||
expect(getActionDropdownValues('send_email_to_team')).toEqual(teams);
|
||||
expect(getActionDropdownValues('send_message')).toEqual([]);
|
||||
expect(getActionDropdownValues('add_sla')).toEqual(slaPolicies);
|
||||
|
||||
@@ -16,7 +16,20 @@ describe('useEditableAutomation', () => {
|
||||
|
||||
return [];
|
||||
}),
|
||||
getActionDropdownValues: vi.fn(),
|
||||
getActionDropdownValues: vi.fn(actionName => {
|
||||
if (actionName === 'assign_agent') {
|
||||
return [
|
||||
{ id: 'nil', name: 'None' },
|
||||
{
|
||||
id: 'last_responding_agent',
|
||||
name: 'Last Responding Agent',
|
||||
},
|
||||
{ id: 1, name: 'Agent 1' },
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,4 +64,35 @@ describe('useEditableAutomation', () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('rehydrates last responding agent as a selected action option', () => {
|
||||
const automation = {
|
||||
event_name: 'conversation_created',
|
||||
conditions: [],
|
||||
actions: [
|
||||
{
|
||||
action_name: 'assign_agent',
|
||||
action_params: ['last_responding_agent'],
|
||||
},
|
||||
],
|
||||
};
|
||||
const automationActionTypes = [
|
||||
{ key: 'assign_agent', inputType: 'search_select' },
|
||||
];
|
||||
|
||||
const { formatAutomation } = useEditableAutomation();
|
||||
const result = formatAutomation(automation, [], {}, automationActionTypes);
|
||||
|
||||
expect(result.actions).toEqual([
|
||||
{
|
||||
action_name: 'assign_agent',
|
||||
action_params: [
|
||||
{
|
||||
id: 'last_responding_agent',
|
||||
name: 'Last Responding Agent',
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,8 +121,19 @@ export default function useAutomationValues() {
|
||||
* @returns {Array} An array of action dropdown values.
|
||||
*/
|
||||
const getActionDropdownValues = type => {
|
||||
let agentsList = agents.value;
|
||||
if (type === 'assign_agent') {
|
||||
agentsList = [
|
||||
{
|
||||
id: 'last_responding_agent',
|
||||
name: t('AUTOMATION.LAST_RESPONDING_AGENT'),
|
||||
},
|
||||
...agentsList,
|
||||
];
|
||||
}
|
||||
|
||||
return getActionOptions({
|
||||
agents: agents.value,
|
||||
agents: agentsList,
|
||||
labels: labels.value,
|
||||
teams: teams.value,
|
||||
slaPolicies: slaPolicies.value,
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
"ATLEAST_ONE_ACTION_REQUIRED": "At least one action is required"
|
||||
},
|
||||
"NONE_OPTION": "None",
|
||||
"LAST_RESPONDING_AGENT": "Last Responding Agent",
|
||||
"EVENTS": {
|
||||
"CONVERSATION_CREATED": "Conversation Created",
|
||||
"CONVERSATION_UPDATED": "Conversation Updated",
|
||||
|
||||
Reference in New Issue
Block a user