@botonic/plugin-flow-builder 0.22.0-beta.3 → 0.22.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.
Files changed (268) hide show
  1. package/lib/cjs/action.d.ts +16 -2
  2. package/lib/cjs/action.js +21 -19
  3. package/lib/cjs/action.js.map +1 -1
  4. package/lib/cjs/api.d.ts +19 -0
  5. package/lib/cjs/api.js +108 -0
  6. package/lib/cjs/api.js.map +1 -0
  7. package/lib/cjs/content-fields/content-fields-base.d.ts +4 -4
  8. package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
  9. package/lib/cjs/content-fields/flow-button.d.ts +6 -3
  10. package/lib/cjs/content-fields/flow-button.js +28 -21
  11. package/lib/cjs/content-fields/flow-button.js.map +1 -1
  12. package/lib/cjs/content-fields/flow-carousel.d.ts +3 -2
  13. package/lib/cjs/content-fields/flow-carousel.js +3 -10
  14. package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
  15. package/lib/cjs/content-fields/flow-element.d.ts +6 -3
  16. package/lib/cjs/content-fields/flow-element.js +16 -5
  17. package/lib/cjs/content-fields/flow-element.js.map +1 -1
  18. package/lib/cjs/content-fields/flow-image.d.ts +2 -2
  19. package/lib/cjs/content-fields/flow-image.js.map +1 -1
  20. package/lib/cjs/content-fields/flow-text.d.ts +4 -3
  21. package/lib/cjs/content-fields/flow-text.js +9 -9
  22. package/lib/cjs/content-fields/flow-text.js.map +1 -1
  23. package/lib/cjs/content-fields/flow-video.d.ts +2 -2
  24. package/lib/cjs/content-fields/flow-video.js +0 -1
  25. package/lib/cjs/content-fields/flow-video.js.map +1 -1
  26. package/lib/cjs/content-fields/hubtype-fields/button.d.ts +9 -0
  27. package/lib/cjs/content-fields/hubtype-fields/button.js +3 -0
  28. package/lib/cjs/content-fields/hubtype-fields/button.js.map +1 -0
  29. package/lib/cjs/content-fields/hubtype-fields/carousel.d.ts +16 -0
  30. package/lib/cjs/content-fields/hubtype-fields/carousel.js +3 -0
  31. package/lib/cjs/content-fields/hubtype-fields/carousel.js.map +1 -0
  32. package/lib/cjs/content-fields/hubtype-fields/common.d.ts +55 -0
  33. package/lib/cjs/content-fields/hubtype-fields/common.js +3 -0
  34. package/lib/cjs/content-fields/hubtype-fields/common.js.map +1 -0
  35. package/lib/cjs/content-fields/hubtype-fields/fallback.d.ts +9 -0
  36. package/lib/cjs/content-fields/hubtype-fields/fallback.js +3 -0
  37. package/lib/cjs/content-fields/hubtype-fields/fallback.js.map +1 -0
  38. package/lib/cjs/content-fields/hubtype-fields/function.d.ts +28 -0
  39. package/lib/cjs/content-fields/hubtype-fields/function.js +10 -0
  40. package/lib/cjs/content-fields/hubtype-fields/function.js.map +1 -0
  41. package/lib/cjs/content-fields/hubtype-fields/handoff.d.ts +10 -0
  42. package/lib/cjs/content-fields/hubtype-fields/handoff.js +3 -0
  43. package/lib/cjs/content-fields/hubtype-fields/handoff.js.map +1 -0
  44. package/lib/cjs/content-fields/hubtype-fields/image.d.ts +8 -0
  45. package/lib/cjs/content-fields/{types.js → hubtype-fields/image.js} +1 -1
  46. package/lib/cjs/content-fields/hubtype-fields/image.js.map +1 -0
  47. package/lib/cjs/content-fields/hubtype-fields/index.d.ts +17 -0
  48. package/lib/cjs/content-fields/hubtype-fields/index.js +21 -0
  49. package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -0
  50. package/lib/cjs/content-fields/hubtype-fields/intent.d.ts +10 -0
  51. package/lib/cjs/content-fields/hubtype-fields/intent.js +3 -0
  52. package/lib/cjs/content-fields/hubtype-fields/intent.js.map +1 -0
  53. package/lib/cjs/content-fields/hubtype-fields/keyword.d.ts +9 -0
  54. package/lib/cjs/content-fields/hubtype-fields/keyword.js +3 -0
  55. package/lib/cjs/content-fields/hubtype-fields/keyword.js.map +1 -0
  56. package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +23 -0
  57. package/lib/cjs/content-fields/hubtype-fields/node-types.js +31 -0
  58. package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -0
  59. package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +16 -0
  60. package/lib/cjs/content-fields/hubtype-fields/nodes.js +3 -0
  61. package/lib/cjs/content-fields/hubtype-fields/nodes.js.map +1 -0
  62. package/lib/cjs/content-fields/hubtype-fields/payload.d.ts +8 -0
  63. package/lib/cjs/content-fields/hubtype-fields/payload.js +3 -0
  64. package/lib/cjs/content-fields/hubtype-fields/payload.js.map +1 -0
  65. package/lib/cjs/content-fields/hubtype-fields/start.d.ts +7 -0
  66. package/lib/cjs/content-fields/hubtype-fields/start.js +3 -0
  67. package/lib/cjs/content-fields/hubtype-fields/start.js.map +1 -0
  68. package/lib/cjs/content-fields/hubtype-fields/text.d.ts +11 -0
  69. package/lib/cjs/content-fields/hubtype-fields/text.js +3 -0
  70. package/lib/cjs/content-fields/hubtype-fields/text.js.map +1 -0
  71. package/lib/cjs/content-fields/hubtype-fields/url.d.ts +8 -0
  72. package/lib/cjs/content-fields/hubtype-fields/url.js +3 -0
  73. package/lib/cjs/content-fields/hubtype-fields/url.js.map +1 -0
  74. package/lib/cjs/content-fields/hubtype-fields/video.d.ts +8 -0
  75. package/lib/cjs/content-fields/hubtype-fields/video.js +3 -0
  76. package/lib/cjs/content-fields/hubtype-fields/video.js.map +1 -0
  77. package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.d.ts +21 -0
  78. package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js +3 -0
  79. package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
  80. package/lib/cjs/content-fields/index.d.ts +7 -5
  81. package/lib/cjs/content-fields/index.js +11 -9
  82. package/lib/cjs/content-fields/index.js.map +1 -1
  83. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +10 -0
  84. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +32 -0
  85. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
  86. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +10 -0
  87. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +29 -0
  88. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
  89. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +12 -0
  90. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +33 -0
  91. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
  92. package/lib/cjs/functions/conditional-provider.d.ts +2 -2
  93. package/lib/cjs/functions/conditional-provider.js +2 -2
  94. package/lib/cjs/functions/conditional-provider.js.map +1 -1
  95. package/lib/cjs/functions/conditional-queue-status.d.ts +7 -2
  96. package/lib/cjs/functions/conditional-queue-status.js +11 -1
  97. package/lib/cjs/functions/conditional-queue-status.js.map +1 -1
  98. package/lib/cjs/handoff.d.ts +2 -2
  99. package/lib/cjs/handoff.js +17 -9
  100. package/lib/cjs/handoff.js.map +1 -1
  101. package/lib/cjs/helpers.d.ts +2 -1
  102. package/lib/cjs/helpers.js +5 -13
  103. package/lib/cjs/helpers.js.map +1 -1
  104. package/lib/cjs/index.d.ts +10 -21
  105. package/lib/cjs/index.js +36 -151
  106. package/lib/cjs/index.js.map +1 -1
  107. package/lib/cjs/types.d.ts +8 -2
  108. package/lib/cjs/types.js.map +1 -1
  109. package/lib/esm/action.d.ts +16 -2
  110. package/lib/esm/action.js +21 -19
  111. package/lib/esm/action.js.map +1 -1
  112. package/lib/esm/api.d.ts +19 -0
  113. package/lib/esm/api.js +103 -0
  114. package/lib/esm/api.js.map +1 -0
  115. package/lib/esm/content-fields/content-fields-base.d.ts +4 -4
  116. package/lib/esm/content-fields/content-fields-base.js.map +1 -1
  117. package/lib/esm/content-fields/flow-button.d.ts +6 -3
  118. package/lib/esm/content-fields/flow-button.js +28 -21
  119. package/lib/esm/content-fields/flow-button.js.map +1 -1
  120. package/lib/esm/content-fields/flow-carousel.d.ts +3 -2
  121. package/lib/esm/content-fields/flow-carousel.js +4 -11
  122. package/lib/esm/content-fields/flow-carousel.js.map +1 -1
  123. package/lib/esm/content-fields/flow-element.d.ts +6 -3
  124. package/lib/esm/content-fields/flow-element.js +15 -5
  125. package/lib/esm/content-fields/flow-element.js.map +1 -1
  126. package/lib/esm/content-fields/flow-image.d.ts +2 -2
  127. package/lib/esm/content-fields/flow-image.js.map +1 -1
  128. package/lib/esm/content-fields/flow-text.d.ts +4 -3
  129. package/lib/esm/content-fields/flow-text.js +9 -9
  130. package/lib/esm/content-fields/flow-text.js.map +1 -1
  131. package/lib/esm/content-fields/flow-video.d.ts +2 -2
  132. package/lib/esm/content-fields/flow-video.js +0 -1
  133. package/lib/esm/content-fields/flow-video.js.map +1 -1
  134. package/lib/esm/content-fields/hubtype-fields/button.d.ts +9 -0
  135. package/lib/esm/content-fields/hubtype-fields/button.js +2 -0
  136. package/lib/esm/content-fields/hubtype-fields/button.js.map +1 -0
  137. package/lib/esm/content-fields/hubtype-fields/carousel.d.ts +16 -0
  138. package/lib/esm/content-fields/hubtype-fields/carousel.js +2 -0
  139. package/lib/esm/content-fields/hubtype-fields/carousel.js.map +1 -0
  140. package/lib/esm/content-fields/hubtype-fields/common.d.ts +55 -0
  141. package/lib/esm/content-fields/hubtype-fields/common.js +2 -0
  142. package/lib/esm/content-fields/hubtype-fields/common.js.map +1 -0
  143. package/lib/esm/content-fields/hubtype-fields/fallback.d.ts +9 -0
  144. package/lib/esm/content-fields/hubtype-fields/fallback.js +2 -0
  145. package/lib/esm/content-fields/hubtype-fields/fallback.js.map +1 -0
  146. package/lib/esm/content-fields/hubtype-fields/function.d.ts +28 -0
  147. package/lib/esm/content-fields/hubtype-fields/function.js +7 -0
  148. package/lib/esm/content-fields/hubtype-fields/function.js.map +1 -0
  149. package/lib/esm/content-fields/hubtype-fields/handoff.d.ts +10 -0
  150. package/lib/esm/content-fields/hubtype-fields/handoff.js +2 -0
  151. package/lib/esm/content-fields/hubtype-fields/handoff.js.map +1 -0
  152. package/lib/esm/content-fields/hubtype-fields/image.d.ts +8 -0
  153. package/lib/esm/content-fields/hubtype-fields/image.js +2 -0
  154. package/lib/esm/content-fields/hubtype-fields/image.js.map +1 -0
  155. package/lib/esm/content-fields/hubtype-fields/index.d.ts +17 -0
  156. package/lib/esm/content-fields/hubtype-fields/index.js +18 -0
  157. package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -0
  158. package/lib/esm/content-fields/hubtype-fields/intent.d.ts +10 -0
  159. package/lib/esm/content-fields/hubtype-fields/intent.js +2 -0
  160. package/lib/esm/content-fields/hubtype-fields/intent.js.map +1 -0
  161. package/lib/esm/content-fields/hubtype-fields/keyword.d.ts +9 -0
  162. package/lib/esm/content-fields/hubtype-fields/keyword.js +2 -0
  163. package/lib/esm/content-fields/hubtype-fields/keyword.js.map +1 -0
  164. package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +23 -0
  165. package/lib/esm/content-fields/hubtype-fields/node-types.js +28 -0
  166. package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -0
  167. package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +16 -0
  168. package/lib/esm/content-fields/hubtype-fields/nodes.js +2 -0
  169. package/lib/esm/content-fields/hubtype-fields/nodes.js.map +1 -0
  170. package/lib/esm/content-fields/hubtype-fields/payload.d.ts +8 -0
  171. package/lib/esm/content-fields/hubtype-fields/payload.js +2 -0
  172. package/lib/esm/content-fields/hubtype-fields/payload.js.map +1 -0
  173. package/lib/esm/content-fields/hubtype-fields/start.d.ts +7 -0
  174. package/lib/esm/content-fields/hubtype-fields/start.js +2 -0
  175. package/lib/esm/content-fields/hubtype-fields/start.js.map +1 -0
  176. package/lib/esm/content-fields/hubtype-fields/text.d.ts +11 -0
  177. package/lib/esm/content-fields/hubtype-fields/text.js +2 -0
  178. package/lib/esm/content-fields/hubtype-fields/text.js.map +1 -0
  179. package/lib/esm/content-fields/hubtype-fields/url.d.ts +8 -0
  180. package/lib/esm/content-fields/hubtype-fields/url.js +2 -0
  181. package/lib/esm/content-fields/hubtype-fields/url.js.map +1 -0
  182. package/lib/esm/content-fields/hubtype-fields/video.d.ts +8 -0
  183. package/lib/esm/content-fields/hubtype-fields/video.js +2 -0
  184. package/lib/esm/content-fields/hubtype-fields/video.js.map +1 -0
  185. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.d.ts +21 -0
  186. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js +2 -0
  187. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
  188. package/lib/esm/content-fields/index.d.ts +7 -5
  189. package/lib/esm/content-fields/index.js +6 -4
  190. package/lib/esm/content-fields/index.js.map +1 -1
  191. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +10 -0
  192. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +28 -0
  193. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
  194. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +10 -0
  195. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +25 -0
  196. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
  197. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +12 -0
  198. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +28 -0
  199. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
  200. package/lib/esm/functions/conditional-provider.d.ts +2 -2
  201. package/lib/esm/functions/conditional-provider.js +2 -2
  202. package/lib/esm/functions/conditional-provider.js.map +1 -1
  203. package/lib/esm/functions/conditional-queue-status.d.ts +7 -2
  204. package/lib/esm/functions/conditional-queue-status.js +11 -1
  205. package/lib/esm/functions/conditional-queue-status.js.map +1 -1
  206. package/lib/esm/handoff.d.ts +2 -2
  207. package/lib/esm/handoff.js +17 -9
  208. package/lib/esm/handoff.js.map +1 -1
  209. package/lib/esm/helpers.d.ts +2 -1
  210. package/lib/esm/helpers.js +3 -11
  211. package/lib/esm/helpers.js.map +1 -1
  212. package/lib/esm/index.d.ts +10 -21
  213. package/lib/esm/index.js +38 -153
  214. package/lib/esm/index.js.map +1 -1
  215. package/lib/esm/types.d.ts +8 -2
  216. package/lib/esm/types.js.map +1 -1
  217. package/package.json +4 -5
  218. package/src/action.tsx +31 -22
  219. package/src/api.ts +162 -0
  220. package/src/content-fields/content-fields-base.ts +7 -7
  221. package/src/content-fields/flow-button.tsx +40 -19
  222. package/src/content-fields/flow-carousel.tsx +10 -18
  223. package/src/content-fields/flow-element.tsx +26 -9
  224. package/src/content-fields/flow-image.tsx +2 -2
  225. package/src/content-fields/flow-text.tsx +15 -12
  226. package/src/content-fields/flow-video.tsx +2 -3
  227. package/src/content-fields/hubtype-fields/button.ts +15 -0
  228. package/src/content-fields/hubtype-fields/carousel.ts +18 -0
  229. package/src/content-fields/hubtype-fields/common.ts +65 -0
  230. package/src/content-fields/hubtype-fields/fallback.ts +10 -0
  231. package/src/content-fields/hubtype-fields/function.ts +33 -0
  232. package/src/content-fields/hubtype-fields/handoff.ts +11 -0
  233. package/src/content-fields/hubtype-fields/image.ts +9 -0
  234. package/src/content-fields/hubtype-fields/index.ts +17 -0
  235. package/src/content-fields/hubtype-fields/intent.ts +11 -0
  236. package/src/content-fields/hubtype-fields/keyword.ts +10 -0
  237. package/src/content-fields/hubtype-fields/node-types.ts +26 -0
  238. package/src/content-fields/hubtype-fields/nodes.ts +32 -0
  239. package/src/content-fields/hubtype-fields/payload.ts +9 -0
  240. package/src/content-fields/hubtype-fields/start.ts +8 -0
  241. package/src/content-fields/hubtype-fields/text.ts +12 -0
  242. package/src/content-fields/hubtype-fields/url.ts +9 -0
  243. package/src/content-fields/hubtype-fields/video.ts +9 -0
  244. package/src/content-fields/hubtype-fields/whatsapp-button-list.ts +25 -0
  245. package/src/content-fields/index.ts +14 -5
  246. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx +33 -0
  247. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx +35 -0
  248. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx +46 -0
  249. package/src/functions/conditional-provider.ts +2 -2
  250. package/src/functions/conditional-queue-status.ts +22 -3
  251. package/src/handoff.ts +27 -14
  252. package/src/helpers.ts +8 -19
  253. package/src/index.ts +55 -197
  254. package/src/types.ts +14 -2
  255. package/lib/cjs/content-fields/types.d.ts +0 -5
  256. package/lib/cjs/content-fields/types.js.map +0 -1
  257. package/lib/cjs/flow-builder-models.d.ts +0 -196
  258. package/lib/cjs/flow-builder-models.js +0 -24
  259. package/lib/cjs/flow-builder-models.js.map +0 -1
  260. package/lib/esm/content-fields/types.d.ts +0 -5
  261. package/lib/esm/content-fields/types.js +0 -2
  262. package/lib/esm/content-fields/types.js.map +0 -1
  263. package/lib/esm/flow-builder-models.d.ts +0 -196
  264. package/lib/esm/flow-builder-models.js +0 -21
  265. package/lib/esm/flow-builder-models.js.map +0 -1
  266. package/src/.DS_Store +0 -0
  267. package/src/content-fields/types.ts +0 -6
  268. package/src/flow-builder-models.ts +0 -249
