@botonic/plugin-flow-builder 0.43.2 → 0.44.0-alpha.0

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 (312) hide show
  1. package/lib/cjs/action/ai-agent.js +55 -61
  2. package/lib/cjs/action/ai-agent.js.map +1 -1
  3. package/lib/cjs/action/fallback.js +28 -32
  4. package/lib/cjs/action/fallback.js.map +1 -1
  5. package/lib/cjs/action/first-interaction.js +61 -71
  6. package/lib/cjs/action/first-interaction.js.map +1 -1
  7. package/lib/cjs/action/index.js +66 -79
  8. package/lib/cjs/action/index.js.map +1 -1
  9. package/lib/cjs/action/knowledge-bases.js +64 -72
  10. package/lib/cjs/action/knowledge-bases.js.map +1 -1
  11. package/lib/cjs/action/payload.js +61 -70
  12. package/lib/cjs/action/payload.js.map +1 -1
  13. package/lib/cjs/api.d.ts +7 -2
  14. package/lib/cjs/api.js +58 -36
  15. package/lib/cjs/api.js.map +1 -1
  16. package/lib/cjs/constants.d.ts +1 -1
  17. package/lib/cjs/content-fields/content-fields-base.js +3 -6
  18. package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
  19. package/lib/cjs/content-fields/flow-ai-agent.d.ts +0 -1
  20. package/lib/cjs/content-fields/flow-ai-agent.js +4 -7
  21. package/lib/cjs/content-fields/flow-ai-agent.js.map +1 -1
  22. package/lib/cjs/content-fields/flow-bot-action.d.ts +0 -1
  23. package/lib/cjs/content-fields/flow-bot-action.js +14 -17
  24. package/lib/cjs/content-fields/flow-bot-action.js.map +1 -1
  25. package/lib/cjs/content-fields/flow-button.d.ts +0 -1
  26. package/lib/cjs/content-fields/flow-button.js +10 -16
  27. package/lib/cjs/content-fields/flow-button.js.map +1 -1
  28. package/lib/cjs/content-fields/flow-capture-user-input.d.ts +13 -0
  29. package/lib/cjs/content-fields/flow-capture-user-input.js +43 -0
  30. package/lib/cjs/content-fields/flow-capture-user-input.js.map +1 -0
  31. package/lib/cjs/content-fields/flow-carousel.d.ts +0 -1
  32. package/lib/cjs/content-fields/flow-carousel.js +16 -23
  33. package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
  34. package/lib/cjs/content-fields/flow-channel-conditional.d.ts +0 -1
  35. package/lib/cjs/content-fields/flow-channel-conditional.js +14 -17
  36. package/lib/cjs/content-fields/flow-channel-conditional.js.map +1 -1
  37. package/lib/cjs/content-fields/flow-country-conditional.d.ts +0 -1
  38. package/lib/cjs/content-fields/flow-country-conditional.js +17 -21
  39. package/lib/cjs/content-fields/flow-country-conditional.js.map +1 -1
  40. package/lib/cjs/content-fields/flow-custom-conditional.js +18 -22
  41. package/lib/cjs/content-fields/flow-custom-conditional.js.map +1 -1
  42. package/lib/cjs/content-fields/flow-element.d.ts +0 -1
  43. package/lib/cjs/content-fields/flow-element.js +5 -9
  44. package/lib/cjs/content-fields/flow-element.js.map +1 -1
  45. package/lib/cjs/content-fields/flow-go-to-flow.d.ts +0 -1
  46. package/lib/cjs/content-fields/flow-go-to-flow.js +15 -18
  47. package/lib/cjs/content-fields/flow-go-to-flow.js.map +1 -1
  48. package/lib/cjs/content-fields/flow-handoff.d.ts +0 -1
  49. package/lib/cjs/content-fields/flow-handoff.js +29 -35
  50. package/lib/cjs/content-fields/flow-handoff.js.map +1 -1
  51. package/lib/cjs/content-fields/flow-image.d.ts +0 -1
  52. package/lib/cjs/content-fields/flow-image.js +2 -5
  53. package/lib/cjs/content-fields/flow-image.js.map +1 -1
  54. package/lib/cjs/content-fields/flow-knowledge-base.d.ts +0 -1
  55. package/lib/cjs/content-fields/flow-knowledge-base.js +5 -8
  56. package/lib/cjs/content-fields/flow-knowledge-base.js.map +1 -1
  57. package/lib/cjs/content-fields/flow-queue-status-conditional.d.ts +0 -1
  58. package/lib/cjs/content-fields/flow-queue-status-conditional.js +55 -65
  59. package/lib/cjs/content-fields/flow-queue-status-conditional.js.map +1 -1
  60. package/lib/cjs/content-fields/flow-rating.d.ts +0 -1
  61. package/lib/cjs/content-fields/flow-rating.js +2 -5
  62. package/lib/cjs/content-fields/flow-rating.js.map +1 -1
  63. package/lib/cjs/content-fields/flow-text.d.ts +0 -1
  64. package/lib/cjs/content-fields/flow-text.js +5 -8
  65. package/lib/cjs/content-fields/flow-text.js.map +1 -1
  66. package/lib/cjs/content-fields/flow-video.d.ts +0 -1
  67. package/lib/cjs/content-fields/flow-video.js +2 -5
  68. package/lib/cjs/content-fields/flow-video.js.map +1 -1
  69. package/lib/cjs/content-fields/flow-webview.js +15 -18
  70. package/lib/cjs/content-fields/flow-webview.js.map +1 -1
  71. package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.d.ts +0 -1
  72. package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js +3 -6
  73. package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
  74. package/lib/cjs/content-fields/flow-whatsapp-template.d.ts +0 -1
  75. package/lib/cjs/content-fields/flow-whatsapp-template.js +6 -12
  76. package/lib/cjs/content-fields/flow-whatsapp-template.js.map +1 -1
  77. package/lib/cjs/content-fields/hubtype-fields/capture-user-input.d.ts +19 -0
  78. package/lib/cjs/content-fields/hubtype-fields/capture-user-input.js +12 -0
  79. package/lib/cjs/content-fields/hubtype-fields/capture-user-input.js.map +1 -0
  80. package/lib/cjs/content-fields/hubtype-fields/function.js +1 -1
  81. package/lib/cjs/content-fields/hubtype-fields/function.js.map +1 -1
  82. package/lib/cjs/content-fields/hubtype-fields/index.d.ts +1 -0
  83. package/lib/cjs/content-fields/hubtype-fields/index.js +1 -0
  84. package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -1
  85. package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +2 -1
  86. package/lib/cjs/content-fields/hubtype-fields/node-types.js +4 -3
  87. package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
  88. package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +2 -1
  89. package/lib/cjs/content-fields/hubtype-fields/rating.js +1 -1
  90. package/lib/cjs/content-fields/hubtype-fields/rating.js.map +1 -1
  91. package/lib/cjs/content-fields/index.d.ts +3 -2
  92. package/lib/cjs/content-fields/index.js +3 -1
  93. package/lib/cjs/content-fields/index.js.map +1 -1
  94. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +2 -5
  95. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
  96. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +2 -5
  97. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
  98. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +0 -1
  99. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +3 -6
  100. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
  101. package/lib/cjs/filters/index.js +5 -8
  102. package/lib/cjs/filters/index.js.map +1 -1
  103. package/lib/cjs/flow-factory.js +49 -51
  104. package/lib/cjs/flow-factory.js.map +1 -1
  105. package/lib/cjs/functions/index.js +18 -21
  106. package/lib/cjs/functions/index.js.map +1 -1
  107. package/lib/cjs/helpers.js +1 -2
  108. package/lib/cjs/helpers.js.map +1 -1
  109. package/lib/cjs/index.js +68 -73
  110. package/lib/cjs/index.js.map +1 -1
  111. package/lib/cjs/services/hubtype-queues-api.js +10 -12
  112. package/lib/cjs/services/hubtype-queues-api.js.map +1 -1
  113. package/lib/cjs/tracking.d.ts +1 -1
  114. package/lib/cjs/tracking.js +33 -43
  115. package/lib/cjs/tracking.js.map +1 -1
  116. package/lib/cjs/types.js +2 -2
  117. package/lib/cjs/types.js.map +1 -1
  118. package/lib/cjs/user-input/capture-user-input-api.d.ts +20 -0
  119. package/lib/cjs/user-input/capture-user-input-api.js +84 -0
  120. package/lib/cjs/user-input/capture-user-input-api.js.map +1 -0
  121. package/lib/cjs/user-input/index.d.ts +1 -2
  122. package/lib/cjs/user-input/index.js +25 -24
  123. package/lib/cjs/user-input/index.js.map +1 -1
  124. package/lib/cjs/user-input/keyword.js +31 -36
  125. package/lib/cjs/user-input/keyword.js.map +1 -1
  126. package/lib/cjs/user-input/smart-intent.js +55 -59
  127. package/lib/cjs/user-input/smart-intent.js.map +1 -1
  128. package/lib/cjs/utils.js +7 -9
  129. package/lib/cjs/utils.js.map +1 -1
  130. package/lib/cjs/webview/contents-context.d.ts +0 -1
  131. package/lib/cjs/webview/types.js +1 -1
  132. package/lib/cjs/webview/types.js.map +1 -1
  133. package/lib/cjs/webview/use-webview-contents.js +10 -9
  134. package/lib/cjs/webview/use-webview-contents.js.map +1 -1
  135. package/lib/esm/action/ai-agent.js +61 -63
  136. package/lib/esm/action/ai-agent.js.map +1 -1
  137. package/lib/esm/action/fallback.js +32 -32
  138. package/lib/esm/action/fallback.js.map +1 -1
  139. package/lib/esm/action/first-interaction.js +69 -75
  140. package/lib/esm/action/first-interaction.js.map +1 -1
  141. package/lib/esm/action/index.js +93 -101
  142. package/lib/esm/action/index.js.map +1 -1
  143. package/lib/esm/action/knowledge-bases.js +71 -75
  144. package/lib/esm/action/knowledge-bases.js.map +1 -1
  145. package/lib/esm/action/payload.js +67 -72
  146. package/lib/esm/action/payload.js.map +1 -1
  147. package/lib/esm/api.d.ts +7 -2
  148. package/lib/esm/api.js +77 -51
  149. package/lib/esm/api.js.map +1 -1
  150. package/lib/esm/constants.d.ts +1 -1
  151. package/lib/esm/constants.js +17 -14
  152. package/lib/esm/constants.js.map +1 -1
  153. package/lib/esm/content-fields/content-fields-base.js +13 -12
  154. package/lib/esm/content-fields/content-fields-base.js.map +1 -1
  155. package/lib/esm/content-fields/flow-ai-agent.d.ts +0 -1
  156. package/lib/esm/content-fields/flow-ai-agent.js +18 -17
  157. package/lib/esm/content-fields/flow-ai-agent.js.map +1 -1
  158. package/lib/esm/content-fields/flow-bot-action.d.ts +0 -1
  159. package/lib/esm/content-fields/flow-bot-action.js +25 -24
  160. package/lib/esm/content-fields/flow-bot-action.js.map +1 -1
  161. package/lib/esm/content-fields/flow-button.d.ts +0 -1
  162. package/lib/esm/content-fields/flow-button.js +25 -27
  163. package/lib/esm/content-fields/flow-button.js.map +1 -1
  164. package/lib/esm/content-fields/flow-capture-user-input.d.ts +13 -0
  165. package/lib/esm/content-fields/flow-capture-user-input.js +43 -0
  166. package/lib/esm/content-fields/flow-capture-user-input.js.map +1 -0
  167. package/lib/esm/content-fields/flow-carousel.d.ts +0 -1
  168. package/lib/esm/content-fields/flow-carousel.js +39 -42
  169. package/lib/esm/content-fields/flow-carousel.js.map +1 -1
  170. package/lib/esm/content-fields/flow-channel-conditional.d.ts +0 -1
  171. package/lib/esm/content-fields/flow-channel-conditional.js +24 -23
  172. package/lib/esm/content-fields/flow-channel-conditional.js.map +1 -1
  173. package/lib/esm/content-fields/flow-country-conditional.d.ts +0 -1
  174. package/lib/esm/content-fields/flow-country-conditional.js +27 -27
  175. package/lib/esm/content-fields/flow-country-conditional.js.map +1 -1
  176. package/lib/esm/content-fields/flow-custom-conditional.js +30 -30
  177. package/lib/esm/content-fields/flow-custom-conditional.js.map +1 -1
  178. package/lib/esm/content-fields/flow-element.d.ts +0 -1
  179. package/lib/esm/content-fields/flow-element.js +16 -16
  180. package/lib/esm/content-fields/flow-element.js.map +1 -1
  181. package/lib/esm/content-fields/flow-go-to-flow.d.ts +0 -1
  182. package/lib/esm/content-fields/flow-go-to-flow.js +25 -24
  183. package/lib/esm/content-fields/flow-go-to-flow.js.map +1 -1
  184. package/lib/esm/content-fields/flow-handoff.d.ts +0 -1
  185. package/lib/esm/content-fields/flow-handoff.js +40 -42
  186. package/lib/esm/content-fields/flow-handoff.js.map +1 -1
  187. package/lib/esm/content-fields/flow-image.d.ts +0 -1
  188. package/lib/esm/content-fields/flow-image.js +12 -11
  189. package/lib/esm/content-fields/flow-image.js.map +1 -1
  190. package/lib/esm/content-fields/flow-knowledge-base.d.ts +0 -1
  191. package/lib/esm/content-fields/flow-knowledge-base.js +15 -14
  192. package/lib/esm/content-fields/flow-knowledge-base.js.map +1 -1
  193. package/lib/esm/content-fields/flow-queue-status-conditional.d.ts +0 -1
  194. package/lib/esm/content-fields/flow-queue-status-conditional.js +67 -73
  195. package/lib/esm/content-fields/flow-queue-status-conditional.js.map +1 -1
  196. package/lib/esm/content-fields/flow-rating.d.ts +0 -1
  197. package/lib/esm/content-fields/flow-rating.js +23 -22
  198. package/lib/esm/content-fields/flow-rating.js.map +1 -1
  199. package/lib/esm/content-fields/flow-text.d.ts +0 -1
  200. package/lib/esm/content-fields/flow-text.js +25 -24
  201. package/lib/esm/content-fields/flow-text.js.map +1 -1
  202. package/lib/esm/content-fields/flow-video.d.ts +0 -1
  203. package/lib/esm/content-fields/flow-video.js +12 -11
  204. package/lib/esm/content-fields/flow-video.js.map +1 -1
  205. package/lib/esm/content-fields/flow-webview.js +23 -22
  206. package/lib/esm/content-fields/flow-webview.js.map +1 -1
  207. package/lib/esm/content-fields/flow-whatsapp-cta-url-button.d.ts +0 -1
  208. package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js +31 -30
  209. package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
  210. package/lib/esm/content-fields/flow-whatsapp-template.d.ts +0 -1
  211. package/lib/esm/content-fields/flow-whatsapp-template.js +45 -47
  212. package/lib/esm/content-fields/flow-whatsapp-template.js.map +1 -1
  213. package/lib/esm/content-fields/hubtype-fields/ai-agent.js +2 -1
  214. package/lib/esm/content-fields/hubtype-fields/bot-action.js +2 -1
  215. package/lib/esm/content-fields/hubtype-fields/button.js +2 -1
  216. package/lib/esm/content-fields/hubtype-fields/capture-user-input.d.ts +19 -0
  217. package/lib/esm/content-fields/hubtype-fields/capture-user-input.js +12 -0
  218. package/lib/esm/content-fields/hubtype-fields/capture-user-input.js.map +1 -0
  219. package/lib/esm/content-fields/hubtype-fields/carousel.js +2 -1
  220. package/lib/esm/content-fields/hubtype-fields/channel-conditional.js +2 -1
  221. package/lib/esm/content-fields/hubtype-fields/common.js +2 -1
  222. package/lib/esm/content-fields/hubtype-fields/country-conditional.js +2 -1
  223. package/lib/esm/content-fields/hubtype-fields/custom-conditional.js +2 -1
  224. package/lib/esm/content-fields/hubtype-fields/fallback.js +2 -1
  225. package/lib/esm/content-fields/hubtype-fields/function.js +5 -2
  226. package/lib/esm/content-fields/hubtype-fields/function.js.map +1 -1
  227. package/lib/esm/content-fields/hubtype-fields/go-to-flow.js +2 -1
  228. package/lib/esm/content-fields/hubtype-fields/handoff.js +2 -1
  229. package/lib/esm/content-fields/hubtype-fields/image.js +2 -1
  230. package/lib/esm/content-fields/hubtype-fields/index.d.ts +1 -0
  231. package/lib/esm/content-fields/hubtype-fields/index.js +27 -23
  232. package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -1
  233. package/lib/esm/content-fields/hubtype-fields/keyword.js +2 -1
  234. package/lib/esm/content-fields/hubtype-fields/knowledge-base.js +2 -1
  235. package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +2 -1
  236. package/lib/esm/content-fields/hubtype-fields/node-types.js +10 -6
  237. package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
  238. package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +2 -1
  239. package/lib/esm/content-fields/hubtype-fields/nodes.js +2 -1
  240. package/lib/esm/content-fields/hubtype-fields/payload.js +2 -1
  241. package/lib/esm/content-fields/hubtype-fields/queue-status-conditional.js +2 -1
  242. package/lib/esm/content-fields/hubtype-fields/rating.js +5 -2
  243. package/lib/esm/content-fields/hubtype-fields/rating.js.map +1 -1
  244. package/lib/esm/content-fields/hubtype-fields/smart-intent.js +2 -1
  245. package/lib/esm/content-fields/hubtype-fields/text.js +2 -1
  246. package/lib/esm/content-fields/hubtype-fields/url.js +2 -1
  247. package/lib/esm/content-fields/hubtype-fields/video.js +2 -1
  248. package/lib/esm/content-fields/hubtype-fields/webview.js +2 -1
  249. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js +2 -1
  250. package/lib/esm/content-fields/hubtype-fields/whatsapp-cta-url-button.js +2 -1
  251. package/lib/esm/content-fields/hubtype-fields/whatsapp-template.js +2 -1
  252. package/lib/esm/content-fields/index.d.ts +3 -2
  253. package/lib/esm/content-fields/index.js +46 -22
  254. package/lib/esm/content-fields/index.js.map +1 -1
  255. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +10 -9
  256. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
  257. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +10 -9
  258. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
  259. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +0 -1
  260. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +18 -17
  261. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
  262. package/lib/esm/filters/index.js +10 -9
  263. package/lib/esm/filters/index.js.map +1 -1
  264. package/lib/esm/flow-factory.js +56 -54
  265. package/lib/esm/flow-factory.js.map +1 -1
  266. package/lib/esm/functions/index.js +24 -22
  267. package/lib/esm/functions/index.js.map +1 -1
  268. package/lib/esm/helpers.js +4 -1
  269. package/lib/esm/helpers.js.map +1 -1
  270. package/lib/esm/index.js +101 -99
  271. package/lib/esm/index.js.map +1 -1
  272. package/lib/esm/services/hubtype-queues-api.js +17 -15
  273. package/lib/esm/services/hubtype-queues-api.js.map +1 -1
  274. package/lib/esm/tracking.d.ts +1 -1
  275. package/lib/esm/tracking.js +42 -45
  276. package/lib/esm/tracking.js.map +1 -1
  277. package/lib/esm/types.js +7 -4
  278. package/lib/esm/types.js.map +1 -1
  279. package/lib/esm/user-input/capture-user-input-api.d.ts +20 -0
  280. package/lib/esm/user-input/capture-user-input-api.js +84 -0
  281. package/lib/esm/user-input/capture-user-input-api.js.map +1 -0
  282. package/lib/esm/user-input/index.d.ts +1 -2
  283. package/lib/esm/user-input/index.js +30 -25
  284. package/lib/esm/user-input/index.js.map +1 -1
  285. package/lib/esm/user-input/keyword.js +40 -41
  286. package/lib/esm/user-input/keyword.js.map +1 -1
  287. package/lib/esm/user-input/smart-intent.js +65 -65
  288. package/lib/esm/user-input/smart-intent.js.map +1 -1
  289. package/lib/esm/utils.js +22 -15
  290. package/lib/esm/utils.js.map +1 -1
  291. package/lib/esm/webview/contents-context.d.ts +0 -1
  292. package/lib/esm/webview/contents-context.js +6 -2
  293. package/lib/esm/webview/contents-context.js.map +1 -1
  294. package/lib/esm/webview/index.js +9 -3
  295. package/lib/esm/webview/index.js.map +1 -1
  296. package/lib/esm/webview/types.js +5 -2
  297. package/lib/esm/webview/types.js.map +1 -1
  298. package/lib/esm/webview/use-webview-contents.js +28 -23
  299. package/lib/esm/webview/use-webview-contents.js.map +1 -1
  300. package/package.json +2 -2
  301. package/src/api.ts +35 -1
  302. package/src/content-fields/flow-capture-user-input.tsx +45 -0
  303. package/src/content-fields/hubtype-fields/capture-user-input.ts +21 -0
  304. package/src/content-fields/hubtype-fields/index.ts +1 -0
  305. package/src/content-fields/hubtype-fields/node-types.ts +1 -0
  306. package/src/content-fields/hubtype-fields/nodes.ts +2 -0
  307. package/src/content-fields/index.ts +3 -0
  308. package/src/flow-factory.ts +4 -0
  309. package/src/index.ts +4 -3
  310. package/src/tracking.ts +2 -2
  311. package/src/user-input/capture-user-input-api.ts +134 -0
  312. package/src/user-input/index.ts +13 -8
