@botonic/plugin-flow-builder 0.29.0 → 0.30.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/first-interaction.js +0 -4
- package/lib/cjs/action/first-interaction.js.map +1 -1
- package/lib/cjs/action/index.d.ts +2 -1
- package/lib/cjs/action/index.js +10 -4
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/payload.d.ts +1 -1
- package/lib/cjs/action/payload.js +6 -4
- package/lib/cjs/action/payload.js.map +1 -1
- package/lib/cjs/api.js +0 -3
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/constants.d.ts +0 -1
- package/lib/cjs/constants.js +1 -2
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/content-fields/flow-bot-action.d.ts +11 -0
- package/lib/cjs/content-fields/flow-bot-action.js +22 -0
- package/lib/cjs/content-fields/flow-bot-action.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/bot-action.d.ts +2 -2
- package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +3 -3
- package/lib/cjs/content-fields/hubtype-fields/node-types.js +1 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +2 -2
- package/lib/cjs/content-fields/index.d.ts +3 -2
- package/lib/cjs/content-fields/index.js +3 -1
- package/lib/cjs/content-fields/index.js.map +1 -1
- package/lib/cjs/index.d.ts +0 -3
- package/lib/cjs/index.js +7 -11
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/action/first-interaction.js +1 -5
- package/lib/esm/action/first-interaction.js.map +1 -1
- package/lib/esm/action/index.d.ts +2 -1
- package/lib/esm/action/index.js +10 -4
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/payload.d.ts +1 -1
- package/lib/esm/action/payload.js +6 -4
- package/lib/esm/action/payload.js.map +1 -1
- package/lib/esm/api.js +1 -4
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/constants.d.ts +0 -1
- package/lib/esm/constants.js +0 -1
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/content-fields/flow-bot-action.d.ts +11 -0
- package/lib/esm/content-fields/flow-bot-action.js +18 -0
- package/lib/esm/content-fields/flow-bot-action.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/bot-action.d.ts +2 -2
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +3 -3
- package/lib/esm/content-fields/hubtype-fields/node-types.js +1 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +2 -2
- package/lib/esm/content-fields/index.d.ts +3 -2
- package/lib/esm/content-fields/index.js +2 -1
- package/lib/esm/content-fields/index.js.map +1 -1
- package/lib/esm/index.d.ts +0 -3
- package/lib/esm/index.js +8 -11
- package/lib/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/src/action/first-interaction.ts +1 -7
- package/src/action/index.tsx +19 -4
- package/src/action/payload.ts +5 -3
- package/src/api.ts +1 -9
- package/src/constants.ts +0 -1
- package/src/content-fields/flow-bot-action.tsx +31 -0
- package/src/content-fields/hubtype-fields/bot-action.ts +2 -2
- package/src/content-fields/hubtype-fields/node-types.ts +1 -1
- package/src/content-fields/hubtype-fields/nodes.ts +2 -5
- package/src/content-fields/index.ts +3 -0
- package/src/index.ts +11 -17
package/src/index.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { v4 as uuid } from 'uuid'
|
|
|
4
4
|
|
|
5
5
|
import { FlowBuilderApi } from './api'
|
|
6
6
|
import {
|
|
7
|
-
BOT_ACTION_PAYLOAD_PREFIX,
|
|
8
7
|
FLOW_BUILDER_API_URL_PROD,
|
|
9
8
|
SEPARATOR,
|
|
10
9
|
SOURCE_INFO_SEPARATOR,
|
|
11
10
|
} from './constants'
|
|
12
11
|
import {
|
|
12
|
+
FlowBotAction,
|
|
13
13
|
FlowCarousel,
|
|
14
14
|
FlowContent,
|
|
15
15
|
FlowHandoff,
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
FlowWhatsappCtaUrlButtonNode,
|
|
22
22
|
} from './content-fields'
|
|
23
23
|
import {
|
|
24
|
-
HtBotActionNode,
|
|
25
24
|
HtFlowBuilderData,
|
|
26
25
|
HtFunctionArgument,
|
|
27
26
|
HtFunctionArguments,
|
|
@@ -43,7 +42,6 @@ import { SmartIntentsInferenceConfig } from './user-input/smart-intent'
|
|
|
43
42
|
import { inputHasTextData, resolveGetAccessToken } from './utils'
|
|
44
43
|
export default class BotonicPluginFlowBuilder implements Plugin {
|
|
45
44
|
public cmsApi: FlowBuilderApi
|
|
46
|
-
private flowUrl: string
|
|
47
45
|
private flow?: HtFlowBuilderData
|
|
48
46
|
private functions: Record<any, any>
|
|
49
47
|
private currentRequest: PluginPreRequest
|
|
@@ -112,12 +110,6 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
112
110
|
private updateRequestBeforeRoutes(request: PluginPreRequest) {
|
|
113
111
|
if (request.input.payload) {
|
|
114
112
|
request.input.payload = this.removeSourceSufix(request.input.payload)
|
|
115
|
-
|
|
116
|
-
if (request.input.payload.startsWith(BOT_ACTION_PAYLOAD_PREFIX)) {
|
|
117
|
-
request.input.payload = this.replaceBotActionPayload(
|
|
118
|
-
request.input.payload
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
113
|
}
|
|
122
114
|
}
|
|
123
115
|
|
|
@@ -125,12 +117,6 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
125
117
|
return payload.split(SOURCE_INFO_SEPARATOR)[0]
|
|
126
118
|
}
|
|
127
119
|
|
|
128
|
-
public replaceBotActionPayload(payload: string): string {
|
|
129
|
-
const botActionId = payload.split(SEPARATOR)[1]
|
|
130
|
-
const botActionNode = this.cmsApi.getNodeById<HtBotActionNode>(botActionId)
|
|
131
|
-
return this.cmsApi.createPayloadWithParams(botActionNode)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
120
|
async getContentsByContentID(
|
|
135
121
|
contentID: string,
|
|
136
122
|
locale: string,
|
|
@@ -178,8 +164,13 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
178
164
|
if (content) {
|
|
179
165
|
contents.push(content)
|
|
180
166
|
}
|
|
181
|
-
// TODO: prevent infinite recursive calls
|
|
182
167
|
|
|
168
|
+
// If node is BOT_ACTION not add more contents to render, next nodes render after execute action
|
|
169
|
+
if (node.type === HtNodeWithContentType.BOT_ACTION) {
|
|
170
|
+
return contents
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// TODO: prevent infinite recursive calls
|
|
183
174
|
if (node.follow_up) {
|
|
184
175
|
return this.getContentsById(node.follow_up.id, resolvedLocale, contents)
|
|
185
176
|
}
|
|
@@ -217,6 +208,10 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
217
208
|
|
|
218
209
|
case HtNodeWithContentType.KNOWLEDGE_BASE:
|
|
219
210
|
return FlowKnowledgeBase.fromHubtypeCMS(hubtypeContent)
|
|
211
|
+
|
|
212
|
+
case HtNodeWithContentType.BOT_ACTION:
|
|
213
|
+
return FlowBotAction.fromHubtypeCMS(hubtypeContent, locale, this.cmsApi)
|
|
214
|
+
|
|
220
215
|
default:
|
|
221
216
|
return undefined
|
|
222
217
|
}
|
|
@@ -284,7 +279,6 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
284
279
|
}
|
|
285
280
|
|
|
286
281
|
export * from './action'
|
|
287
|
-
export { BOT_ACTION_PAYLOAD_PREFIX } from './constants'
|
|
288
282
|
export * from './content-fields'
|
|
289
283
|
export { trackFlowContent } from './tracking'
|
|
290
284
|
export {
|