@botonic/plugin-flow-builder 0.58.0-alpha.0 → 0.58.0-alpha.2
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/push-flow-resolver.d.ts +3 -6
- package/lib/cjs/action/push-flow-resolver.js +20 -34
- package/lib/cjs/action/push-flow-resolver.js.map +1 -1
- package/lib/cjs/content-fields/flow-update-variables.d.ts +15 -0
- package/lib/cjs/content-fields/flow-update-variables.js +133 -0
- package/lib/cjs/content-fields/flow-update-variables.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +2 -1
- 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/update-variables.d.ts +9 -0
- package/lib/cjs/content-fields/hubtype-fields/update-variables.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/update-variables.js.map +1 -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/services/contact-info-fields-api.d.ts +7 -0
- package/lib/cjs/services/contact-info-fields-api.js +28 -0
- package/lib/cjs/services/contact-info-fields-api.js.map +1 -0
- package/lib/esm/action/push-flow-resolver.d.ts +3 -6
- package/lib/esm/action/push-flow-resolver.js +20 -34
- package/lib/esm/action/push-flow-resolver.js.map +1 -1
- package/lib/esm/content-fields/flow-update-variables.d.ts +15 -0
- package/lib/esm/content-fields/flow-update-variables.js +133 -0
- package/lib/esm/content-fields/flow-update-variables.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +2 -1
- 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/update-variables.d.ts +9 -0
- package/lib/esm/content-fields/hubtype-fields/update-variables.js +3 -0
- package/lib/esm/content-fields/hubtype-fields/update-variables.js.map +1 -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/services/contact-info-fields-api.d.ts +7 -0
- package/lib/esm/services/contact-info-fields-api.js +28 -0
- package/lib/esm/services/contact-info-fields-api.js.map +1 -0
- package/package.json +2 -2
- package/src/action/push-flow-resolver.ts +38 -48
- package/src/content-fields/flow-update-variables.tsx +184 -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/update-variables.ts +10 -0
- package/src/content-fields/index.ts +3 -0
- package/src/flow-factory.ts +7 -0
- package/src/services/contact-info-fields-api.ts +36 -0
|
@@ -20,6 +20,7 @@ import type { HtPayloadNode } from './payload'
|
|
|
20
20
|
import type { HtRatingNode } from './rating'
|
|
21
21
|
import type { HtSmartIntentNode } from './smart-intent'
|
|
22
22
|
import type { HtTextNode } from './text'
|
|
23
|
+
import type { HtUpdateVariablesNode } from './update-variables'
|
|
23
24
|
import type { HtUrlNode } from './url'
|
|
24
25
|
import type { HtVideoNode } from './video'
|
|
25
26
|
import type { HtWebviewNode } from './webview'
|
|
@@ -52,6 +53,7 @@ export type HtNodeWithContent =
|
|
|
52
53
|
| HtCustomConditionalV2Node
|
|
53
54
|
| HtDoNothingNode
|
|
54
55
|
| HtContactReasonsNode
|
|
56
|
+
| HtUpdateVariablesNode
|
|
55
57
|
// | HtChannelConditionalNode
|
|
56
58
|
// | HtCountryConditionalNode
|
|
57
59
|
// | HtCustomConditionalNode
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HtBaseNode } from './common'
|
|
2
|
+
import type { HtNodeWithContentType } from './node-types'
|
|
3
|
+
|
|
4
|
+
export interface HtUpdateVariablesNode extends HtBaseNode {
|
|
5
|
+
type: HtNodeWithContentType.UPDATE_VARIABLES
|
|
6
|
+
content: {
|
|
7
|
+
set_variables: Record<string, string | number | boolean>
|
|
8
|
+
unset_variables: string[]
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -15,6 +15,7 @@ import { FlowImage } from './flow-image'
|
|
|
15
15
|
import { FlowQueueStatusConditional } from './flow-queue-status-conditional'
|
|
16
16
|
import { FlowRating } from './flow-rating'
|
|
17
17
|
import { FlowText } from './flow-text'
|
|
18
|
+
import { FlowUpdateVariables } from './flow-update-variables'
|
|
18
19
|
import { FlowVideo } from './flow-video'
|
|
19
20
|
import { FlowWhatsappCtaUrlButtonNode } from './flow-whatsapp-cta-url-button'
|
|
20
21
|
import { FlowWhatsappRequestContactInfoNode } from './flow-whatsapp-request-contact-info'
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
FlowQueueStatusConditional,
|
|
47
48
|
FlowRating,
|
|
48
49
|
FlowText,
|
|
50
|
+
FlowUpdateVariables,
|
|
49
51
|
FlowVideo,
|
|
50
52
|
FlowWhatsappButtonList,
|
|
51
53
|
FlowWhatsappButtonListRow,
|
|
@@ -77,4 +79,5 @@ export type FlowContent =
|
|
|
77
79
|
| FlowAiAgentRouter
|
|
78
80
|
| FlowCustomConditionalV2
|
|
79
81
|
| FlowDoNothing
|
|
82
|
+
| FlowUpdateVariables
|
|
80
83
|
| FlowContactReasonsConditional
|
package/src/flow-factory.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
FlowQueueStatusConditional,
|
|
20
20
|
FlowRating,
|
|
21
21
|
FlowText,
|
|
22
|
+
FlowUpdateVariables,
|
|
22
23
|
FlowVideo,
|
|
23
24
|
FlowWhatsappButtonList,
|
|
24
25
|
FlowWhatsappCtaUrlButtonNode,
|
|
@@ -123,6 +124,12 @@ export class FlowFactory {
|
|
|
123
124
|
case HtNodeWithContentType.DO_NOTHING:
|
|
124
125
|
return FlowDoNothing.fromHubtypeCMS(hubtypeContent)
|
|
125
126
|
|
|
127
|
+
case HtNodeWithContentType.UPDATE_VARIABLES:
|
|
128
|
+
return FlowUpdateVariables.fromHubtypeCMS(
|
|
129
|
+
hubtypeContent,
|
|
130
|
+
this.botContext
|
|
131
|
+
)
|
|
132
|
+
|
|
126
133
|
case HtNodeWithContentType.CONTACT_REASONS_CONDITION:
|
|
127
134
|
return FlowContactReasonsConditional.fromHubtypeCMS(
|
|
128
135
|
hubtypeContent,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
|
|
3
|
+
export class ContactInfoFieldsClient {
|
|
4
|
+
constructor(
|
|
5
|
+
private readonly hubtypeApiUrl: string,
|
|
6
|
+
private readonly accessToken: string
|
|
7
|
+
) {}
|
|
8
|
+
|
|
9
|
+
async update(
|
|
10
|
+
chatId: string,
|
|
11
|
+
fieldName: string,
|
|
12
|
+
value: string | number | boolean
|
|
13
|
+
): Promise<void> {
|
|
14
|
+
await axios.put(
|
|
15
|
+
`${this.hubtypeApiUrl}/external/v1/chats/${chatId}/contact_info_fields/${encodeURIComponent(fieldName)}/`,
|
|
16
|
+
{ value },
|
|
17
|
+
{
|
|
18
|
+
headers: {
|
|
19
|
+
'Content-Type': 'application/json',
|
|
20
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async delete(chatId: string, fieldName: string): Promise<void> {
|
|
27
|
+
await axios.delete(
|
|
28
|
+
`${this.hubtypeApiUrl}/external/v1/chats/${chatId}/contact_info_fields/${encodeURIComponent(fieldName)}/`,
|
|
29
|
+
{
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
}
|