@botonic/plugin-flow-builder 0.27.5 → 0.27.7-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/action/first-interaction.d.ts +3 -0
- package/lib/cjs/action/first-interaction.js +72 -0
- package/lib/cjs/action/first-interaction.js.map +1 -0
- package/lib/cjs/action/index.js +10 -16
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.js +7 -16
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/action/payload.d.ts +3 -0
- package/lib/cjs/action/payload.js +17 -0
- package/lib/cjs/action/payload.js.map +1 -0
- package/lib/cjs/index.js +1 -3
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/tracking.d.ts +0 -14
- package/lib/cjs/tracking.js +13 -14
- package/lib/cjs/tracking.js.map +1 -1
- package/lib/cjs/user-input/index.js +17 -5
- package/lib/cjs/user-input/index.js.map +1 -1
- package/lib/cjs/utils.d.ts +2 -1
- package/lib/cjs/utils.js +6 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/action/first-interaction.d.ts +3 -0
- package/lib/esm/action/first-interaction.js +68 -0
- package/lib/esm/action/first-interaction.js.map +1 -0
- package/lib/esm/action/index.js +9 -15
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/knowledge-bases.js +7 -16
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/action/payload.d.ts +3 -0
- package/lib/esm/action/payload.js +13 -0
- package/lib/esm/action/payload.js.map +1 -0
- package/lib/esm/index.js +2 -4
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/tracking.d.ts +0 -14
- package/lib/esm/tracking.js +13 -13
- package/lib/esm/tracking.js.map +1 -1
- package/lib/esm/user-input/index.js +17 -5
- package/lib/esm/user-input/index.js.map +1 -1
- package/lib/esm/utils.d.ts +2 -1
- package/lib/esm/utils.js +4 -0
- package/lib/esm/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/action/first-interaction.ts +111 -0
- package/src/action/index.tsx +9 -22
- package/src/action/knowledge-bases.ts +9 -16
- package/src/action/payload.ts +20 -0
- package/src/index.ts +2 -3
- package/src/tracking.ts +13 -13
- package/src/user-input/index.ts +21 -6
- package/src/utils.ts +5 -1
package/src/tracking.ts
CHANGED
|
@@ -37,19 +37,20 @@ export async function trackFlowContent(
|
|
|
37
37
|
) {
|
|
38
38
|
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
|
|
39
39
|
const cmsApi = flowBuilderPlugin.cmsApi
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
for (const content of contents) {
|
|
41
|
+
const nodeContent = cmsApi.getNodeById<HtNodeWithContent>(content.id)
|
|
42
|
+
const eventArgs = getContentEventArgs(request, {
|
|
43
|
+
code: nodeContent.code,
|
|
44
|
+
flowId: nodeContent.flow_id,
|
|
45
|
+
flowName: flowBuilderPlugin.getFlowName(nodeContent.flow_id),
|
|
46
|
+
id: nodeContent.id,
|
|
47
|
+
isMeaningful: nodeContent.is_meaningful ?? false,
|
|
48
|
+
})
|
|
49
|
+
await trackEvent(request, EventAction.FlowNode, eventArgs)
|
|
50
|
+
}
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
function getContentEventArgs(
|
|
53
54
|
request: ActionRequest,
|
|
54
55
|
contentInfo: {
|
|
55
56
|
code: string
|
|
@@ -59,12 +60,11 @@ export function getContentEventArgs(
|
|
|
59
60
|
isMeaningful: boolean
|
|
60
61
|
}
|
|
61
62
|
) {
|
|
62
|
-
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
|
|
63
63
|
const flowThreadId = request.session.flow_thread_id ?? uuid()
|
|
64
64
|
return {
|
|
65
65
|
flowThreadId,
|
|
66
66
|
flowId: contentInfo.flowId,
|
|
67
|
-
flowName:
|
|
67
|
+
flowName: contentInfo.flowName,
|
|
68
68
|
flowNodeId: contentInfo.id,
|
|
69
69
|
flowNodeContentId: contentInfo.code,
|
|
70
70
|
flowNodeIsMeaningful: contentInfo.isMeaningful,
|
package/src/user-input/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
HtKeywordNode,
|
|
8
8
|
HtSmartIntentNode,
|
|
9
9
|
} from '../content-fields/hubtype-fields'
|
|
10
|
+
import { inputHasTextData } from '../utils'
|
|
10
11
|
import { getIntentNodeByInput } from './intent'
|
|
11
12
|
import { KeywordMatcher } from './keyword'
|
|
12
13
|
import { SmartIntentsApi, SmartIntentsInferenceConfig } from './smart-intent'
|
|
@@ -17,25 +18,39 @@ export async function getNodeByUserInput(
|
|
|
17
18
|
request: ActionRequest,
|
|
18
19
|
smartIntentsConfig: SmartIntentsInferenceConfig
|
|
19
20
|
): Promise<HtSmartIntentNode | HtIntentNode | HtKeywordNode | undefined> {
|
|
20
|
-
if (request.input
|
|
21
|
+
if (inputHasTextData(request.input)) {
|
|
21
22
|
const keywordMatcher = new KeywordMatcher({
|
|
22
23
|
cmsApi,
|
|
23
24
|
locale,
|
|
24
25
|
request,
|
|
25
26
|
})
|
|
26
|
-
const keywordNode = await keywordMatcher.getNodeByInput(request.input.data)
|
|
27
|
-
if (keywordNode)
|
|
28
|
-
|
|
27
|
+
const keywordNode = await keywordMatcher.getNodeByInput(request.input.data!)
|
|
28
|
+
if (keywordNode) {
|
|
29
|
+
console.log('Keyword node found:', keywordNode.content.title, {
|
|
30
|
+
keywordNode,
|
|
31
|
+
})
|
|
32
|
+
return keywordNode
|
|
33
|
+
}
|
|
29
34
|
const smartIntentsApi = new SmartIntentsApi(
|
|
30
35
|
cmsApi,
|
|
31
36
|
request,
|
|
32
37
|
smartIntentsConfig
|
|
33
38
|
)
|
|
34
39
|
const smartIntentNode = await smartIntentsApi.getNodeByInput()
|
|
35
|
-
if (smartIntentNode)
|
|
40
|
+
if (smartIntentNode) {
|
|
41
|
+
console.log('Smart intent node found:', smartIntentNode.content.title, {
|
|
42
|
+
smartIntentNode,
|
|
43
|
+
})
|
|
44
|
+
return smartIntentNode
|
|
45
|
+
}
|
|
36
46
|
|
|
37
47
|
const intentNode = await getIntentNodeByInput(cmsApi, locale, request)
|
|
38
|
-
if (intentNode)
|
|
48
|
+
if (intentNode) {
|
|
49
|
+
console.log('Intent node found:', intentNode.content.title, {
|
|
50
|
+
intentNode,
|
|
51
|
+
})
|
|
52
|
+
return intentNode
|
|
53
|
+
}
|
|
39
54
|
}
|
|
40
55
|
return undefined
|
|
41
56
|
}
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Session } from '@botonic/core'
|
|
1
|
+
import { INPUT, Input, Session } from '@botonic/core'
|
|
2
2
|
import { ActionRequest } from '@botonic/react'
|
|
3
3
|
|
|
4
4
|
import { BotonicPluginFlowBuilderOptions, ProcessEnvNodeEnvs } from './types'
|
|
@@ -47,3 +47,7 @@ function resolveObjectKey(object: any, key: string): any {
|
|
|
47
47
|
}
|
|
48
48
|
return undefined
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
export function inputHasTextData(input: Input): boolean {
|
|
52
|
+
return input.data !== undefined && input.type === INPUT.TEXT
|
|
53
|
+
}
|