Skip to content

Commit

Permalink
Merge branch 'master' into FC-129678
Browse files Browse the repository at this point in the history
  • Loading branch information
ShashaankKrishnatray authored Sep 25, 2024
2 parents 802fe8a + 1cc5c01 commit 8c4dd38
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/rule-engine/src/models/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export enum ConditionKey {
UserName = 'USER_NAME',
UserPhone = 'USER_PHONE',
UserProperty = 'USER_PROPERTY',
ChannelType = 'CHANNEL_TYPE'
}
export enum ConditionOperator {
After = 'AFTER',
Expand Down
21 changes: 21 additions & 0 deletions packages/rule-engine/src/recommended/conditions/channel-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ProductEventData } from '@freshworks-jaya/marketplace-models';
import { Condition } from '../../models/rule';
import { Utils } from '../../Utils';
import { Integrations, RuleEngineOptions } from '../../models/rule-engine';

export default (
condition: Condition,
productEventData: ProductEventData,
integrations: Integrations,
options: RuleEngineOptions,
ruleAlias: string,
): Promise<void> => {
return Utils.evaluateCondition(
condition.operator,
productEventData?.conversation?.source || productEventData?.message?.source ||'',
condition.value as string,
integrations,
options,
ruleAlias,
);
};
2 changes: 2 additions & 0 deletions packages/rule-engine/src/recommended/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import conditionCallStatus from './conditions/call-status';
import conditionCallType from './conditions/call-type';
import conditionConversationProperty from './conditions/conversation-property';
import conditionEmailBody from './conditions/email-body';
import conditionChannelType from './conditions/channel-type';

// Import all dynamic placeholders
import dynamicPlaceholderAverageWaitTime from './dynamic-placeholders/average-wait-time';
Expand Down Expand Up @@ -145,6 +146,7 @@ const recommendedPlugins: RulePlugin[] = [
[ConditionKey.CallStatus]: conditionCallStatus,
[ConditionKey.CallType]: conditionCallType,
[ConditionKey.EmailBody]: conditionEmailBody,
[ConditionKey.ChannelType]: conditionChannelType,
},
dynamicPlaceholders: {
'conversation.url': dynamicPlaceholderConversationUrl,
Expand Down

0 comments on commit 8c4dd38

Please sign in to comment.