Skip to content

Commit

Permalink
Merge pull request #114 from freshworks/CXBU_8394
Browse files Browse the repository at this point in the history
CXBU-8394 : Channel and conversation topic changes
  • Loading branch information
ShashaankKrishnatray authored Sep 24, 2024
2 parents 7d1805c + 655a11b commit 1cc5c01
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/rule-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freshworks-jaya/rule-engine",
"version": "0.18.3",
"version": "0.18.6-beta-1",
"description": "Provides methods to process rules in product events in marketplace app",
"repository": "[email protected]:freshdesk/jaya-lib.git",
"main": "lib/index.js",
Expand Down
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 1cc5c01

Please sign in to comment.