@botonic/plugin-flow-builder 0.55.2 → 0.56.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/get-contents.js +6 -1
- package/lib/cjs/action/get-contents.js.map +1 -1
- package/lib/cjs/action/index.js +5 -0
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/api.d.ts +5 -1
- package/lib/cjs/api.js +19 -0
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/content-fields/flow-ai-agent-base.js +5 -1
- package/lib/cjs/content-fields/flow-ai-agent-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-ai-agent-router.js +1 -0
- package/lib/cjs/content-fields/flow-ai-agent-router.js.map +1 -1
- package/lib/cjs/content-fields/flow-ai-agent.js +1 -0
- package/lib/cjs/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/cjs/content-fields/flow-whatsapp-request-contact-info.d.ts +11 -0
- package/lib/cjs/content-fields/flow-whatsapp-request-contact-info.js +46 -0
- package/lib/cjs/content-fields/flow-whatsapp-request-contact-info.js.map +1 -0
- package/lib/cjs/content-fields/flow-whatsapp-template.d.ts +1 -0
- package/lib/cjs/content-fields/flow-whatsapp-template.js +11 -0
- package/lib/cjs/content-fields/flow-whatsapp-template.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/index.d.ts +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.js +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +1 -0
- package/lib/cjs/content-fields/hubtype-fields/node-types.js +1 -0
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +2 -1
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-request-contact-info.d.ts +10 -0
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-request-contact-info.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-template.d.ts +4 -0
- 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/flow-factory.js +2 -0
- package/lib/cjs/flow-factory.js.map +1 -1
- package/lib/cjs/index.d.ts +3 -2
- package/lib/cjs/index.js +12 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types.d.ts +2 -2
- package/lib/cjs/utils/hubtype-assistant-content.d.ts +1 -0
- package/lib/cjs/utils/hubtype-assistant-content.js +11 -0
- package/lib/cjs/utils/hubtype-assistant-content.js.map +1 -1
- package/lib/esm/action/get-contents.js +6 -1
- package/lib/esm/action/get-contents.js.map +1 -1
- package/lib/esm/action/index.js +5 -0
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/api.d.ts +5 -1
- package/lib/esm/api.js +19 -0
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/content-fields/flow-ai-agent-base.js +5 -1
- package/lib/esm/content-fields/flow-ai-agent-base.js.map +1 -1
- package/lib/esm/content-fields/flow-ai-agent-router.js +1 -0
- package/lib/esm/content-fields/flow-ai-agent-router.js.map +1 -1
- package/lib/esm/content-fields/flow-ai-agent.js +1 -0
- package/lib/esm/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/esm/content-fields/flow-whatsapp-request-contact-info.d.ts +11 -0
- package/lib/esm/content-fields/flow-whatsapp-request-contact-info.js +46 -0
- package/lib/esm/content-fields/flow-whatsapp-request-contact-info.js.map +1 -0
- package/lib/esm/content-fields/flow-whatsapp-template.d.ts +1 -0
- package/lib/esm/content-fields/flow-whatsapp-template.js +11 -0
- package/lib/esm/content-fields/flow-whatsapp-template.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/index.d.ts +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.js +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +1 -0
- package/lib/esm/content-fields/hubtype-fields/node-types.js +1 -0
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +2 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-request-contact-info.d.ts +10 -0
- package/lib/esm/content-fields/hubtype-fields/whatsapp-request-contact-info.js +3 -0
- package/lib/esm/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/whatsapp-template.d.ts +4 -0
- package/lib/esm/content-fields/index.d.ts +3 -2
- package/lib/esm/content-fields/index.js +3 -1
- package/lib/esm/content-fields/index.js.map +1 -1
- package/lib/esm/flow-factory.js +2 -0
- package/lib/esm/flow-factory.js.map +1 -1
- package/lib/esm/index.d.ts +3 -2
- package/lib/esm/index.js +12 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types.d.ts +2 -2
- package/lib/esm/utils/hubtype-assistant-content.d.ts +1 -0
- package/lib/esm/utils/hubtype-assistant-content.js +11 -0
- package/lib/esm/utils/hubtype-assistant-content.js.map +1 -1
- package/package.json +3 -3
- package/src/action/get-contents.ts +17 -2
- package/src/action/index.tsx +7 -0
- package/src/api.ts +28 -0
- package/src/content-fields/flow-ai-agent-base.tsx +12 -1
- package/src/content-fields/flow-ai-agent-router.tsx +1 -0
- package/src/content-fields/flow-ai-agent.tsx +1 -0
- package/src/content-fields/flow-whatsapp-request-contact-info.tsx +66 -0
- package/src/content-fields/flow-whatsapp-template.tsx +16 -0
- package/src/content-fields/hubtype-fields/index.ts +1 -0
- package/src/content-fields/hubtype-fields/node-types.ts +1 -0
- package/src/content-fields/hubtype-fields/nodes.ts +2 -0
- package/src/content-fields/hubtype-fields/whatsapp-request-contact-info.ts +11 -0
- package/src/content-fields/hubtype-fields/whatsapp-template.ts +5 -0
- package/src/content-fields/index.ts +5 -2
- package/src/flow-factory.ts +6 -0
- package/src/index.ts +30 -5
- package/src/types.ts +6 -6
- package/src/utils/hubtype-assistant-content.ts +14 -0
|
@@ -15,6 +15,7 @@ import { FlowRating } from './flow-rating'
|
|
|
15
15
|
import { FlowText } from './flow-text'
|
|
16
16
|
import { FlowVideo } from './flow-video'
|
|
17
17
|
import { FlowWhatsappCtaUrlButtonNode } from './flow-whatsapp-cta-url-button'
|
|
18
|
+
import { FlowWhatsappRequestContactInfoNode } from './flow-whatsapp-request-contact-info'
|
|
18
19
|
import { FlowWhatsappTemplate } from './flow-whatsapp-template'
|
|
19
20
|
import {
|
|
20
21
|
FlowWhatsappButtonList,
|
|
@@ -26,14 +27,15 @@ export { ContentFieldsBase } from './content-fields-base'
|
|
|
26
27
|
export { FlowButton } from './flow-button'
|
|
27
28
|
export { FlowElement } from './flow-element'
|
|
28
29
|
export {
|
|
29
|
-
FlowAiAgentRouter,
|
|
30
30
|
FlowAiAgent,
|
|
31
|
+
FlowAiAgentRouter,
|
|
31
32
|
FlowBotAction,
|
|
32
33
|
FlowCaptureUserInput,
|
|
33
34
|
FlowCarousel,
|
|
34
35
|
FlowChannelConditional,
|
|
35
36
|
FlowCountryConditional,
|
|
36
37
|
FlowCustomConditional,
|
|
38
|
+
FlowCustomConditionalV2,
|
|
37
39
|
FlowGoToFlow,
|
|
38
40
|
FlowHandoff,
|
|
39
41
|
FlowImage,
|
|
@@ -45,8 +47,8 @@ export {
|
|
|
45
47
|
FlowWhatsappButtonListRow,
|
|
46
48
|
FlowWhatsappButtonListSection,
|
|
47
49
|
FlowWhatsappCtaUrlButtonNode,
|
|
50
|
+
FlowWhatsappRequestContactInfoNode,
|
|
48
51
|
FlowWhatsappTemplate,
|
|
49
|
-
FlowCustomConditionalV2,
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
export type FlowContent =
|
|
@@ -56,6 +58,7 @@ export type FlowContent =
|
|
|
56
58
|
| FlowVideo
|
|
57
59
|
| FlowWhatsappButtonList
|
|
58
60
|
| FlowWhatsappCtaUrlButtonNode
|
|
61
|
+
| FlowWhatsappRequestContactInfoNode
|
|
59
62
|
| FlowWhatsappTemplate
|
|
60
63
|
| FlowHandoff
|
|
61
64
|
| FlowBotAction
|
package/src/flow-factory.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
FlowVideo,
|
|
21
21
|
FlowWhatsappButtonList,
|
|
22
22
|
FlowWhatsappCtaUrlButtonNode,
|
|
23
|
+
FlowWhatsappRequestContactInfoNode,
|
|
23
24
|
FlowWhatsappTemplate,
|
|
24
25
|
} from './content-fields'
|
|
25
26
|
import { FlowCaptureUserInput } from './content-fields/flow-capture-user-input'
|
|
@@ -75,6 +76,11 @@ export class FlowFactory {
|
|
|
75
76
|
this.cmsApi,
|
|
76
77
|
this.botContext
|
|
77
78
|
)
|
|
79
|
+
case HtNodeWithContentType.WHATSAPP_REQUEST_CONTACT_INFO:
|
|
80
|
+
return FlowWhatsappRequestContactInfoNode.fromHubtypeCMS(
|
|
81
|
+
hubtypeContent,
|
|
82
|
+
this.locale
|
|
83
|
+
)
|
|
78
84
|
case HtNodeWithContentType.HANDOFF:
|
|
79
85
|
return FlowHandoff.fromHubtypeCMS(
|
|
80
86
|
hubtypeContent,
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
PROVIDER,
|
|
6
6
|
type ResolvedPlugins,
|
|
7
7
|
type Session,
|
|
8
|
+
WhatsappInputOrigin,
|
|
8
9
|
} from '@botonic/core'
|
|
9
10
|
import type { ActionRequest } from '@botonic/react'
|
|
10
11
|
import { v7 as uuidv7 } from 'uuid'
|
|
@@ -105,6 +106,8 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
105
106
|
request: this.currentRequest,
|
|
106
107
|
})
|
|
107
108
|
|
|
109
|
+
this.resolveWhatsappContactRequestPayload(request)
|
|
110
|
+
|
|
108
111
|
const checkUserTextInput =
|
|
109
112
|
inputHasTextOrTranscript(request.input) && !request.input.payload
|
|
110
113
|
|
|
@@ -122,6 +125,28 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
122
125
|
await this.updateRequestBeforeRoutes(request)
|
|
123
126
|
}
|
|
124
127
|
|
|
128
|
+
private resolveWhatsappContactRequestPayload(
|
|
129
|
+
request: PluginPreRequest
|
|
130
|
+
): void {
|
|
131
|
+
if (
|
|
132
|
+
request.input.type !== INPUT.CONTACT ||
|
|
133
|
+
request.input.origin !== WhatsappInputOrigin.ContactRequest
|
|
134
|
+
) {
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const whatsappRequestContactInfoNode =
|
|
139
|
+
this.cmsApi.getWhatsappRequestContactInfoNode()
|
|
140
|
+
|
|
141
|
+
if (whatsappRequestContactInfoNode) {
|
|
142
|
+
request.input.payload = this.cmsApi.getPayload(
|
|
143
|
+
whatsappRequestContactInfoNode.content.button.target
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this.cmsApi.removeWhatsappRequestContactId()
|
|
148
|
+
}
|
|
149
|
+
|
|
125
150
|
private convertWhatsappAiAgentEmptyPayloads(request: PluginPreRequest): void {
|
|
126
151
|
if (request.session.user.provider === PROVIDER.WHATSAPP) {
|
|
127
152
|
const shouldUseReferral =
|
|
@@ -275,16 +300,16 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
275
300
|
export * from './action'
|
|
276
301
|
export { AGENT_RATING_PAYLOAD, EMPTY_PAYLOAD } from './constants'
|
|
277
302
|
export * from './content-fields'
|
|
278
|
-
export { HtBotActionNode } from './content-fields/hubtype-fields'
|
|
303
|
+
export type { HtBotActionNode } from './content-fields/hubtype-fields'
|
|
279
304
|
export {
|
|
280
305
|
getCommonFlowContentEventArgsForContentId,
|
|
281
306
|
trackFlowContent,
|
|
282
307
|
} from './tracking'
|
|
283
308
|
export {
|
|
284
|
-
BotonicPluginFlowBuilderOptions,
|
|
285
|
-
ContentFilter,
|
|
309
|
+
type BotonicPluginFlowBuilderOptions,
|
|
310
|
+
type ContentFilter,
|
|
286
311
|
FlowBuilderJSONVersion,
|
|
287
|
-
PayloadParamsBase,
|
|
288
|
-
RatingSubmittedInfo,
|
|
312
|
+
type PayloadParamsBase,
|
|
313
|
+
type RatingSubmittedInfo,
|
|
289
314
|
} from './types'
|
|
290
315
|
export * from './webview'
|
package/src/types.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
AiAgentArgs,
|
|
3
|
-
|
|
3
|
+
BotContext,
|
|
4
4
|
GuardrailRule,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
InferenceResponse,
|
|
6
|
+
PluginPreRequest,
|
|
7
|
+
ResolvedPlugins,
|
|
8
8
|
} from '@botonic/core'
|
|
9
9
|
import type { FlowContent } from './content-fields'
|
|
10
10
|
import type {
|
|
@@ -101,4 +101,4 @@ export interface RatingSubmittedInfo extends HtRatingButton {
|
|
|
101
101
|
possibleValues: number[]
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
export { AiAgentArgs, GuardrailRule }
|
|
104
|
+
export type { AiAgentArgs, GuardrailRule }
|
|
@@ -6,6 +6,7 @@ import { FlowImage } from '../content-fields/flow-image'
|
|
|
6
6
|
import { FlowText } from '../content-fields/flow-text'
|
|
7
7
|
import { FlowVideo } from '../content-fields/flow-video'
|
|
8
8
|
import { FlowWhatsappCtaUrlButtonNode } from '../content-fields/flow-whatsapp-cta-url-button'
|
|
9
|
+
import { FlowWhatsappRequestContactInfoNode } from '../content-fields/flow-whatsapp-request-contact-info'
|
|
9
10
|
import { FlowWhatsappTemplate } from '../content-fields/flow-whatsapp-template'
|
|
10
11
|
import { HtButtonStyle } from '../content-fields/hubtype-fields'
|
|
11
12
|
import { FlowWhatsappButtonList } from '../content-fields/whatsapp-button-list/flow-whatsapp-button-list'
|
|
@@ -34,6 +35,9 @@ export class HubtypeAssistantContent {
|
|
|
34
35
|
if (content instanceof FlowWhatsappTemplate) {
|
|
35
36
|
return HubtypeAssistantContent.formatWhatsappTemplateContent(content)
|
|
36
37
|
}
|
|
38
|
+
if (content instanceof FlowWhatsappRequestContactInfoNode) {
|
|
39
|
+
return HubtypeAssistantContent.formatRequestContactInfoContent(content)
|
|
40
|
+
}
|
|
37
41
|
return ''
|
|
38
42
|
}
|
|
39
43
|
|
|
@@ -205,4 +209,14 @@ export class HubtypeAssistantContent {
|
|
|
205
209
|
const { name, language } = template.htWhatsappTemplate
|
|
206
210
|
return `WhatsApp Template: ${name} (${language})`
|
|
207
211
|
}
|
|
212
|
+
|
|
213
|
+
private static formatRequestContactInfoContent(
|
|
214
|
+
requestContactInfo: FlowWhatsappRequestContactInfoNode
|
|
215
|
+
): string {
|
|
216
|
+
const body = requestContactInfo.text?.trim() ?? ''
|
|
217
|
+
if (!body) {
|
|
218
|
+
return '[WhatsApp Request Contact Info]'
|
|
219
|
+
}
|
|
220
|
+
return requestContactInfo.text
|
|
221
|
+
}
|
|
208
222
|
}
|