Skip to content

Commit 336a7c0

Browse files
authored
feat(plugin-flow-builder): remove all logic related with intents babel #BLT-3010 (#3010)
## Description Remove all logic related with old intents babel
1 parent 71bb95f commit 336a7c0

File tree

10 files changed

+3
-146
lines changed

10 files changed

+3
-146
lines changed

packages/botonic-plugin-flow-builder/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ All notable changes to Botonic will be documented in this file.
1818

1919
### Changed
2020

21+
- [PR-3010](https://github.com/hubtype/botonic/pull/3010): Remove all logic related with intents babel.
22+
2123
### Fixed
2224

2325
</details>

packages/botonic-plugin-flow-builder/src/api.ts

-38
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
HtFallbackNode,
88
HtFlowBuilderData,
99
HtGoToFlow,
10-
HtIntentNode,
1110
HtKeywordNode,
1211
HtNodeComponent,
1312
HtNodeLink,
@@ -125,49 +124,12 @@ export class FlowBuilderApi {
125124
: undefined
126125
}
127126

128-
getIntentNode(input: Input, locale: string): HtIntentNode | undefined {
129-
try {
130-
const intentsNodes = this.flow.nodes.filter(
131-
node => node.type === HtNodeWithContentType.INTENT
132-
) as HtIntentNode[]
133-
const inputIntent = input.intent
134-
if (inputIntent) {
135-
return intentsNodes.find(
136-
node =>
137-
inputIntent && this.nodeContainsIntent(node, inputIntent, locale)
138-
)
139-
}
140-
} catch (error) {
141-
console.error(`Error getting node by intent '${input.intent}': `, error)
142-
}
143-
144-
return undefined
145-
}
146-
147127
getSmartIntentNodes(): HtSmartIntentNode[] {
148128
return this.flow.nodes.filter(
149129
node => node.type === HtNodeWithContentType.SMART_INTENT
150130
) as HtSmartIntentNode[]
151131
}
152132

153-
private nodeContainsIntent(
154-
node: HtIntentNode,
155-
intent: string,
156-
locale: string
157-
): boolean {
158-
return node.content.intents.some(
159-
i => i.locale === locale && i.values.includes(intent)
160-
)
161-
}
162-
163-
hasMetConfidenceThreshold(
164-
node: HtIntentNode,
165-
predictedConfidence: number
166-
): boolean {
167-
const nodeConfidence = node.content.confidence / 100
168-
return predictedConfidence >= nodeConfidence
169-
}
170-
171133
getKeywordNodes(): HtKeywordNode[] {
172134
return this.flow.nodes.filter(
173135
node => node.type === HtNodeWithContentType.KEYWORD

packages/botonic-plugin-flow-builder/src/content-fields/hubtype-fields/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export * from './function'
77
export * from './go-to-flow'
88
export * from './handoff'
99
export * from './image'
10-
export * from './intent'
1110
export * from './keyword'
1211
export * from './knowledge-base'
1312
export * from './node-types'

packages/botonic-plugin-flow-builder/src/content-fields/hubtype-fields/intent.ts

-12
This file was deleted.

packages/botonic-plugin-flow-builder/src/content-fields/hubtype-fields/node-types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export enum HtNodeWithContentType {
44
IMAGE = 'image',
55
TEXT = 'text',
66
KEYWORD = 'keyword',
7-
INTENT = 'intent',
87
SMART_INTENT = 'smart-intent',
98
FUNCTION = 'function',
109
FALLBACK = 'fallback',

packages/botonic-plugin-flow-builder/src/content-fields/hubtype-fields/nodes.ts

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { HtFunctionNode } from './function'
55
import { HtGoToFlow } from './go-to-flow'
66
import { HtHandoffNode } from './handoff'
77
import { HtImageNode } from './image'
8-
import { HtIntentNode } from './intent'
98
import { HtKeywordNode } from './keyword'
109
import { HtKnowledgeBaseNode } from './knowledge-base'
1110
import { HtPayloadNode } from './payload'
@@ -23,7 +22,6 @@ export type HtNodeWithContent =
2322
| HtCarouselNode
2423
| HtHandoffNode
2524
| HtKeywordNode
26-
| HtIntentNode
2725
| HtFunctionNode
2826
| HtFallbackNode
2927
| HtWhatsappButtonListNode

packages/botonic-plugin-flow-builder/src/tracking.ts

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { getFlowBuilderPlugin } from './helpers'
1111
export enum EventAction {
1212
FlowNode = 'flow_node',
1313
Keyword = 'nlu_keyword',
14-
Intent = 'nlu_intent',
1514
IntentSmart = 'nlu_intent_smart',
1615
Knowledgebase = 'knowledgebase',
1716
Fallback = 'fallback',

packages/botonic-plugin-flow-builder/src/user-input/index.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { ActionRequest } from '@botonic/react'
22

33
import { FlowBuilderApi } from '../api'
44
import {
5-
HtIntentNode,
65
HtKeywordNode,
76
HtSmartIntentNode,
87
} from '../content-fields/hubtype-fields'
@@ -11,7 +10,6 @@ import {
1110
isKeywordsAllowed,
1211
isSmartIntentsAllowed,
1312
} from '../utils'
14-
import { getIntentNodeByInput } from './intent'
1513
import { KeywordMatcher } from './keyword'
1614
import { SmartIntentsApi, SmartIntentsInferenceConfig } from './smart-intent'
1715

@@ -20,7 +18,7 @@ export async function getNodeByUserInput(
2018
locale: string,
2119
request: ActionRequest,
2220
smartIntentsConfig: SmartIntentsInferenceConfig
23-
): Promise<HtSmartIntentNode | HtIntentNode | HtKeywordNode | undefined> {
21+
): Promise<HtSmartIntentNode | HtKeywordNode | undefined> {
2422
if (inputHasTextData(request.input)) {
2523
if (isKeywordsAllowed(request)) {
2624
const keywordMatcher = new KeywordMatcher({
@@ -47,14 +45,6 @@ export async function getNodeByUserInput(
4745
return smartIntentNode
4846
}
4947
}
50-
51-
// TODO: Remove this because frontend no allow create intents babel
52-
if (isSmartIntentsAllowed(request)) {
53-
const intentNode = await getIntentNodeByInput(cmsApi, locale, request)
54-
if (intentNode) {
55-
return intentNode
56-
}
57-
}
5848
}
5949

6050
return undefined

packages/botonic-plugin-flow-builder/src/user-input/intent.ts

-59
This file was deleted.

packages/botonic-plugin-flow-builder/tests/first-interaction.test.ts

-21
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,6 @@ describe('Check the contents returned by the plugin in first interaction', () =>
5454
expect(contents.length).toBe(3)
5555
expect((contents[2] as FlowText).text).toBe('All types of messages')
5656
})
57-
58-
test('The start contents are displayed followed by more contents obtained by matching an intent', async () => {
59-
const { contents } = await createFlowBuilderPluginAndGetContents({
60-
flowBuilderOptions: { flow: basicFlow },
61-
requestArgs: {
62-
input: {
63-
data: 'I want to select my seat ',
64-
type: INPUT.TEXT,
65-
intent: 'select a seat',
66-
confidence: 0.8,
67-
},
68-
isFirstInteraction: true,
69-
},
70-
})
71-
72-
expect((contents[0] as FlowText).text).toBe('Welcome message')
73-
expect(contents.length).toBe(3)
74-
expect((contents[2] as FlowText).text).toBe(
75-
'Message explaining how to select a seat'
76-
)
77-
})
7857
})
7958

8059
describe('Check the contents returned by the plugin in first interaction with smart intent', () => {

0 commit comments

Comments
 (0)