@@ -0,0 +1,10 @@
1
+ import { HtBaseNode, HtNodeLink } from './common'
2
+ import { HtNodeWithContentType } from './node-types'
3
+
4
+ export interface HtFallbackNode extends HtBaseNode {
5
+ type: HtNodeWithContentType.FALLBACK
6
+ content: {
7
+ first_message?: HtNodeLink
8
+ second_message?: HtNodeLink
9
+ }
10
+ }
@@ -0,0 +1,33 @@
1
+ import { HtBaseNode, HtNodeLink } from './common'
2
+ import { HtNodeWithContentType } from './node-types'
3
+
4
+ export enum HtArgumentType {
5
+ NUMBER = 'number',
6
+ STRING = 'string',
7
+ JSON = 'json',
8
+ }
9
+
10
+ export interface HtFunctionArgument {
11
+ type: HtArgumentType
12
+ name: string
13
+ value: string
14
+ }
15
+
16
+ export interface HtFunctionArgumentLocale {
17
+ locale: string
18
+ values: HtFunctionArgument[]
19
+ }
20
+
21
+ export interface HtFunctionResult {
22
+ result: string
23
+ target?: HtNodeLink
24
+ }
25
+
26
+ export interface HtFunctionNode extends HtBaseNode {
27
+ type: HtNodeWithContentType.FUNCTION
28
+ content: {
29
+ action: string
30
+ arguments: HtFunctionArgumentLocale[]
31
+ result_mapping: HtFunctionResult[]
32
+ }
33
+ }
@@ -0,0 +1,11 @@
1
+ import { HtBaseNode, HtPayloadLocale, HtQueueLocale } from './common'
2
+ import { HtNodeWithContentType } from './node-types'
3
+
4
+ export interface HtHandoffNode extends HtBaseNode {
5
+ type: HtNodeWithContentType.HANDOFF
6
+ content: {
7
+ queue: HtQueueLocale[]
8
+ payload: HtPayloadLocale[]
9
+ has_auto_assign: boolean
10
+ }
11
+ }
@@ -0,0 +1,9 @@
1
+ import { HtBaseNode, HtMediaFileLocale } from './common'
2
+ import { HtNodeWithContentType } from './node-types'
3
+
4
+ export interface HtImageNode extends HtBaseNode {
5
+ type: HtNodeWithContentType.IMAGE
6
+ content: {
7
+ image: HtMediaFileLocale[]
8
+ }
9
+ }
@@ -0,0 +1,17 @@
1
+ export * from './button'
2
+ export * from './carousel'
3
+ export * from './common'
4
+ export * from './fallback'
5
+ export * from './function'
6
+ export * from './handoff'
7
+ export * from './image'
8
+ export * from './intent'
9
+ export * from './keyword'
10
+ export * from './node-types'
11
+ export * from './nodes'
12
+ export * from './payload'
13
+ export * from './start'
14
+ export * from './text'
15
+ export * from './url'
16
+ export * from './video'
17
+ export * from './whatsapp-button-list'
@@ -0,0 +1,11 @@
1
+ import { HtBaseNode, HtInputLocale, HtTextLocale } from './common'
2
+ import { HtNodeWithContentType } from './node-types'
3
+
4
+ export interface HtIntentNode extends HtBaseNode {
5
+ type: HtNodeWithContentType.INTENT
6
+ content: {
7
+ title: HtTextLocale[]
8
+ intents: HtInputLocale[]
9
+ confidence: number
10
+ }
11
+ }
@@ -0,0 +1,10 @@
1
+ import { HtBaseNode, HtInputLocale, HtTextLocale } from './common'
2
+ import { HtNodeWithContentType } from './node-types'
3
+
4
+ export interface HtKeywordNode extends HtBaseNode {
5
+ type: HtNodeWithContentType.KEYWORD
6
+ content: {
7
+ title: HtTextLocale[]
8
+ keywords: HtInputLocale[]
9
+ }
10
+ }
@@ -0,0 +1,26 @@
1
+ export enum HtNodeWithContentType {
2
+ CAROUSEL = 'carousel',
3
+ HANDOFF = 'handoff',
4
+ IMAGE = 'image',
5
+ TEXT = 'text',
6
+ KEYWORD = 'keyword',
7
+ INTENT = 'intent',
8
+ FUNCTION = 'function',
9
+ FALLBACK = 'fallback',
10
+ VIDEO = 'video',
11
+ WHATSAPP_BUTTON_LIST = 'whatsapp-button-list',
12
+ }
13
+
14
+ export enum HtNodeStartType {
15
+ STARTUP = 'start-up',
16
+ }
17
+
18
+ export enum HtNodeWithoutContentType {
19
+ URL = 'url',
20
+ PAYLOAD = 'payload',
21
+ }
22
+
23
+ export enum HtButtonStyle {
24
+ BUTTON = 'button',
25
+ QUICK_REPLY = 'quick-reply',
26
+ }
@@ -0,0 +1,32 @@
1
+ import { HtCarouselNode } from './carousel'
2
+ import { HtFallbackNode } from './fallback'
3
+ import { HtFunctionNode } from './function'
4
+ import { HtHandoffNode } from './handoff'
5
+ import { HtImageNode } from './image'
6
+ import { HtIntentNode } from './intent'
7
+ import { HtKeywordNode } from './keyword'
8
+ import { HtPayloadNode } from './payload'
9
+ import { HtStartNode } from './start'
10
+ import { HtTextNode } from './text'
11
+ import { HtUrlNode } from './url'
12
+ import { HtVideoNode } from './video'
13
+ import { HtWhatsappButtonListNode } from './whatsapp-button-list'
14
+
15
+ export type HtNodeWithContent =
16
+ | HtTextNode
17
+ | HtImageNode
18
+ | HtVideoNode
19
+ | HtCarouselNode
20
+ | HtHandoffNode
21
+ | HtKeywordNode
22
+ | HtIntentNode
23
+ | HtFunctionNode
24
+ | HtFallbackNode
25
+ | HtWhatsappButtonListNode
26
+
27
+ export type HtNodeWithoutContent = HtUrlNode | HtPayloadNode
28
+
29
+ export type HtNodeComponent =
30
+ | HtNodeWithContent
31
+ | HtNodeWithoutContent
32
+ | HtStartNode
@@ -0,0 +1,9 @@
1
+ import { HtNodeWithoutContentType } from './node-types'
2
+
3
+ export interface HtPayloadNode {
4
+ id: string
5
+ type: HtNodeWithoutContentType.PAYLOAD
6
+ content: {
7
+ payload: string
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ import { HtNodeLink } from './common'
2
+ import { HtNodeStartType } from './node-types'
3
+
4
+ export interface HtStartNode {
5
+ id: string
6
+ type: HtNodeStartType.STARTUP
7
+ target: HtNodeLink
8
+ }
@@ -0,0 +1,12 @@
1
+ import { HtButton } from './button'
2
+ import { HtBaseNode, HtTextLocale } from './common'
3
+ import { HtButtonStyle, HtNodeWithContentType } from './node-types'
4
+
5
+ export interface HtTextNode extends HtBaseNode {
6
+ type: HtNodeWithContentType.TEXT
7
+ content: {
8
+ text: HtTextLocale[]
9
+ buttons_style?: HtButtonStyle
10
+ buttons: HtButton[]
11
+ }
12
+ }
@@ -0,0 +1,9 @@
1
+ import { HtNodeWithoutContentType } from './node-types'
2
+
3
+ export interface HtUrlNode {
4
+ id: string
5
+ type: HtNodeWithoutContentType.URL
6
+ content: {
7
+ url: string
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ import { HtBaseNode, HtVideoLocale } from './common'
2
+ import { HtNodeWithContentType } from './node-types'
3
+
4
+ export interface HtVideoNode extends HtBaseNode {
5
+ type: HtNodeWithContentType.VIDEO
6
+ content: {
7
+ video: HtVideoLocale[]
8
+ }
9
+ }
@@ -0,0 +1,25 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { HtBaseNode, HtNodeLink, HtTextLocale } from './common'
3
+ import { HtNodeWithContentType } from './node-types'
4
+
5
+ export interface HtWhatsappButtonListRow {
6
+ id: string
7
+ text: HtTextLocale[]
8
+ description: HtTextLocale[]
9
+ target?: HtNodeLink
10
+ }
11
+
12
+ export interface HtWhatsappButtonListSection {
13
+ id: string
14
+ title: HtTextLocale[]
15
+ rows: HtWhatsappButtonListRow[]
16
+ }
17
+
18
+ export interface HtWhatsappButtonListNode extends HtBaseNode {
19
+ type: HtNodeWithContentType.WHATSAPP_BUTTON_LIST
20
+ content: {
21
+ text: HtTextLocale[]
22
+ button_text: HtTextLocale[]
23
+ sections: HtWhatsappButtonListSection[]
24
+ }
25
+ }
@@ -1,8 +1,17 @@
1
+ import { FlowCarousel } from './flow-carousel'
2
+ import { FlowImage } from './flow-image'
3
+ import { FlowText } from './flow-text'
4
+ import { FlowVideo } from './flow-video'
5
+ import { FlowWhatsappButtonList } from './whatsapp-button-list/flow-whatsapp-button-list'
6
+
1
7
  export { ContentFieldsBase } from './content-fields-base'
2
8
  export { FlowButton } from './flow-button'
3
- export { FlowCarousel } from './flow-carousel'
4
9
  export { FlowElement } from './flow-element'
5
- export { FlowImage } from './flow-image'
6
- export { FlowText } from './flow-text'
7
- export { FlowVideo } from './flow-video'
8
- export type { FlowContent } from './types'
10
+ export { FlowCarousel, FlowImage, FlowText, FlowVideo, FlowWhatsappButtonList }
11
+
12
+ export type FlowContent =
13
+ | FlowCarousel
14
+ | FlowImage
15
+ | FlowText
16
+ | FlowVideo
17
+ | FlowWhatsappButtonList
@@ -0,0 +1,33 @@
1
+ import { WhatsappButtonListRowProps } from '@botonic/react/lib/cjs/components/whatsapp-button-list'
2
+
3
+ import { ContentFieldsBase } from '../content-fields-base'
4
+ import { HtWhatsappButtonListRow } from '../hubtype-fields'
5
+
6
+ export class FlowWhatsappButtonListRow extends ContentFieldsBase {
7
+ public title = ''
8
+ public description = ''
9
+ public targetId?: string
10
+
11
+ static fromHubtypeCMS(
12
+ component: HtWhatsappButtonListRow,
13
+ locale: string
14
+ ): FlowWhatsappButtonListRow {
15
+ const newRow = new FlowWhatsappButtonListRow(component.id)
16
+ newRow.title = this.getTextByLocale(locale, component.text)
17
+ newRow.description = this.getTextByLocale(locale, component.description)
18
+ newRow.targetId = component.target?.id
19
+ return newRow
20
+ }
21
+
22
+ toBotonic(): WhatsappButtonListRowProps | undefined {
23
+ if (!this.targetId) {
24
+ console.error(`Row with title: '${this.title}' has no target`)
25
+ return undefined
26
+ }
27
+ return {
28
+ id: this.targetId,
29
+ title: this.title,
30
+ description: this.description,
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,35 @@
1
+ import {
2
+ WhatsappButtonListRowProps,
3
+ WhatsappButtonListSectionProps,
4
+ } from '@botonic/react/lib/cjs/components/whatsapp-button-list'
5
+
6
+ import { HtWhatsappButtonListSection } from '../hubtype-fields'
7
+ import { ContentFieldsBase } from './../content-fields-base'
8
+ import { FlowWhatsappButtonListRow } from './flow-whatsapp-button-list-row'
9
+
10
+ export class FlowWhatsappButtonListSection extends ContentFieldsBase {
11
+ public title = ''
12
+ public rows: FlowWhatsappButtonListRow[] = []
13
+
14
+ static fromHubtypeCMS(
15
+ component: HtWhatsappButtonListSection,
16
+ locale: string
17
+ ): FlowWhatsappButtonListSection {
18
+ const newButton = new FlowWhatsappButtonListSection(component.id)
19
+ newButton.title = this.getTextByLocale(locale, component.title)
20
+ newButton.rows = component.rows.map(row =>
21
+ FlowWhatsappButtonListRow.fromHubtypeCMS(row, locale)
22
+ )
23
+ return newButton
24
+ }
25
+
26
+ toBotonic(): WhatsappButtonListSectionProps {
27
+ const rows = this.rows.reduce((acc: WhatsappButtonListRowProps[], row) => {
28
+ const botonicRow = row.toBotonic()
29
+ if (botonicRow) acc.push(botonicRow)
30
+ return acc
31
+ }, [])
32
+
33
+ return { title: this.title, rows }
34
+ }
35
+ }
@@ -0,0 +1,46 @@
1
+ import { WhatsappButtonList } from '@botonic/react'
2
+ import React from 'react'
3
+
4
+ import { HtWhatsappButtonListNode } from '../hubtype-fields'
5
+ import { ContentFieldsBase } from './../content-fields-base'
6
+ import { FlowWhatsappButtonListSection } from './flow-whatsapp-button-list-section'
7
+
8
+ export class FlowWhatsappButtonList extends ContentFieldsBase {
9
+ public code = ''
10
+ public text = ''
11
+ public listButtonText = ''
12
+ public sections: FlowWhatsappButtonListSection[] = []
13
+
14
+ static fromHubtypeCMS(
15
+ component: HtWhatsappButtonListNode,
16
+ locale: string
17
+ ): FlowWhatsappButtonList {
18
+ const newWhatsappButtonList = new FlowWhatsappButtonList(component.id)
19
+ newWhatsappButtonList.code = component.code
20
+ newWhatsappButtonList.text = this.getTextByLocale(
21
+ locale,
22
+ component.content.text
23
+ )
24
+ newWhatsappButtonList.listButtonText = this.getTextByLocale(
25
+ locale,
26
+ component.content.button_text
27
+ )
28
+ newWhatsappButtonList.sections = component.content.sections.map(section =>
29
+ FlowWhatsappButtonListSection.fromHubtypeCMS(section, locale)
30
+ )
31
+ return newWhatsappButtonList
32
+ }
33
+
34
+ toBotonic(id: string): JSX.Element {
35
+ return (
36
+ <WhatsappButtonList
37
+ key={id}
38
+ body={this.text}
39
+ action={{
40
+ button: this.listButtonText,
41
+ sections: this.sections.map(section => section.toBotonic()),
42
+ }}
43
+ ></WhatsappButtonList>
44
+ )
45
+ }
46
+ }
@@ -1,5 +1,5 @@
1
- export function conditionalProvider({ session, results }): string {
2
- const provider = session.user.provider
1
+ export function conditionalProvider({ request, results }): string {
2
+ const provider = request.session.user.provider
3
3
  if (results.includes(provider)) return provider
4
4
  return 'default'
5
5
  }
@@ -1,5 +1,7 @@
1
+ import { ActionRequest } from '@botonic/react'
1
2
  import axios from 'axios'
2
3
 
4
+ import { getFlowBuilderPlugin } from '../helpers'
3
5
  import { getWebpackEnvVar } from '../utils'
4
6
 
5
7
  const _HUBTYPE_API_URL_ = getWebpackEnvVar(
@@ -9,11 +11,17 @@ const _HUBTYPE_API_URL_ = getWebpackEnvVar(
9
11
  'https://api.hubtype.com'
10
12
  )
11
13
 
14
+ type ConditionalQueueStatusArgs = {
15
+ request: ActionRequest
16
+ queue_id: string
17
+ queue_name: string
18
+ }
19
+
12
20
  export async function conditionalQueueStatus({
21
+ request,
13
22
  queue_id,
14
- }: {
15
- queue_id: string
16
- }): Promise<string> {
23
+ queue_name,
24
+ }: ConditionalQueueStatusArgs): Promise<string> {
17
25
  const response = await axios.get(
18
26
  `${_HUBTYPE_API_URL_}/v1/queues/${queue_id}/availability/`,
19
27
  // TODO: Make it configurable in the future
@@ -26,5 +34,16 @@ export async function conditionalQueueStatus({
26
34
  }
27
35
  )
28
36
  const isAvailable = response.data.available
37
+
38
+ const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
39
+ if (flowBuilderPlugin.trackEvent) {
40
+ const eventName = `QUEUE_${isAvailable ? 'OPEN' : 'CLOSED'}`
41
+ const args = {
42
+ queue_id,
43
+ queue_name,
44
+ }
45
+ await flowBuilderPlugin.trackEvent(request, eventName, args)
46
+ }
47
+
29
48
  return isAvailable ? 'open' : 'closed'
30
49
  }
package/src/handoff.ts CHANGED
@@ -1,21 +1,27 @@
1
1
  import { HandOffBuilder } from '@botonic/core'
2
2
  import { ActionRequest } from '@botonic/react'
3
3
 
4
- import { HandoffNode, PayloadNode } from './flow-builder-models'
4
+ import { HtHandoffNode, HtPayloadNode } from './content-fields/hubtype-fields'
5
5
  import { getFlowBuilderPlugin } from './helpers'
6
+ import BotonicPluginFlowBuilder from './index'
6
7
 
7
8
  export async function doHandoff(
8
9
  request: ActionRequest,
9
10
  locale: string,
10
- handoffNode: HandoffNode
11
+ handoffNode: HtHandoffNode
11
12
  ): Promise<void> {
13
+ const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
12
14
  // @ts-ignore
13
15
  const handOffBuilder = new HandOffBuilder(request.session)
14
16
  const handoffQueues = handoffNode.content.queue
15
17
  const queueFound = handoffQueues.find(q => q.locale === locale)
16
18
  if (queueFound) handOffBuilder.withQueue(queueFound.id)
17
19
 
18
- const onFinishPayload = await getOnFinishPayload(handoffNode, locale, request)
20
+ const onFinishPayload = await getOnFinishPayload(
21
+ flowBuilderPlugin,
22
+ handoffNode,
23
+ locale
24
+ )
19
25
  if (onFinishPayload) handOffBuilder.withOnFinishPayload(onFinishPayload)
20
26
  if (handoffNode.content.has_auto_assign) {
21
27
  handOffBuilder.withAutoAssignOnWaiting(true)
@@ -36,19 +42,26 @@ export async function doHandoff(
36
42
  // }
37
43
 
38
44
  await handOffBuilder.handOff()
45
+
46
+ if (flowBuilderPlugin.trackEvent) {
47
+ await flowBuilderPlugin.trackEvent(request, 'HANDOFF_SUCCESSFULL', {
48
+ queue_id: queueFound?.id,
49
+ queue_name: queueFound?.name,
50
+ })
51
+ }
39
52
  }
40
53
 
41
54
  async function getOnFinishPayload(
42
- handoffNode: HandoffNode,
43
- locale: string,
44
- request: ActionRequest
55
+ flowBuilderPlugin: BotonicPluginFlowBuilder,
56
+ handoffNode: HtHandoffNode,
57
+ locale: string
45
58
  ): Promise<string | undefined> {
46
- const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
47
-
48
- const handoffTargetNode = await flowBuilderPlugin.getHandoffContent(
49
- handoffNode.target?.id
50
- )
51
- if (handoffTargetNode?.id) return handoffTargetNode?.id
59
+ if (handoffNode.target?.id) {
60
+ const handoffTargetNode = flowBuilderPlugin.cmsApi.getNode<HtHandoffNode>(
61
+ handoffNode.target?.id
62
+ )
63
+ if (handoffTargetNode?.id) return handoffTargetNode?.id
64
+ }
52
65
 
53
66
  const payloadId = handoffNode.content.payload.find(
54
67
  payload => payload.locale === locale
@@ -56,7 +69,7 @@ async function getOnFinishPayload(
56
69
 
57
70
  if (!payloadId) return undefined
58
71
 
59
- const actionPayload = await flowBuilderPlugin.getContent(payloadId)
72
+ const actionPayload = flowBuilderPlugin.cmsApi.getNode(payloadId)
60
73
 
61
- return (actionPayload as PayloadNode).content.payload
74
+ return (actionPayload as HtPayloadNode).content.payload
62
75
  }
package/src/helpers.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { Plugin } from '@botonic/core'
2
+
3
+ import {
4
+ HtHandoffNode,
5
+ HtNodeWithContent,
6
+ HtNodeWithContentType,
7
+ } from './content-fields/hubtype-fields'
2
8
  import BotonicPluginFlowBuilder from './index'
3
- import { NodeComponent } from './flow-builder-models'
4
9
 
5
10
  const FLOW_BUILDER_PLUGIN_NAME = 'BotonicPluginFlowBuilder'
6
11
 
@@ -18,22 +23,6 @@ export function getFlowBuilderPlugin(plugins: {
18
23
  return flowBuilderPlugin
19
24
  }
20
25
 
21
- export async function updateButtonUrls(
22
- hubtypeContent: any,
23
- contentKey: string,
24
- getContentFn: any
25
- ): Promise<void> {
26
- if (hubtypeContent.content[contentKey]) {
27
- for (const i in hubtypeContent.content[contentKey]) {
28
- const button = hubtypeContent.content[contentKey][i].button
29
- if (button?.url) {
30
- for (const j in button.url) {
31
- button.url[j] = {
32
- ...button.url[j],
33
- ...(await getContentFn(button.url[j].id)),
34
- }
35
- }
36
- }
37
- }
38
- }
26
+ export function isHandoffNode(node: HtNodeWithContent): node is HtHandoffNode {
27
+ return node.type === HtNodeWithContentType.HANDOFF
39
28
  }