@@ -1 +1 @@
1
- {"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAA8B,EAAE,CAC1E,aAAa,CAAgC;IAC3C,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS;IACjC,QAAQ,EAAE,EAA6B;CACxC,CAAC,CAAA"}
1
+ {"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAI9B,MAAM,4BAA4B,GAAG,GAA8B,EAAE,CAC1E,IAAA,qBAAa,EAAgC;IAC3C,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS;IACjC,QAAQ,EAAE,EAA6B;CACxC,CAAC,CAAA;AANS,QAAA,4BAA4B,gCAMrC"}
@@ -1,4 +1,10 @@
1
- export { createWebviewContentsContext } from './contents-context';
2
- export * from './types';
3
- export { useWebviewContents } from './use-webview-contents';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useWebviewContents = exports.createWebviewContentsContext = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var contents_context_1 = require("./contents-context");
6
+ Object.defineProperty(exports, "createWebviewContentsContext", { enumerable: true, get: function () { return contents_context_1.createWebviewContentsContext; } });
7
+ tslib_1.__exportStar(require("./types"), exports);
8
+ var use_webview_contents_1 = require("./use-webview-contents");
9
+ Object.defineProperty(exports, "useWebviewContents", { enumerable: true, get: function () { return use_webview_contents_1.useWebviewContents; } });
4
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACjE,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webview/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAiE;AAAxD,gIAAA,4BAA4B,OAAA;AACrC,kDAAuB;AACvB,+DAA2D;AAAlD,0HAAA,kBAAkB,OAAA"}
@@ -1,6 +1,9 @@
1
- export var WebviewContentType;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebviewContentType = void 0;
4
+ var WebviewContentType;
2
5
  (function (WebviewContentType) {
3
6
  WebviewContentType["TEXT"] = "webview-text";
4
7
  WebviewContentType["IMAGE"] = "webview-image";
5
- })(WebviewContentType || (WebviewContentType = {}));
8
+ })(WebviewContentType || (exports.WebviewContentType = WebviewContentType = {}));
6
9
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/webview/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,2CAAqB,CAAA;IACrB,6CAAuB,CAAA;AACzB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/webview/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,2CAAqB,CAAA;IACrB,6CAAuB,CAAA;AACzB,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B"}
@@ -1,15 +1,18 @@
1
- import { __awaiter } from "tslib";
2
- import axios from 'axios';
3
- import { useEffect, useState } from 'react';
4
- import { FLOW_BUILDER_API_URL_PROD } from '../constants';
5
- import { FlowBuilderJSONVersion } from '../types';
6
- import { WebviewContentType, } from './types';
7
- export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version = FlowBuilderJSONVersion.LATEST, botId, webviewId, providerId, locale, mapContents, }) {
8
- const [textContents, setTextContents] = useState();
9
- const [imageContents, setImageContents] = useState();
10
- const [contents, setContents] = useState({});
11
- const [currentLocale, setCurrentLocale] = useState(locale);
12
- const [error, setError] = useState(false);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useWebviewContents = useWebviewContents;
4
+ const tslib_1 = require("tslib");
5
+ const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const react_1 = require("react");
7
+ const constants_1 = require("../constants");
8
+ const types_1 = require("../types");
9
+ const types_2 = require("./types");
10
+ function useWebviewContents({ apiUrl = constants_1.FLOW_BUILDER_API_URL_PROD, version = types_1.FlowBuilderJSONVersion.LATEST, botId, webviewId, providerId, locale, mapContents, }) {
11
+ const [textContents, setTextContents] = (0, react_1.useState)();
12
+ const [imageContents, setImageContents] = (0, react_1.useState)();
13
+ const [contents, setContents] = (0, react_1.useState)({});
14
+ const [currentLocale, setCurrentLocale] = (0, react_1.useState)(locale);
15
+ const [error, setError] = (0, react_1.useState)(false);
13
16
  const updateCurrentLocale = (textContents) => {
14
17
  if (!textContents || textContents.length === 0) {
15
18
  console.log('There is no text contents to check the locale');
@@ -28,16 +31,18 @@ export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version
28
31
  console.error(`locale: ${currentLocale} cannot be resolved with: ${locales.join(', ')}`);
29
32
  };
30
33
  const getTextContent = (contentID) => {
31
- var _a, _b;
32
- return (((_b = (_a = textContents === null || textContents === void 0 ? void 0 : textContents.find(textContent => textContent.code === contentID)) === null || _a === void 0 ? void 0 : _a.content.text.find(text => text.locale === currentLocale)) === null || _b === void 0 ? void 0 : _b.message) ||
34
+ return (textContents
35
+ ?.find(textContent => textContent.code === contentID)
36
+ ?.content.text.find(text => text.locale === currentLocale)?.message ||
33
37
  '');
34
38
  };
35
39
  const getImageSrc = (contentID) => {
36
- var _a, _b;
37
- return (((_b = (_a = imageContents === null || imageContents === void 0 ? void 0 : imageContents.find(imageContent => imageContent.code === contentID)) === null || _a === void 0 ? void 0 : _a.content.image.find(image => image.locale === currentLocale)) === null || _b === void 0 ? void 0 : _b.file) ||
40
+ return (imageContents
41
+ ?.find(imageContent => imageContent.code === contentID)
42
+ ?.content.image.find(image => image.locale === currentLocale)?.file ||
38
43
  '');
39
44
  };
40
- useEffect(() => {
45
+ (0, react_1.useEffect)(() => {
41
46
  if (textContents || imageContents) {
42
47
  const contentsObject = {};
43
48
  for (const [key, value] of Object.entries(mapContents)) {
@@ -46,14 +51,14 @@ export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version
46
51
  setContents(contentsObject);
47
52
  }
48
53
  }, [textContents, imageContents, currentLocale]);
49
- useEffect(() => {
50
- const getResponseContents = () => __awaiter(this, void 0, void 0, function* () {
54
+ (0, react_1.useEffect)(() => {
55
+ const getResponseContents = async () => {
51
56
  const url = `${apiUrl}/v1/bot_flows/${botId}/versions/${version}/webviews/${webviewId}/?provider_id=${providerId}`;
52
57
  try {
53
- const response = yield axios.get(url);
54
- const textResponseContents = response.data.filter(webviewContent => webviewContent.type === WebviewContentType.TEXT);
58
+ const response = await axios_1.default.get(url);
59
+ const textResponseContents = response.data.filter(webviewContent => webviewContent.type === types_2.WebviewContentType.TEXT);
55
60
  setTextContents(textResponseContents);
56
- const imageResponseContents = response.data.filter(webviewContent => webviewContent.type === WebviewContentType.IMAGE);
61
+ const imageResponseContents = response.data.filter(webviewContent => webviewContent.type === types_2.WebviewContentType.IMAGE);
57
62
  setImageContents(imageResponseContents);
58
63
  updateCurrentLocale(textResponseContents);
59
64
  }
@@ -61,7 +66,7 @@ export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version
61
66
  console.error('Error fetching webview contents:', error);
62
67
  setError(true);
63
68
  }
64
- });
69
+ };
65
70
  getResponseContents();
66
71
  }, []);
67
72
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,sBAAsB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+1,6 @@
1
1
  {
2
2
  "name": "@botonic/plugin-flow-builder",
3
- "version": "0.43.2",
3
+ "version": "0.44.0-alpha.0",
4
4
  "main": "./lib/cjs/index.js",
5
5
  "module": "./lib/esm/index.js",
6
6
  "description": "Use Flow Builder to show your contents",
@@ -14,7 +14,7 @@
14
14
  "lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.ts*'"
15
15
  },
16
16
  "dependencies": {
17
- "@botonic/react": "^0.43.1",
17
+ "@botonic/react": "^0.44.0-alpha.0",
18
18
  "axios": "^1.13.2",
19
19
  "uuid": "^10.0.0"
20
20
  },
package/src/api.ts CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  } from './constants'
10
10
  import {
11
11
  HtBotActionNode,
12
+ HtCaptureUserInputNode,
12
13
  HtFallbackNode,
13
14
  HtFlowBuilderData,
14
15
  HtFlowWebview,
@@ -21,8 +22,8 @@ import {
21
22
  HtPayloadNode,
22
23
  HtRatingButton,
23
24
  HtRatingNode,
25
+ HtSmartIntentNode,
24
26
  } from './content-fields/hubtype-fields'
25
- import { HtSmartIntentNode } from './content-fields/hubtype-fields/smart-intent'
26
27
  import { FlowBuilderApiOptions, ProcessEnvNodeEnvs } from './types'
27
28
 
28
29
  export class FlowBuilderApi {
@@ -265,6 +266,39 @@ export class FlowBuilderApi {
265
266
  return this.flow.webviews.find(webview => webview.id === id)
266
267
  }
267
268
 
269
+ shouldCaptureUserInput(): boolean {
270
+ return !!this.getCaptureUserInputId()
271
+ }
272
+
273
+ getCaptureUserInputId(): string | undefined {
274
+ return this.request.session.capture_user_input?.node_id
275
+ }
276
+
277
+ setCaptureUserInputId(id: string): void {
278
+ if (this.request.session.capture_user_input) {
279
+ this.request.session.capture_user_input.node_id = id
280
+ }
281
+ this.request.session.capture_user_input = { node_id: id }
282
+ }
283
+
284
+ removeCaptureUserInputId(): void {
285
+ this.request.session.capture_user_input = undefined
286
+ }
287
+
288
+ setUserExtraDataVariable(key: string, value: string): void {
289
+ if (this.request.session.user.extra_data) {
290
+ this.request.session.user.extra_data[key] = value
291
+ }
292
+ }
293
+
294
+ getCaptureUserInputNode(): HtCaptureUserInputNode | undefined {
295
+ const captureUserInputId = this.getCaptureUserInputId()
296
+ if (!captureUserInputId) {
297
+ return undefined
298
+ }
299
+ return this.getNodeById<HtCaptureUserInputNode>(captureUserInputId)
300
+ }
301
+
268
302
  getResolvedLocale(): string {
269
303
  const systemLocale = this.request.getSystemLocale()
270
304
 
@@ -0,0 +1,45 @@
1
+ import { ActionRequest } from '@botonic/react'
2
+
3
+ import { getFlowBuilderPlugin } from '../helpers'
4
+ import { ContentFieldsBase } from './content-fields-base'
5
+ import {
6
+ HtAiValidationType,
7
+ HtCaptureUserInputNode,
8
+ } from './hubtype-fields/capture-user-input'
9
+
10
+ export class FlowCaptureUserInput extends ContentFieldsBase {
11
+ public fieldName = ''
12
+ public aiValidationType = HtAiValidationType.NONE
13
+ public aiValidationInstructions = ''
14
+ public captureSuccessId = ''
15
+ public captureFailId = ''
16
+
17
+ static fromHubtypeCMS(cmsText: HtCaptureUserInputNode): FlowCaptureUserInput {
18
+ const newCaptureUserInput = new FlowCaptureUserInput(cmsText.id)
19
+ newCaptureUserInput.code = cmsText.code
20
+ newCaptureUserInput.fieldName = cmsText.content.field_name
21
+ newCaptureUserInput.aiValidationType =
22
+ cmsText.content.ai_validation_type || HtAiValidationType.NONE
23
+ newCaptureUserInput.aiValidationInstructions =
24
+ cmsText.content.ai_validation_instructions || ''
25
+ newCaptureUserInput.captureSuccessId = cmsText.content.capture_success.id
26
+ newCaptureUserInput.captureFailId = cmsText.content.capture_fail.id
27
+ newCaptureUserInput.followUp = undefined
28
+
29
+ return newCaptureUserInput
30
+ }
31
+
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+ async trackFlow(_request: ActionRequest): Promise<void> {
34
+ return
35
+ }
36
+
37
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
+ toBotonic(_id: string, request: ActionRequest): JSX.Element {
39
+ const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
40
+ const cmsApi = flowBuilderPlugin.cmsApi
41
+ cmsApi.setCaptureUserInputId(this.id)
42
+
43
+ return <></>
44
+ }
45
+ }
@@ -0,0 +1,21 @@
1
+ import { HtBaseNode, HtNodeLink } from './common'
2
+ import { HtNodeWithContentType } from './node-types'
3
+
4
+ export enum HtAiValidationType {
5
+ NONE = 'None',
6
+ NAME = 'Name',
7
+ EMAIL = 'Email',
8
+ PHONE = 'Phone number',
9
+ CUSTOM = 'Custom',
10
+ }
11
+
12
+ export interface HtCaptureUserInputNode extends HtBaseNode {
13
+ type: HtNodeWithContentType.CAPTURE_USER_INPUT
14
+ content: {
15
+ field_name: string
16
+ ai_validation_type?: HtAiValidationType
17
+ ai_validation_instructions?: string
18
+ capture_success: HtNodeLink
19
+ capture_fail: HtNodeLink
20
+ }
21
+ }
@@ -1,5 +1,6 @@
1
1
  export * from './bot-action'
2
2
  export * from './button'
3
+ export * from './capture-user-input'
3
4
  export * from './carousel'
4
5
  export * from './common'
5
6
  export * from './fallback'
@@ -17,6 +17,7 @@ export enum HtNodeWithContentType {
17
17
  RATING = 'rating',
18
18
  WEBVIEW = 'webview',
19
19
  GO_TO_FLOW = 'go-to-flow',
20
+ CAPTURE_USER_INPUT = 'capture-user-input',
20
21
  }
21
22
 
22
23
  export enum HtNodeWithoutContentType {
@@ -1,5 +1,6 @@
1
1
  import { HtAiAgentNode } from './ai-agent'
2
2
  import { HtBotActionNode } from './bot-action'
3
+ import { HtCaptureUserInputNode } from './capture-user-input'
3
4
  import { HtCarouselNode } from './carousel'
4
5
  // import { HtChannelConditionalNode } from './channel-conditional'
5
6
  // import { HtCountryConditionalNode } from './country-conditional'
@@ -42,6 +43,7 @@ export type HtNodeWithContent =
42
43
  | HtWebviewNode
43
44
  | HtGoToFlow
44
45
  | HtWhatsappTemplateNode
46
+ | HtCaptureUserInputNode
45
47
  // | HtChannelConditionalNode
46
48
  // | HtCountryConditionalNode
47
49
  // | HtCustomConditionalNode
@@ -1,5 +1,6 @@
1
1
  import { FlowAiAgent } from './flow-ai-agent'
2
2
  import { FlowBotAction } from './flow-bot-action'
3
+ import { FlowCaptureUserInput } from './flow-capture-user-input'
3
4
  import { FlowCarousel } from './flow-carousel'
4
5
  import { FlowChannelConditional } from './flow-channel-conditional'
5
6
  import { FlowCountryConditional } from './flow-country-conditional'
@@ -25,6 +26,7 @@ export { FlowElement } from './flow-element'
25
26
  export {
26
27
  FlowAiAgent,
27
28
  FlowBotAction,
29
+ FlowCaptureUserInput,
28
30
  FlowCarousel,
29
31
  FlowChannelConditional,
30
32
  FlowCountryConditional,
@@ -60,5 +62,6 @@ export type FlowContent =
60
62
  | FlowQueueStatusConditional
61
63
  | FlowCustomConditional
62
64
  | FlowGoToFlow
65
+ | FlowCaptureUserInput
63
66
 
64
67
  export { DISABLED_MEMORY_LENGTH }
@@ -21,6 +21,7 @@ import {
21
21
  FlowWhatsappCtaUrlButtonNode,
22
22
  FlowWhatsappTemplate,
23
23
  } from './content-fields'
24
+ import { FlowCaptureUserInput } from './content-fields/flow-capture-user-input'
24
25
  import {
25
26
  HtFunctionNode,
26
27
  HtNodeComponent,
@@ -94,6 +95,9 @@ export class FlowFactory {
94
95
  case HtNodeWithContentType.WHATSAPP_TEMPLATE:
95
96
  return FlowWhatsappTemplate.fromHubtypeCMS(hubtypeContent)
96
97
 
98
+ case HtNodeWithContentType.CAPTURE_USER_INPUT:
99
+ return FlowCaptureUserInput.fromHubtypeCMS(hubtypeContent)
100
+
97
101
  default:
98
102
  return undefined
99
103
  }
package/src/index.ts CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  RatingSubmittedInfo,
37
37
  TrackEventFunction,
38
38
  } from './types'
39
- import { getNodeByUserInput } from './user-input'
39
+ import { getNextPayloadByUserInput } from './user-input'
40
40
  import { SmartIntentsInferenceConfig } from './user-input/smart-intent'
41
41
  import { inputHasTextData, resolveGetAccessToken } from './utils'
42
42
 
@@ -109,13 +109,13 @@ export default class BotonicPluginFlowBuilder implements Plugin {
109
109
 
110
110
  if (checkUserTextInput) {
111
111
  const resolvedLocale = this.cmsApi.getResolvedLocale()
112
- const nodeByUserInput = await getNodeByUserInput(
112
+ const nextPayload = await getNextPayloadByUserInput(
113
113
  this.cmsApi,
114
114
  resolvedLocale,
115
115
  request as unknown as ActionRequest,
116
116
  this.smartIntentsConfig
117
117
  )
118
- request.input.payload = this.cmsApi.getPayload(nodeByUserInput?.target)
118
+ request.input.payload = nextPayload
119
119
  }
120
120
 
121
121
  this.updateRequestBeforeRoutes(request)
@@ -135,6 +135,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
135
135
  }
136
136
 
137
137
  private updateRequestBeforeRoutes(request: PluginPreRequest): void {
138
+ this.cmsApi.removeCaptureUserInputId()
138
139
  if (request.input.payload) {
139
140
  request.input.payload = this.removeSourceSuffix(request.input.payload)
140
141
 
package/src/tracking.ts CHANGED
@@ -108,11 +108,11 @@ function getCommonFlowContentEventArgs(
108
108
 
109
109
  export function getCommonFlowContentEventArgsForContentId(
110
110
  request: ActionRequest,
111
- contentId: string
111
+ id: string
112
112
  ): CommonFlowContentEventArgs {
113
113
  const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
114
114
  const cmsApi = flowBuilderPlugin.cmsApi
115
- const nodeContent = cmsApi.getNodeById<HtNodeWithContent>(contentId)
115
+ const nodeContent = cmsApi.getNodeById<HtNodeWithContent>(id)
116
116
 
117
117
  return getCommonFlowContentEventArgs(request, nodeContent)
118
118
  }
@@ -0,0 +1,134 @@
1
+ import { EventAction, EventCaptureUserInput } from '@botonic/core'
2
+ import { ActionRequest } from '@botonic/react'
3
+ import axios from 'axios'
4
+
5
+ import { FlowBuilderApi } from '../api'
6
+ import { FlowCaptureUserInput } from '../content-fields'
7
+ import {
8
+ HtAiValidationType,
9
+ HtCaptureUserInputNode,
10
+ } from '../content-fields/hubtype-fields'
11
+ import {
12
+ getCommonFlowContentEventArgsForContentId,
13
+ trackEvent,
14
+ } from '../tracking'
15
+ import { inputHasTextData } from '../utils'
16
+
17
+ interface AiCaptureResponseSuccess {
18
+ success: true
19
+ value: string
20
+ }
21
+
22
+ interface AiCaptureResponseFailure {
23
+ success: false
24
+ }
25
+
26
+ type AiCaptureResponse = AiCaptureResponseSuccess | AiCaptureResponseFailure
27
+
28
+ export class CaptureUserInputApi {
29
+ private cmsApi: FlowBuilderApi
30
+ private request: ActionRequest
31
+
32
+ constructor(cmsApi: FlowBuilderApi, request: ActionRequest) {
33
+ this.cmsApi = cmsApi
34
+ this.request = request
35
+ }
36
+
37
+ async getNextNodeId(): Promise<string | undefined> {
38
+ if (
39
+ inputHasTextData(this.request.input) &&
40
+ this.cmsApi.shouldCaptureUserInput()
41
+ ) {
42
+ const captureUserInputNode = this.cmsApi.getCaptureUserInputNode()
43
+ if (!captureUserInputNode) {
44
+ return undefined
45
+ }
46
+ const captureUserInput =
47
+ FlowCaptureUserInput.fromHubtypeCMS(captureUserInputNode)
48
+
49
+ if (captureUserInput.aiValidationType === HtAiValidationType.NONE) {
50
+ this.cmsApi.setUserExtraDataVariable(
51
+ captureUserInputNode.content.field_name,
52
+ this.request.input.data as string
53
+ )
54
+ await this.trackUserInputCapture(captureUserInputNode, true)
55
+ return captureUserInput.captureSuccessId
56
+ }
57
+
58
+ const aiCaptureResponse =
59
+ await this.getAiCaptureResponse(captureUserInputNode)
60
+ if (!aiCaptureResponse.success) {
61
+ await this.trackUserInputCapture(captureUserInputNode, false)
62
+ return captureUserInput.captureFailId
63
+ }
64
+
65
+ this.cmsApi.setUserExtraDataVariable(
66
+ captureUserInputNode.content.field_name,
67
+ aiCaptureResponse.value
68
+ )
69
+ await this.trackUserInputCapture(captureUserInputNode, true)
70
+ return captureUserInput.captureSuccessId
71
+ }
72
+ return undefined
73
+ }
74
+
75
+ async getAiCaptureResponse(
76
+ captureUserInputNode: HtCaptureUserInputNode
77
+ ): Promise<AiCaptureResponse> {
78
+ try {
79
+ const url = `${process.env.HUBTYPE_API_URL}/external/v1/capture_user_input/`
80
+ const data = {
81
+ field_name: captureUserInputNode.content.field_name,
82
+ validation_instructions:
83
+ captureUserInputNode.content.ai_validation_instructions,
84
+ user_input: this.request.input.data,
85
+ }
86
+ const config = {
87
+ headers: {
88
+ 'Content-Type': 'application/json',
89
+ Authorization: `Bearer ${this.request.session._access_token}`,
90
+ },
91
+ }
92
+
93
+ const aiCaptureResponse = await axios.post<AiCaptureResponse>(
94
+ url,
95
+ data,
96
+ config
97
+ )
98
+
99
+ return aiCaptureResponse.data
100
+ } catch (error) {
101
+ console.warn('Error getting ai/capture_user_input', error)
102
+ }
103
+
104
+ return {
105
+ success: false,
106
+ }
107
+ }
108
+
109
+ async trackUserInputCapture(
110
+ captureUserInputNode: HtCaptureUserInputNode,
111
+ captureSuccess: boolean
112
+ ): Promise<void> {
113
+ const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
114
+ getCommonFlowContentEventArgsForContentId(
115
+ this.request,
116
+ captureUserInputNode.id
117
+ )
118
+ const event: EventCaptureUserInput = {
119
+ action: EventAction.CaptureUserInput,
120
+ flowThreadId,
121
+ flowId,
122
+ flowName,
123
+ flowNodeId,
124
+ flowNodeContentId,
125
+ flowNodeIsMeaningful: false,
126
+ fieldName: captureUserInputNode.content.field_name,
127
+ userInput: this.request.input.data as string,
128
+ captureSuccess,
129
+ messageId: this.request.input.message_id,
130
+ }
131
+ const { action, ...eventArgs } = event
132
+ await trackEvent(this.request, action, eventArgs)
133
+ }
134
+ }
@@ -1,25 +1,30 @@
1
1
  import { ActionRequest } from '@botonic/react'
2
2
 
3
3
  import { FlowBuilderApi } from '../api'
4
- import {
5
- HtKeywordNode,
6
- HtSmartIntentNode,
7
- } from '../content-fields/hubtype-fields'
8
4
  import {
9
5
  inputHasTextData,
10
6
  isKeywordsAllowed,
11
7
  isSmartIntentsAllowed,
12
8
  } from '../utils'
9
+ import { CaptureUserInputApi } from './capture-user-input-api'
13
10
  import { KeywordMatcher } from './keyword'
14
11
  import { SmartIntentsApi, SmartIntentsInferenceConfig } from './smart-intent'
15
12
 
16
- export async function getNodeByUserInput(
13
+ export async function getNextPayloadByUserInput(
17
14
  cmsApi: FlowBuilderApi,
18
15
  locale: string,
19
16
  request: ActionRequest,
20
17
  smartIntentsConfig: SmartIntentsInferenceConfig
21
- ): Promise<HtSmartIntentNode | HtKeywordNode | undefined> {
18
+ ): Promise<string | undefined> {
22
19
  if (inputHasTextData(request.input)) {
20
+ if (cmsApi.shouldCaptureUserInput()) {
21
+ const captureUserInputApi = new CaptureUserInputApi(
22
+ cmsApi,
23
+ request as unknown as ActionRequest
24
+ )
25
+ return await captureUserInputApi.getNextNodeId()
26
+ }
27
+
23
28
  if (isKeywordsAllowed(request)) {
24
29
  const keywordMatcher = new KeywordMatcher({
25
30
  cmsApi,
@@ -30,7 +35,7 @@ export async function getNodeByUserInput(
30
35
  request.input.data!
31
36
  )
32
37
  if (keywordNode) {
33
- return keywordNode
38
+ return cmsApi.getPayload(keywordNode.target)
34
39
  }
35
40
  }
36
41
 
@@ -42,7 +47,7 @@ export async function getNodeByUserInput(
42
47
  )
43
48
  const smartIntentNode = await smartIntentsApi.getNodeByInput()
44
49
  if (smartIntentNode) {
45
- return smartIntentNode
50
+ return cmsApi.getPayload(smartIntentNode.target)
46
51
  }
47
52
  }
48
53
  }