From 80359d635cf5de8a10ee64097e41e5480cfef08b Mon Sep 17 00:00:00 2001 From: gopig93 Date: Fri, 1 Nov 2024 13:56:59 +0530 Subject: [PATCH] [FC-120763]Resolution SLA Advanced automation Impacts --- packages/marketplace-models/package.json | 2 +- packages/marketplace-models/src/types/PayloadData.ts | 6 ++++++ packages/rule-engine/package.json | 4 ++-- packages/rule-engine/src/models/rule.ts | 1 + packages/rule-engine/src/recommended/index.ts | 2 ++ .../trigger-actions/resolution-sla-breach.ts | 12 ++++++++++++ 6 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 packages/rule-engine/src/recommended/trigger-actions/resolution-sla-breach.ts diff --git a/packages/marketplace-models/package.json b/packages/marketplace-models/package.json index 06c1a7ce..fc7776f5 100644 --- a/packages/marketplace-models/package.json +++ b/packages/marketplace-models/package.json @@ -1,6 +1,6 @@ { "name": "@freshworks-jaya/marketplace-models", - "version": "0.1.38", + "version": "0.1.39", "description": "Provides type definitions for models in marketplace product events", "repository": "git@github.com:freshdesk/jaya-lib.git", "main": "lib/index.js", diff --git a/packages/marketplace-models/src/types/PayloadData.ts b/packages/marketplace-models/src/types/PayloadData.ts index 08a4cca7..8aad4ede 100644 --- a/packages/marketplace-models/src/types/PayloadData.ts +++ b/packages/marketplace-models/src/types/PayloadData.ts @@ -59,6 +59,11 @@ export enum ResponseDueType { ResponseDue = 'RESPONSE_DUE', } +export enum ResolutionDueType { + NO_RESOLUTION_DUE = 'NO_RESOLUTION_DUE', + RESOLUTION_DUE = 'RESOLUTION_DUE', +} + export enum ActorSubEntity { AgentGroupMapping = 'agent_group_mapping', AssignmentRule = 'assignment_rule', @@ -210,6 +215,7 @@ export interface ModelProperties { // eslint-disable-next-line @typescript-eslint/no-explicit-any properties: any; reopened_time: string | null; + resolution_due_type: ResolutionDueType; resolved_time: string | null; response_due_type: ResponseDueType; sla_policy_name?: string | null; diff --git a/packages/rule-engine/package.json b/packages/rule-engine/package.json index c85f59d8..7ea7e8de 100644 --- a/packages/rule-engine/package.json +++ b/packages/rule-engine/package.json @@ -1,6 +1,6 @@ { "name": "@freshworks-jaya/rule-engine", - "version": "0.18.6-beta-31", + "version": "0.18.6-beta-32", "description": "Provides methods to process rules in product events in marketplace app", "repository": "git@github.com:freshdesk/jaya-lib.git", "main": "lib/index.js", @@ -46,7 +46,7 @@ "dependencies": { "@freshworks-jaya/freshchat-api": "0.7.36-beta-2", "@freshworks-jaya/kairos-api": "^0.1.5", - "@freshworks-jaya/marketplace-models": "0.1.38", + "@freshworks-jaya/marketplace-models": "0.1.39", "@freshworks-jaya/utilities": "^1.0.0", "@google-cloud/logging": "^9.3.1", "axios": "^0.21.4", diff --git a/packages/rule-engine/src/models/rule.ts b/packages/rule-engine/src/models/rule.ts index d0642250..e0e6d247 100644 --- a/packages/rule-engine/src/models/rule.ts +++ b/packages/rule-engine/src/models/rule.ts @@ -32,6 +32,7 @@ export enum TriggerActionType { FirstSlaBreach = 'FIRST_SLA_BREACH', MessageCreate = 'MESSAGE_CREATE', NextSlaBreach = 'NEXT_SLA_BREACH', + ResolutionSlaBreach = 'RESOLUTION_SLA_BREACH', PrivateNoteCreate = 'PRIVATE_NOTE_CREATE', UpdateConversationProperty = 'UPDATE_CONVERSATION_PROPERTY', } diff --git a/packages/rule-engine/src/recommended/index.ts b/packages/rule-engine/src/recommended/index.ts index abd711c2..5c4a1c11 100644 --- a/packages/rule-engine/src/recommended/index.ts +++ b/packages/rule-engine/src/recommended/index.ts @@ -35,6 +35,7 @@ import triggerActionMessageCreate from './trigger-actions/message-create'; import triggerActionPrivateNoteCreate from './trigger-actions/private-note-create'; import triggerActionFirstSLABreach from './trigger-actions/first-sla-breach'; import triggerActionNextSLABreach from './trigger-actions/next-sla-breach'; +import triggerActionResolutionSLABreach from './trigger-actions/resolution-sla-breach'; import triggerActionCallEnded from './trigger-actions/call-ended'; import triggerActionUpdateConversationProperty from './trigger-actions/update-conversation-property'; @@ -200,6 +201,7 @@ const recommendedPlugins: RulePlugin[] = [ [TriggerActionType.PrivateNoteCreate]: triggerActionPrivateNoteCreate, [TriggerActionType.FirstSlaBreach]: triggerActionFirstSLABreach, [TriggerActionType.NextSlaBreach]: triggerActionNextSLABreach, + [TriggerActionType.ResolutionSlaBreach]: triggerActionResolutionSLABreach, [TriggerActionType.CallEnded]: triggerActionCallEnded, [TriggerActionType.UpdateConversationProperty]: triggerActionUpdateConversationProperty, }, diff --git a/packages/rule-engine/src/recommended/trigger-actions/resolution-sla-breach.ts b/packages/rule-engine/src/recommended/trigger-actions/resolution-sla-breach.ts new file mode 100644 index 00000000..90900efd --- /dev/null +++ b/packages/rule-engine/src/recommended/trigger-actions/resolution-sla-breach.ts @@ -0,0 +1,12 @@ +import { Event, ProductEventData, MessageType } from '@freshworks-jaya/marketplace-models'; +import { TriggerAction } from '../../models/rule'; + +export default (productEvent: Event, productEventData: ProductEventData, triggerAction: TriggerAction): boolean => { + return ( + productEvent === Event.ConversationUpdate && + !!productEventData.changes.model_changes && + !!productEventData.changes.model_changes?.sla_breach && + !!productEventData.changes.model_changes?.sla_breach[1] && + productEventData.conversation.resolution_due_type === 'RESOLUTION_DUE' + ); +};