@botonic/plugin-flow-builder 0.34.2 → 0.35.0-alpha.1
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/fallback.d.ts +1 -1
- package/lib/cjs/action/fallback.js +2 -2
- package/lib/cjs/action/fallback.js.map +1 -1
- package/lib/cjs/action/first-interaction.js +5 -5
- package/lib/cjs/action/first-interaction.js.map +1 -1
- package/lib/cjs/action/index.d.ts +1 -1
- package/lib/cjs/action/index.js +2 -3
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.d.ts +1 -1
- package/lib/cjs/action/knowledge-bases.js +2 -2
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/action/payload.d.ts +1 -1
- package/lib/cjs/action/payload.js +2 -2
- package/lib/cjs/action/payload.js.map +1 -1
- package/lib/cjs/api.d.ts +6 -6
- package/lib/cjs/api.js +24 -24
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/content-fields/flow-handoff.js +2 -2
- package/lib/cjs/content-fields/flow-handoff.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/common.d.ts +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.d.ts +0 -1
- package/lib/cjs/content-fields/hubtype-fields/index.js +0 -1
- package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +0 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.js +0 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +1 -2
- package/lib/cjs/functions/conditional-country.js +1 -1
- package/lib/cjs/functions/conditional-country.js.map +1 -1
- package/lib/cjs/helpers.d.ts +2 -4
- package/lib/cjs/helpers.js +8 -5
- package/lib/cjs/helpers.js.map +1 -1
- package/lib/cjs/index.d.ts +6 -7
- package/lib/cjs/index.js +14 -17
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/tracking.d.ts +0 -1
- package/lib/cjs/tracking.js +0 -1
- package/lib/cjs/tracking.js.map +1 -1
- package/lib/cjs/types.d.ts +6 -8
- package/lib/cjs/types.js.map +1 -1
- package/lib/cjs/user-input/index.d.ts +2 -2
- package/lib/cjs/user-input/index.js +0 -8
- package/lib/cjs/user-input/index.js.map +1 -1
- package/lib/cjs/utils.d.ts +1 -2
- package/lib/cjs/utils.js +2 -2
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/action/fallback.d.ts +1 -1
- package/lib/esm/action/fallback.js +2 -2
- package/lib/esm/action/fallback.js.map +1 -1
- package/lib/esm/action/first-interaction.js +5 -5
- package/lib/esm/action/first-interaction.js.map +1 -1
- package/lib/esm/action/index.d.ts +1 -1
- package/lib/esm/action/index.js +2 -3
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/knowledge-bases.d.ts +1 -1
- package/lib/esm/action/knowledge-bases.js +2 -2
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/action/payload.d.ts +1 -1
- package/lib/esm/action/payload.js +2 -2
- package/lib/esm/action/payload.js.map +1 -1
- package/lib/esm/api.d.ts +6 -6
- package/lib/esm/api.js +24 -24
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/content-fields/flow-handoff.js +2 -2
- package/lib/esm/content-fields/flow-handoff.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/common.d.ts +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.d.ts +0 -1
- package/lib/esm/content-fields/hubtype-fields/index.js +0 -1
- package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +0 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.js +0 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +1 -2
- package/lib/esm/functions/conditional-country.js +1 -1
- package/lib/esm/functions/conditional-country.js.map +1 -1
- package/lib/esm/helpers.d.ts +2 -4
- package/lib/esm/helpers.js +8 -5
- package/lib/esm/helpers.js.map +1 -1
- package/lib/esm/index.d.ts +6 -7
- package/lib/esm/index.js +14 -17
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/tracking.d.ts +0 -1
- package/lib/esm/tracking.js +0 -1
- package/lib/esm/tracking.js.map +1 -1
- package/lib/esm/types.d.ts +6 -8
- package/lib/esm/types.js.map +1 -1
- package/lib/esm/user-input/index.d.ts +2 -2
- package/lib/esm/user-input/index.js +0 -8
- package/lib/esm/user-input/index.js.map +1 -1
- package/lib/esm/utils.d.ts +1 -2
- package/lib/esm/utils.js +3 -3
- package/lib/esm/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/action/fallback.ts +2 -5
- package/src/action/first-interaction.ts +3 -6
- package/src/action/index.tsx +2 -3
- package/src/action/knowledge-bases.ts +8 -8
- package/src/action/payload.ts +1 -2
- package/src/api.ts +33 -43
- package/src/content-fields/flow-handoff.tsx +2 -2
- package/src/content-fields/hubtype-fields/common.ts +1 -0
- package/src/content-fields/hubtype-fields/index.ts +0 -1
- package/src/content-fields/hubtype-fields/node-types.ts +0 -1
- package/src/content-fields/hubtype-fields/nodes.ts +0 -2
- package/src/functions/conditional-country.ts +1 -1
- package/src/helpers.ts +17 -11
- package/src/index.ts +19 -20
- package/src/tracking.ts +0 -1
- package/src/types.ts +22 -10
- package/src/user-input/index.ts +1 -11
- package/src/utils.ts +3 -7
- package/lib/cjs/content-fields/hubtype-fields/intent.d.ts +0 -10
- package/lib/cjs/content-fields/hubtype-fields/intent.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/intent.js.map +0 -1
- package/lib/cjs/user-input/intent.d.ts +0 -4
- package/lib/cjs/user-input/intent.js +0 -45
- package/lib/cjs/user-input/intent.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/intent.d.ts +0 -10
- package/lib/esm/content-fields/hubtype-fields/intent.js +0 -2
- package/lib/esm/content-fields/hubtype-fields/intent.js.map +0 -1
- package/lib/esm/user-input/intent.d.ts +0 -4
- package/lib/esm/user-input/intent.js +0 -41
- package/lib/esm/user-input/intent.js.map +0 -1
- package/src/content-fields/hubtype-fields/intent.ts +0 -12
- package/src/user-input/intent.ts +0 -59
package/src/user-input/intent.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { NluType } from '@botonic/core'
|
|
2
|
-
import { ActionRequest } from '@botonic/react'
|
|
3
|
-
|
|
4
|
-
import { FlowBuilderApi } from '../api'
|
|
5
|
-
import { HtIntentNode } from '../content-fields/hubtype-fields'
|
|
6
|
-
import { EventAction, trackEvent } from '../tracking'
|
|
7
|
-
|
|
8
|
-
export async function getIntentNodeByInput(
|
|
9
|
-
cmsApi: FlowBuilderApi,
|
|
10
|
-
locale: string,
|
|
11
|
-
request: ActionRequest
|
|
12
|
-
): Promise<HtIntentNode | undefined> {
|
|
13
|
-
const intentNode = cmsApi.getIntentNode(request.input, locale)
|
|
14
|
-
|
|
15
|
-
if (request.input.confidence && request.input.intent && intentNode) {
|
|
16
|
-
await trackIntentEvent(request, intentNode)
|
|
17
|
-
|
|
18
|
-
if (isIntentValid(intentNode, request, cmsApi)) {
|
|
19
|
-
const targetPayload = cmsApi.getPayload(intentNode.target)
|
|
20
|
-
|
|
21
|
-
request.input.nluResolution = {
|
|
22
|
-
type: NluType.Intent,
|
|
23
|
-
matchedValue: request.input.intent,
|
|
24
|
-
payload: targetPayload,
|
|
25
|
-
}
|
|
26
|
-
return intentNode
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return undefined
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function trackIntentEvent(
|
|
34
|
-
request: ActionRequest,
|
|
35
|
-
intentNode: HtIntentNode
|
|
36
|
-
) {
|
|
37
|
-
const eventArgs = {
|
|
38
|
-
nluIntentLabel: request.input.intent,
|
|
39
|
-
nluIntentConfidence: request.input.confidence,
|
|
40
|
-
nluIntentThreshold: intentNode?.content.confidence,
|
|
41
|
-
nluIntentMessageId: request.input.message_id,
|
|
42
|
-
userInput: request.input.data,
|
|
43
|
-
flowThreadId: request.session.flow_thread_id,
|
|
44
|
-
flowId: intentNode.flow_id,
|
|
45
|
-
flowNodeId: intentNode.id,
|
|
46
|
-
}
|
|
47
|
-
await trackEvent(request, EventAction.Intent, eventArgs)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function isIntentValid(
|
|
51
|
-
intentNode: HtIntentNode,
|
|
52
|
-
request: ActionRequest,
|
|
53
|
-
cmsApi: FlowBuilderApi
|
|
54
|
-
) {
|
|
55
|
-
return (
|
|
56
|
-
request.input.confidence &&
|
|
57
|
-
cmsApi.hasMetConfidenceThreshold(intentNode, request.input.confidence)
|
|
58
|
-
)
|
|
59
|
-
}
|