@botonic/plugin-flow-builder 0.46.1 → 0.47.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 (314) hide show
  1. package/lib/cjs/action/ai-agent-from-user-input.d.ts +3 -0
  2. package/lib/cjs/action/ai-agent-from-user-input.js +23 -0
  3. package/lib/cjs/action/ai-agent-from-user-input.js.map +1 -0
  4. package/lib/cjs/action/context.d.ts +11 -0
  5. package/lib/cjs/action/context.js +17 -0
  6. package/lib/cjs/action/context.js.map +1 -0
  7. package/lib/cjs/action/fallback.d.ts +1 -1
  8. package/lib/cjs/action/first-interaction.d.ts +1 -1
  9. package/lib/cjs/action/first-interaction.js +4 -4
  10. package/lib/cjs/action/first-interaction.js.map +1 -1
  11. package/lib/cjs/action/get-contents.d.ts +3 -0
  12. package/lib/cjs/action/get-contents.js +44 -0
  13. package/lib/cjs/action/get-contents.js.map +1 -0
  14. package/lib/cjs/action/index.d.ts +6 -15
  15. package/lib/cjs/action/index.js +31 -94
  16. package/lib/cjs/action/index.js.map +1 -1
  17. package/lib/cjs/action/knowledge-bases.d.ts +1 -1
  18. package/lib/cjs/action/knowledge-bases.js +3 -3
  19. package/lib/cjs/action/knowledge-bases.js.map +1 -1
  20. package/lib/cjs/action/payload.d.ts +1 -1
  21. package/lib/cjs/api.d.ts +0 -1
  22. package/lib/cjs/api.js +0 -7
  23. package/lib/cjs/api.js.map +1 -1
  24. package/lib/cjs/content-fields/content-fields-base.d.ts +5 -4
  25. package/lib/cjs/content-fields/content-fields-base.js +7 -7
  26. package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
  27. package/lib/cjs/content-fields/flow-ai-agent.d.ts +14 -5
  28. package/lib/cjs/content-fields/flow-ai-agent.js +100 -17
  29. package/lib/cjs/content-fields/flow-ai-agent.js.map +1 -1
  30. package/lib/cjs/content-fields/flow-bot-action.d.ts +4 -2
  31. package/lib/cjs/content-fields/flow-bot-action.js +10 -5
  32. package/lib/cjs/content-fields/flow-bot-action.js.map +1 -1
  33. package/lib/cjs/content-fields/flow-button.d.ts +5 -2
  34. package/lib/cjs/content-fields/flow-button.js +6 -2
  35. package/lib/cjs/content-fields/flow-button.js.map +1 -1
  36. package/lib/cjs/content-fields/flow-capture-user-input.d.ts +4 -3
  37. package/lib/cjs/content-fields/flow-capture-user-input.js +7 -5
  38. package/lib/cjs/content-fields/flow-capture-user-input.js.map +1 -1
  39. package/lib/cjs/content-fields/flow-carousel.d.ts +4 -3
  40. package/lib/cjs/content-fields/flow-carousel.js +11 -7
  41. package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
  42. package/lib/cjs/content-fields/flow-channel-conditional.d.ts +5 -4
  43. package/lib/cjs/content-fields/flow-channel-conditional.js +10 -7
  44. package/lib/cjs/content-fields/flow-channel-conditional.js.map +1 -1
  45. package/lib/cjs/content-fields/flow-country-conditional.d.ts +5 -4
  46. package/lib/cjs/content-fields/flow-country-conditional.js +11 -7
  47. package/lib/cjs/content-fields/flow-country-conditional.js.map +1 -1
  48. package/lib/cjs/content-fields/flow-custom-conditional.d.ts +5 -4
  49. package/lib/cjs/content-fields/flow-custom-conditional.js +11 -7
  50. package/lib/cjs/content-fields/flow-custom-conditional.js.map +1 -1
  51. package/lib/cjs/content-fields/flow-element.d.ts +4 -4
  52. package/lib/cjs/content-fields/flow-element.js +7 -3
  53. package/lib/cjs/content-fields/flow-element.js.map +1 -1
  54. package/lib/cjs/content-fields/flow-go-to-flow.d.ts +3 -3
  55. package/lib/cjs/content-fields/flow-go-to-flow.js +7 -15
  56. package/lib/cjs/content-fields/flow-go-to-flow.js.map +1 -1
  57. package/lib/cjs/content-fields/flow-handoff.d.ts +5 -4
  58. package/lib/cjs/content-fields/flow-handoff.js +11 -7
  59. package/lib/cjs/content-fields/flow-handoff.js.map +1 -1
  60. package/lib/cjs/content-fields/flow-image.d.ts +4 -3
  61. package/lib/cjs/content-fields/flow-image.js +8 -4
  62. package/lib/cjs/content-fields/flow-image.js.map +1 -1
  63. package/lib/cjs/content-fields/flow-knowledge-base.d.ts +4 -3
  64. package/lib/cjs/content-fields/flow-knowledge-base.js +7 -3
  65. package/lib/cjs/content-fields/flow-knowledge-base.js.map +1 -1
  66. package/lib/cjs/content-fields/flow-queue-status-conditional.d.ts +3 -2
  67. package/lib/cjs/content-fields/flow-queue-status-conditional.js +7 -3
  68. package/lib/cjs/content-fields/flow-queue-status-conditional.js.map +1 -1
  69. package/lib/cjs/content-fields/flow-rating.d.ts +4 -3
  70. package/lib/cjs/content-fields/flow-rating.js +13 -9
  71. package/lib/cjs/content-fields/flow-rating.js.map +1 -1
  72. package/lib/cjs/content-fields/flow-text.d.ts +4 -4
  73. package/lib/cjs/content-fields/flow-text.js +11 -6
  74. package/lib/cjs/content-fields/flow-text.js.map +1 -1
  75. package/lib/cjs/content-fields/flow-video.d.ts +4 -3
  76. package/lib/cjs/content-fields/flow-video.js +8 -4
  77. package/lib/cjs/content-fields/flow-video.js.map +1 -1
  78. package/lib/cjs/content-fields/flow-webview.d.ts +3 -2
  79. package/lib/cjs/content-fields/flow-webview.js +6 -3
  80. package/lib/cjs/content-fields/flow-webview.js.map +1 -1
  81. package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.d.ts +5 -3
  82. package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js +14 -10
  83. package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
  84. package/lib/cjs/content-fields/flow-whatsapp-template.d.ts +5 -3
  85. package/lib/cjs/content-fields/flow-whatsapp-template.js +26 -22
  86. package/lib/cjs/content-fields/flow-whatsapp-template.js.map +1 -1
  87. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +4 -3
  88. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +6 -4
  89. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
  90. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +4 -3
  91. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +7 -5
  92. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
  93. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +4 -3
  94. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +10 -6
  95. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
  96. package/lib/cjs/content-fields/whatsapp-button-list/index.d.ts +3 -0
  97. package/lib/cjs/content-fields/whatsapp-button-list/index.js +10 -0
  98. package/lib/cjs/content-fields/whatsapp-button-list/index.js.map +1 -0
  99. package/lib/cjs/filters/index.d.ts +1 -0
  100. package/lib/cjs/filters/index.js +15 -0
  101. package/lib/cjs/filters/index.js.map +1 -1
  102. package/lib/cjs/index.d.ts +1 -1
  103. package/lib/cjs/index.js +4 -8
  104. package/lib/cjs/index.js.map +1 -1
  105. package/lib/cjs/structured-output/flow-builder-content.d.ts +16 -0
  106. package/lib/cjs/structured-output/flow-builder-content.js +12 -0
  107. package/lib/cjs/structured-output/flow-builder-content.js.map +1 -0
  108. package/lib/cjs/tracking.js +6 -6
  109. package/lib/cjs/tracking.js.map +1 -1
  110. package/lib/cjs/types.d.ts +2 -1
  111. package/lib/cjs/user-input/capture-user-input-api.js +4 -4
  112. package/lib/cjs/user-input/capture-user-input-api.js.map +1 -1
  113. package/lib/cjs/user-input/index.js +4 -4
  114. package/lib/cjs/user-input/index.js.map +1 -1
  115. package/lib/cjs/user-input/smart-intent.js +2 -2
  116. package/lib/cjs/user-input/smart-intent.js.map +1 -1
  117. package/lib/cjs/utils/ai-agent.d.ts +18 -0
  118. package/lib/cjs/utils/ai-agent.js +177 -0
  119. package/lib/cjs/utils/ai-agent.js.map +1 -0
  120. package/lib/cjs/utils/authentication.d.ts +2 -0
  121. package/lib/cjs/utils/authentication.js +21 -0
  122. package/lib/cjs/utils/authentication.js.map +1 -0
  123. package/lib/{esm/helpers.d.ts → cjs/utils/get-flow-builder-plugin.d.ts} +1 -1
  124. package/lib/cjs/{helpers.js → utils/get-flow-builder-plugin.js} +1 -1
  125. package/lib/cjs/utils/get-flow-builder-plugin.js.map +1 -0
  126. package/lib/cjs/{utils.d.ts → utils/input.d.ts} +1 -2
  127. package/lib/cjs/{utils.js → utils/input.js} +3 -21
  128. package/lib/cjs/utils/input.js.map +1 -0
  129. package/lib/esm/action/ai-agent-from-user-input.d.ts +3 -0
  130. package/lib/esm/action/ai-agent-from-user-input.js +23 -0
  131. package/lib/esm/action/ai-agent-from-user-input.js.map +1 -0
  132. package/lib/esm/action/context.d.ts +11 -0
  133. package/lib/esm/action/context.js +17 -0
  134. package/lib/esm/action/context.js.map +1 -0
  135. package/lib/esm/action/fallback.d.ts +1 -1
  136. package/lib/esm/action/first-interaction.d.ts +1 -1
  137. package/lib/esm/action/first-interaction.js +4 -4
  138. package/lib/esm/action/first-interaction.js.map +1 -1
  139. package/lib/esm/action/get-contents.d.ts +3 -0
  140. package/lib/esm/action/get-contents.js +44 -0
  141. package/lib/esm/action/get-contents.js.map +1 -0
  142. package/lib/esm/action/index.d.ts +6 -15
  143. package/lib/esm/action/index.js +31 -94
  144. package/lib/esm/action/index.js.map +1 -1
  145. package/lib/esm/action/knowledge-bases.d.ts +1 -1
  146. package/lib/esm/action/knowledge-bases.js +3 -3
  147. package/lib/esm/action/knowledge-bases.js.map +1 -1
  148. package/lib/esm/action/payload.d.ts +1 -1
  149. package/lib/esm/api.d.ts +0 -1
  150. package/lib/esm/api.js +0 -7
  151. package/lib/esm/api.js.map +1 -1
  152. package/lib/esm/content-fields/content-fields-base.d.ts +5 -4
  153. package/lib/esm/content-fields/content-fields-base.js +7 -7
  154. package/lib/esm/content-fields/content-fields-base.js.map +1 -1
  155. package/lib/esm/content-fields/flow-ai-agent.d.ts +14 -5
  156. package/lib/esm/content-fields/flow-ai-agent.js +100 -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 +4 -2
  159. package/lib/esm/content-fields/flow-bot-action.js +10 -5
  160. package/lib/esm/content-fields/flow-bot-action.js.map +1 -1
  161. package/lib/esm/content-fields/flow-button.d.ts +5 -2
  162. package/lib/esm/content-fields/flow-button.js +6 -2
  163. package/lib/esm/content-fields/flow-button.js.map +1 -1
  164. package/lib/esm/content-fields/flow-capture-user-input.d.ts +4 -3
  165. package/lib/esm/content-fields/flow-capture-user-input.js +7 -5
  166. package/lib/esm/content-fields/flow-capture-user-input.js.map +1 -1
  167. package/lib/esm/content-fields/flow-carousel.d.ts +4 -3
  168. package/lib/esm/content-fields/flow-carousel.js +11 -7
  169. package/lib/esm/content-fields/flow-carousel.js.map +1 -1
  170. package/lib/esm/content-fields/flow-channel-conditional.d.ts +5 -4
  171. package/lib/esm/content-fields/flow-channel-conditional.js +10 -7
  172. package/lib/esm/content-fields/flow-channel-conditional.js.map +1 -1
  173. package/lib/esm/content-fields/flow-country-conditional.d.ts +5 -4
  174. package/lib/esm/content-fields/flow-country-conditional.js +11 -7
  175. package/lib/esm/content-fields/flow-country-conditional.js.map +1 -1
  176. package/lib/esm/content-fields/flow-custom-conditional.d.ts +5 -4
  177. package/lib/esm/content-fields/flow-custom-conditional.js +11 -7
  178. package/lib/esm/content-fields/flow-custom-conditional.js.map +1 -1
  179. package/lib/esm/content-fields/flow-element.d.ts +4 -4
  180. package/lib/esm/content-fields/flow-element.js +7 -3
  181. package/lib/esm/content-fields/flow-element.js.map +1 -1
  182. package/lib/esm/content-fields/flow-go-to-flow.d.ts +3 -3
  183. package/lib/esm/content-fields/flow-go-to-flow.js +7 -15
  184. package/lib/esm/content-fields/flow-go-to-flow.js.map +1 -1
  185. package/lib/esm/content-fields/flow-handoff.d.ts +5 -4
  186. package/lib/esm/content-fields/flow-handoff.js +11 -7
  187. package/lib/esm/content-fields/flow-handoff.js.map +1 -1
  188. package/lib/esm/content-fields/flow-image.d.ts +4 -3
  189. package/lib/esm/content-fields/flow-image.js +8 -4
  190. package/lib/esm/content-fields/flow-image.js.map +1 -1
  191. package/lib/esm/content-fields/flow-knowledge-base.d.ts +4 -3
  192. package/lib/esm/content-fields/flow-knowledge-base.js +7 -3
  193. package/lib/esm/content-fields/flow-knowledge-base.js.map +1 -1
  194. package/lib/esm/content-fields/flow-queue-status-conditional.d.ts +3 -2
  195. package/lib/esm/content-fields/flow-queue-status-conditional.js +7 -3
  196. package/lib/esm/content-fields/flow-queue-status-conditional.js.map +1 -1
  197. package/lib/esm/content-fields/flow-rating.d.ts +4 -3
  198. package/lib/esm/content-fields/flow-rating.js +13 -9
  199. package/lib/esm/content-fields/flow-rating.js.map +1 -1
  200. package/lib/esm/content-fields/flow-text.d.ts +4 -4
  201. package/lib/esm/content-fields/flow-text.js +11 -6
  202. package/lib/esm/content-fields/flow-text.js.map +1 -1
  203. package/lib/esm/content-fields/flow-video.d.ts +4 -3
  204. package/lib/esm/content-fields/flow-video.js +8 -4
  205. package/lib/esm/content-fields/flow-video.js.map +1 -1
  206. package/lib/esm/content-fields/flow-webview.d.ts +3 -2
  207. package/lib/esm/content-fields/flow-webview.js +6 -3
  208. package/lib/esm/content-fields/flow-webview.js.map +1 -1
  209. package/lib/esm/content-fields/flow-whatsapp-cta-url-button.d.ts +5 -3
  210. package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js +14 -10
  211. package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
  212. package/lib/esm/content-fields/flow-whatsapp-template.d.ts +5 -3
  213. package/lib/esm/content-fields/flow-whatsapp-template.js +26 -22
  214. package/lib/esm/content-fields/flow-whatsapp-template.js.map +1 -1
  215. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +4 -3
  216. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +6 -4
  217. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
  218. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +4 -3
  219. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +7 -5
  220. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
  221. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +4 -3
  222. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +10 -6
  223. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
  224. package/lib/esm/content-fields/whatsapp-button-list/index.d.ts +3 -0
  225. package/lib/esm/content-fields/whatsapp-button-list/index.js +10 -0
  226. package/lib/esm/content-fields/whatsapp-button-list/index.js.map +1 -0
  227. package/lib/esm/filters/index.d.ts +1 -0
  228. package/lib/esm/filters/index.js +15 -0
  229. package/lib/esm/filters/index.js.map +1 -1
  230. package/lib/esm/index.d.ts +1 -1
  231. package/lib/esm/index.js +4 -8
  232. package/lib/esm/index.js.map +1 -1
  233. package/lib/esm/structured-output/flow-builder-content.d.ts +16 -0
  234. package/lib/esm/structured-output/flow-builder-content.js +12 -0
  235. package/lib/esm/structured-output/flow-builder-content.js.map +1 -0
  236. package/lib/esm/tracking.js +6 -6
  237. package/lib/esm/tracking.js.map +1 -1
  238. package/lib/esm/types.d.ts +2 -1
  239. package/lib/esm/user-input/capture-user-input-api.js +4 -4
  240. package/lib/esm/user-input/capture-user-input-api.js.map +1 -1
  241. package/lib/esm/user-input/index.js +4 -4
  242. package/lib/esm/user-input/index.js.map +1 -1
  243. package/lib/esm/user-input/smart-intent.js +2 -2
  244. package/lib/esm/user-input/smart-intent.js.map +1 -1
  245. package/lib/esm/utils/ai-agent.d.ts +18 -0
  246. package/lib/esm/utils/ai-agent.js +177 -0
  247. package/lib/esm/utils/ai-agent.js.map +1 -0
  248. package/lib/esm/utils/authentication.d.ts +2 -0
  249. package/lib/esm/utils/authentication.js +21 -0
  250. package/lib/esm/utils/authentication.js.map +1 -0
  251. package/lib/{cjs/helpers.d.ts → esm/utils/get-flow-builder-plugin.d.ts} +1 -1
  252. package/lib/esm/{helpers.js → utils/get-flow-builder-plugin.js} +1 -1
  253. package/lib/esm/utils/get-flow-builder-plugin.js.map +1 -0
  254. package/lib/esm/{utils.d.ts → utils/input.d.ts} +1 -2
  255. package/lib/esm/{utils.js → utils/input.js} +3 -21
  256. package/lib/esm/utils/input.js.map +1 -0
  257. package/package.json +2 -2
  258. package/src/action/ai-agent-from-user-input.ts +35 -0
  259. package/src/action/context.ts +29 -0
  260. package/src/action/fallback.ts +1 -1
  261. package/src/action/first-interaction.ts +4 -4
  262. package/src/action/get-contents.ts +51 -0
  263. package/src/action/index.tsx +42 -136
  264. package/src/action/knowledge-bases.ts +5 -2
  265. package/src/action/payload.ts +1 -1
  266. package/src/api.ts +0 -8
  267. package/src/content-fields/content-fields-base.ts +11 -9
  268. package/src/content-fields/flow-ai-agent.tsx +166 -28
  269. package/src/content-fields/flow-bot-action.tsx +17 -6
  270. package/src/content-fields/flow-button.tsx +10 -3
  271. package/src/content-fields/flow-capture-user-input.tsx +9 -6
  272. package/src/content-fields/flow-carousel.tsx +21 -11
  273. package/src/content-fields/flow-channel-conditional.tsx +16 -9
  274. package/src/content-fields/flow-country-conditional.tsx +17 -9
  275. package/src/content-fields/flow-custom-conditional.tsx +17 -9
  276. package/src/content-fields/flow-element.tsx +10 -11
  277. package/src/content-fields/flow-go-to-flow.tsx +10 -24
  278. package/src/content-fields/flow-handoff.tsx +21 -10
  279. package/src/content-fields/flow-image.tsx +11 -5
  280. package/src/content-fields/flow-knowledge-base.tsx +11 -5
  281. package/src/content-fields/flow-queue-status-conditional.tsx +13 -5
  282. package/src/content-fields/flow-rating.tsx +16 -16
  283. package/src/content-fields/flow-text.tsx +14 -7
  284. package/src/content-fields/flow-video.tsx +11 -5
  285. package/src/content-fields/flow-webview.tsx +12 -5
  286. package/src/content-fields/flow-whatsapp-cta-url-button.tsx +16 -12
  287. package/src/content-fields/flow-whatsapp-template.tsx +28 -24
  288. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx +8 -5
  289. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx +8 -6
  290. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx +15 -15
  291. package/src/content-fields/whatsapp-button-list/index.ts +3 -0
  292. package/src/filters/index.ts +20 -0
  293. package/src/index.ts +3 -14
  294. package/src/structured-output/flow-builder-content.ts +17 -0
  295. package/src/tracking.ts +1 -1
  296. package/src/types.ts +2 -2
  297. package/src/user-input/capture-user-input-api.ts +2 -2
  298. package/src/user-input/index.ts +1 -1
  299. package/src/user-input/smart-intent.ts +1 -1
  300. package/src/utils/ai-agent.ts +233 -0
  301. package/src/utils/authentication.ts +23 -0
  302. package/src/{helpers.ts → utils/get-flow-builder-plugin.ts} +1 -1
  303. package/src/{utils.ts → utils/input.ts} +3 -23
  304. package/lib/cjs/action/ai-agent.d.ts +0 -3
  305. package/lib/cjs/action/ai-agent.js +0 -67
  306. package/lib/cjs/action/ai-agent.js.map +0 -1
  307. package/lib/cjs/helpers.js.map +0 -1
  308. package/lib/cjs/utils.js.map +0 -1
  309. package/lib/esm/action/ai-agent.d.ts +0 -3
  310. package/lib/esm/action/ai-agent.js +0 -67
  311. package/lib/esm/action/ai-agent.js.map +0 -1
  312. package/lib/esm/helpers.js.map +0 -1
  313. package/lib/esm/utils.js.map +0 -1
  314. package/src/action/ai-agent.ts +0 -102
@@ -1,14 +1,32 @@
1
- import { type AgenticOutputMessage, VerbosityLevel } from '@botonic/core'
2
- import type { ActionRequest } from '@botonic/react'
3
-
4
- import { trackOneContent } from '../tracking'
1
+ import {
2
+ type AgenticOutputMessage,
3
+ type BotContext,
4
+ EventAction,
5
+ type EventAiAgent,
6
+ type GuardrailRule,
7
+ type HubtypeAssistantMessage,
8
+ type InferenceResponse,
9
+ VerbosityLevel,
10
+ } from '@botonic/core'
11
+ import {
12
+ type FlowBuilderContentMessage,
13
+ FlowBuilderContentSchema,
14
+ } from '../structured-output/flow-builder-content'
15
+ import {
16
+ getCommonFlowContentEventArgsForContentId,
17
+ trackEvent,
18
+ } from '../tracking'
19
+ import { HubtypeAssistantContent } from '../utils/ai-agent'
20
+ import { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'
5
21
  import { ContentFieldsBase } from './content-fields-base'
6
22
  import { FlowCarousel } from './flow-carousel'
7
23
  import { FlowText } from './flow-text'
24
+ import type { HtNodeWithContent } from './hubtype-fields'
8
25
  import type {
9
26
  HtAiAgentNode,
10
27
  HtInputGuardrailRule,
11
28
  } from './hubtype-fields/ai-agent'
29
+ import type { FlowContent } from './index'
12
30
 
13
31
  export class FlowAiAgent extends ContentFieldsBase {
14
32
  public name: string = ''
@@ -19,7 +37,9 @@ export class FlowAiAgent extends ContentFieldsBase {
19
37
  public inputGuardrailRules: HtInputGuardrailRule[]
20
38
  public sources?: { id: string; name: string }[]
21
39
 
22
- public responses: AgenticOutputMessage[] = []
40
+ public aiAgentResponse?: InferenceResponse<FlowBuilderContentMessage>
41
+ public messages: AgenticOutputMessage<FlowBuilderContentMessage>[] = []
42
+ public jsxElements: JSX.Element[] = []
23
43
 
24
44
  static fromHubtypeCMS(component: HtAiAgentNode): FlowAiAgent {
25
45
  const newAiAgent = new FlowAiAgent(component.id)
@@ -37,31 +57,149 @@ export class FlowAiAgent extends ContentFieldsBase {
37
57
  return newAiAgent
38
58
  }
39
59
 
40
- async trackFlow(request: ActionRequest): Promise<void> {
41
- // We can call trackFlowContent here but the function no track events for AiAgent contents
42
- // Review how we can track here the ai agent event
43
- await trackOneContent(request, this)
60
+ async resolveAIAgentResponse(
61
+ botContext: BotContext,
62
+ previousContents?: FlowContent[]
63
+ ): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined> {
64
+ const aiAgentResponse = await this.getAIAgentResponse(
65
+ botContext,
66
+ previousContents
67
+ )
68
+
69
+ if (aiAgentResponse) {
70
+ this.aiAgentResponse = aiAgentResponse
71
+ await this.trackAiAgentResponse(botContext)
72
+ this.messages = aiAgentResponse.messages
73
+ await this.messagesToBotonicJSXElements(botContext)
74
+ }
75
+
76
+ return aiAgentResponse
44
77
  }
45
78
 
46
- toBotonic(id: string, request: ActionRequest): JSX.Element {
47
- return (
48
- <>
49
- {this.responses.map((response: AgenticOutputMessage) => {
50
- if (
51
- response.type === 'text' ||
52
- response.type === 'textWithButtons' ||
53
- response.type === 'botExecutor'
54
- ) {
55
- return FlowText.fromAIAgent(id, response)
56
- }
57
-
58
- if (response.type === 'carousel') {
59
- return FlowCarousel.fromAIAgent(id, response, request)
60
- }
61
-
62
- return <></>
63
- })}
64
- </>
79
+ async getAIAgentResponse(
80
+ botContext: BotContext,
81
+ previousContents?: FlowContent[]
82
+ ): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined> {
83
+ const previousHubtypeContents: HubtypeAssistantMessage[] =
84
+ previousContents?.map(content => {
85
+ return {
86
+ role: 'assistant',
87
+ content: HubtypeAssistantContent.adapt(content),
88
+ }
89
+ }) || []
90
+
91
+ const activeInputGuardrailRules: GuardrailRule[] =
92
+ this.inputGuardrailRules
93
+ ?.filter(rule => rule.is_active)
94
+ ?.map(rule => ({
95
+ name: rule.name,
96
+ description: rule.description,
97
+ })) || []
98
+
99
+ const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)
100
+
101
+ const aiAgentResponse = await flowBuilderPlugin.getAiAgentResponse?.(
102
+ botContext,
103
+ {
104
+ name: this.name,
105
+ instructions: this.instructions,
106
+ model: this.model,
107
+ verbosity: this.verbosity,
108
+ activeTools: this.activeTools,
109
+ inputGuardrailRules: activeInputGuardrailRules,
110
+ sourceIds: this.sources?.map(source => source.id),
111
+ outputMessagesSchemas: [FlowBuilderContentSchema],
112
+ previousHubtypeMessages: previousHubtypeContents,
113
+ }
65
114
  )
115
+
116
+ return aiAgentResponse
117
+ }
118
+
119
+ async trackFlow(): Promise<void> {
120
+ return
121
+ }
122
+
123
+ async trackAiAgentResponse(botContext: BotContext) {
124
+ const { flowThreadId, flowId, flowName, flowNodeId } =
125
+ getCommonFlowContentEventArgsForContentId(botContext, this.id)
126
+
127
+ const event: EventAiAgent = {
128
+ action: EventAction.AiAgent,
129
+ flowThreadId: flowThreadId,
130
+ flowId: flowId,
131
+ flowName: flowName,
132
+ flowNodeId: flowNodeId,
133
+ flowNodeContentId: this.name,
134
+ flowNodeIsMeaningful: true,
135
+ toolsExecuted: this.aiAgentResponse?.toolsExecuted ?? [],
136
+ memoryLength: this.aiAgentResponse?.memoryLength ?? 0,
137
+ inputMessageId: botContext.input.message_id!,
138
+ exit: this.aiAgentResponse?.exit ?? true,
139
+ inputGuardrailsTriggered:
140
+ this.aiAgentResponse?.inputGuardrailsTriggered ?? [],
141
+ outputGuardrailsTriggered: [], //aiAgentResponse.outputGuardrailsTriggered,
142
+ error: this.aiAgentResponse?.error ?? false,
143
+ }
144
+ const { action, ...eventArgs } = event
145
+
146
+ await trackEvent(botContext, action, eventArgs)
147
+ }
148
+
149
+ async getFlowContentsByContentId(
150
+ botContext: BotContext,
151
+ contentId: string
152
+ ): Promise<FlowContent[]> {
153
+ const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)
154
+ const cmsApi = flowBuilderPlugin.cmsApi
155
+ const node = cmsApi.getNodeByContentID(contentId)
156
+ const flowContents = await flowBuilderPlugin.getContentsByNode(
157
+ node as HtNodeWithContent
158
+ )
159
+ return flowContents
160
+ }
161
+
162
+ async messagesToBotonicJSXElements(botContext: BotContext): Promise<void> {
163
+ for (const message of this.messages) {
164
+ if (
165
+ message.type === 'text' ||
166
+ message.type === 'textWithButtons' ||
167
+ message.type === 'botExecutor'
168
+ ) {
169
+ this.jsxElements.push(FlowText.fromAIAgent(this.id, message))
170
+ }
171
+
172
+ if (message.type === 'carousel') {
173
+ this.jsxElements.push(
174
+ FlowCarousel.fromAIAgent(this.id, message, botContext)
175
+ )
176
+ }
177
+
178
+ if (message.type === 'flowBuilderContent') {
179
+ const flowContents = await this.getFlowContentsByContentId(
180
+ botContext,
181
+ message.contentId
182
+ )
183
+ for (const content of flowContents) {
184
+ await content.processContent(botContext)
185
+ this.jsxElements.push(content.toBotonic(botContext))
186
+ }
187
+ }
188
+ }
189
+ return
190
+ }
191
+
192
+ async processContent(
193
+ botContext: BotContext,
194
+ previousContents?: FlowContent[]
195
+ ): Promise<void> {
196
+ if (this.messages.length === 0) {
197
+ await this.resolveAIAgentResponse(botContext, previousContents)
198
+ }
199
+ return
200
+ }
201
+
202
+ toBotonic(): JSX.Element {
203
+ return <>{this.jsxElements}</>
66
204
  }
67
205
  }
@@ -1,4 +1,9 @@
1
- import { BotonicAction, EventAction, type EventBotAction } from '@botonic/core'
1
+ import {
2
+ type BotContext,
3
+ BotonicAction,
4
+ EventAction,
5
+ type EventBotAction,
6
+ } from '@botonic/core'
2
7
  import type { ActionRequest } from '@botonic/react'
3
8
 
4
9
  import type { FlowBuilderApi } from '../api'
@@ -25,9 +30,9 @@ export class FlowBotAction extends ContentFieldsBase {
25
30
  return newBotAction
26
31
  }
27
32
 
28
- async trackFlow(request: ActionRequest): Promise<void> {
33
+ async trackFlow(botContext: BotContext): Promise<void> {
29
34
  const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
30
- getCommonFlowContentEventArgsForContentId(request, this.id)
35
+ getCommonFlowContentEventArgsForContentId(botContext, this.id)
31
36
  const eventBotAction: EventBotAction = {
32
37
  action: EventAction.BotAction,
33
38
  flowThreadId,
@@ -39,11 +44,17 @@ export class FlowBotAction extends ContentFieldsBase {
39
44
  payload: this.payload,
40
45
  }
41
46
  const { action, ...eventArgs } = eventBotAction
42
- await trackEvent(request, action, eventArgs)
47
+ await trackEvent(botContext, action, eventArgs)
48
+ }
49
+
50
+ doBotAction(botContext: ActionRequest): void {
51
+ botContext.session._botonic_action = `${BotonicAction.Redirect}:${this.payload}`
43
52
  }
44
53
 
45
- doBotAction(request: ActionRequest): void {
46
- request.session._botonic_action = `${BotonicAction.Redirect}:${this.payload}`
54
+ async processContent(botContext: BotContext): Promise<void> {
55
+ this.doBotAction(botContext)
56
+ await this.trackFlow(botContext)
57
+ return
47
58
  }
48
59
 
49
60
  toBotonic(): JSX.Element {
@@ -1,4 +1,5 @@
1
- import { type ActionRequest, Button, Reply, type Webview } from '@botonic/react'
1
+ import type { BotContext } from '@botonic/core'
2
+ import { Button, Reply, type Webview } from '@botonic/react'
2
3
 
3
4
  import type { FlowBuilderApi } from '../api'
4
5
  import { SOURCE_INFO_SEPARATOR } from '../constants'
@@ -92,11 +93,13 @@ export class FlowButton extends ContentFieldsBase {
92
93
  text: string
93
94
  payload?: string
94
95
  url?: string
96
+ target?: string
95
97
  }): FlowButton {
96
98
  const newButton = new FlowButton(button.id)
97
99
  newButton.text = button.text
98
100
  if (button.url) {
99
101
  newButton.url = button.url
102
+ newButton.target = button.target
100
103
  } else {
101
104
  newButton.payload = button.payload
102
105
  }
@@ -126,12 +129,16 @@ export class FlowButton extends ContentFieldsBase {
126
129
  return FlowWebview.fromHubtypeCMS(targetNode)
127
130
  }
128
131
 
129
- async trackFlow(request: ActionRequest): Promise<void> {
132
+ async trackFlow(botContext: BotContext): Promise<void> {
130
133
  if (this.flowWebview) {
131
- await this.flowWebview.trackFlow(request)
134
+ await this.flowWebview.trackFlow(botContext)
132
135
  }
133
136
  }
134
137
 
138
+ async processContent(): Promise<void> {
139
+ return
140
+ }
141
+
135
142
  renderButton(buttonIndex: number, buttonStyle?: HtButtonStyle): JSX.Element {
136
143
  if (buttonStyle === HtButtonStyle.QUICK_REPLY) {
137
144
  return (
@@ -1,6 +1,6 @@
1
- import type { ActionRequest } from '@botonic/react'
1
+ import type { BotContext } from '@botonic/core'
2
2
 
3
- import { getFlowBuilderPlugin } from '../helpers'
3
+ import { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'
4
4
  import { ContentFieldsBase } from './content-fields-base'
5
5
  import {
6
6
  HtAiValidationType,
@@ -30,13 +30,16 @@ export class FlowCaptureUserInput extends ContentFieldsBase {
30
30
  }
31
31
 
32
32
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
- async trackFlow(_request: ActionRequest): Promise<void> {
33
+ async trackFlow(_botContext: BotContext): Promise<void> {
34
34
  return
35
35
  }
36
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)
37
+ async processContent(): Promise<void> {
38
+ return
39
+ }
40
+
41
+ toBotonic(botContext: BotContext): JSX.Element {
42
+ const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)
40
43
  const cmsApi = flowBuilderPlugin.cmsApi
41
44
  cmsApi.setCaptureUserInputId(this.id)
42
45
 
@@ -1,4 +1,8 @@
1
- import { type CarouselMessage, isWhatsapp } from '@botonic/core'
1
+ import {
2
+ type BotContext,
3
+ type CarouselMessage,
4
+ isWhatsapp,
5
+ } from '@botonic/core'
2
6
  import {
3
7
  type ActionRequest,
4
8
  Button,
@@ -111,10 +115,10 @@ export class FlowCarousel extends ContentFieldsBase {
111
115
  static fromAIAgent(
112
116
  id: string,
113
117
  carouselMessage: CarouselMessage,
114
- request: ActionRequest
118
+ botContext: ActionRequest
115
119
  ): JSX.Element {
116
120
  if (
117
- isWhatsapp(request.session) &&
121
+ isWhatsapp(botContext.session) &&
118
122
  FlowCarousel.areElementsValidForWhatsapp(carouselMessage)
119
123
  ) {
120
124
  if (
@@ -168,9 +172,10 @@ export class FlowCarousel extends ContentFieldsBase {
168
172
  return (
169
173
  <Carousel key={id}>
170
174
  {carouselMessage.content.elements.map((element, index) =>
171
- FlowElement.fromAIAgent(`${id}-element-${index}`, element).toBotonic(
172
- id
173
- )
175
+ FlowElement.fromAIAgent(
176
+ `${id}-element-${index}`,
177
+ element
178
+ ).renderElement(id)
174
179
  )}
175
180
  </Carousel>
176
181
  )
@@ -196,10 +201,15 @@ export class FlowCarousel extends ContentFieldsBase {
196
201
  }
197
202
  }
198
203
 
199
- toBotonic(id: string, request: ActionRequest): JSX.Element {
204
+ async processContent(botContext: BotContext): Promise<void> {
205
+ await this.trackFlow(botContext)
206
+ return
207
+ }
208
+
209
+ toBotonic(botContext: BotContext): JSX.Element {
200
210
  const carouselMessage = this.toCarouselMessage(this.elements)
201
211
  if (
202
- isWhatsapp(request.session) &&
212
+ isWhatsapp(botContext.session) &&
203
213
  FlowCarousel.areElementsValidForWhatsapp(carouselMessage)
204
214
  ) {
205
215
  if (this.elements.length === 1 && this.elements[0].button?.url) {
@@ -209,7 +219,7 @@ export class FlowCarousel extends ContentFieldsBase {
209
219
 
210
220
  return (
211
221
  <WhatsappCTAUrlButton
212
- key={id}
222
+ key={this.id}
213
223
  body={element.title}
214
224
  headerType={WhatsappCTAUrlHeaderType.Image}
215
225
  headerImage={element.image}
@@ -246,8 +256,8 @@ export class FlowCarousel extends ContentFieldsBase {
246
256
  )
247
257
  }
248
258
  return (
249
- <Carousel key={id}>
250
- {this.elements.map(element => element.toBotonic(id))}
259
+ <Carousel key={this.id}>
260
+ {this.elements.map(element => element.renderElement(this.id))}
251
261
  </Carousel>
252
262
  )
253
263
  }
@@ -1,5 +1,8 @@
1
- import { EventAction, type EventConditionalChannel } from '@botonic/core'
2
- import type { ActionRequest } from '@botonic/react'
1
+ import {
2
+ type BotContext,
3
+ EventAction,
4
+ type EventConditionalChannel,
5
+ } from '@botonic/core'
3
6
 
4
7
  import {
5
8
  getCommonFlowContentEventArgsForContentId,
@@ -16,18 +19,18 @@ export class FlowChannelConditional extends ContentFieldsBase {
16
19
 
17
20
  static fromHubtypeCMS(
18
21
  component: HtChannelConditionalNode,
19
- request: ActionRequest
22
+ botContext: BotContext
20
23
  ): FlowChannelConditional {
21
24
  const newChannelConditional = new FlowChannelConditional(component.id)
22
25
  newChannelConditional.code = component.code
23
26
  newChannelConditional.resultMapping = component.content.result_mapping
24
- newChannelConditional.setConditionalResult(request)
27
+ newChannelConditional.setConditionalResult(botContext)
25
28
 
26
29
  return newChannelConditional
27
30
  }
28
31
 
29
- setConditionalResult(request: ActionRequest): void {
30
- const provider = request.session.user.provider
32
+ setConditionalResult(botContext: BotContext): void {
33
+ const provider = botContext.session.user.provider
31
34
  const conditionalResult =
32
35
  this.resultMapping.find(rMap => rMap.result === provider) ||
33
36
  this.resultMapping.find(rMap => rMap.result === 'default')
@@ -41,9 +44,9 @@ export class FlowChannelConditional extends ContentFieldsBase {
41
44
  this.followUp = conditionalResult.target
42
45
  }
43
46
 
44
- async trackFlow(request: ActionRequest): Promise<void> {
47
+ async trackFlow(botContext: BotContext): Promise<void> {
45
48
  const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
46
- getCommonFlowContentEventArgsForContentId(request, this.id)
49
+ getCommonFlowContentEventArgsForContentId(botContext, this.id)
47
50
 
48
51
  const eventChannelConditional: EventConditionalChannel = {
49
52
  action: EventAction.ConditionalChannel,
@@ -56,7 +59,11 @@ export class FlowChannelConditional extends ContentFieldsBase {
56
59
  channel: this.channelResult,
57
60
  }
58
61
  const { action, ...eventArgs } = eventChannelConditional
59
- await trackEvent(request, action, eventArgs)
62
+ await trackEvent(botContext, action, eventArgs)
63
+ }
64
+
65
+ async processContent(botContext: BotContext): Promise<void> {
66
+ await this.trackFlow(botContext)
60
67
  }
61
68
 
62
69
  toBotonic(): JSX.Element {
@@ -1,5 +1,8 @@
1
- import { EventAction, type EventConditionalCountry } from '@botonic/core'
2
- import type { ActionRequest } from '@botonic/react'
1
+ import {
2
+ type BotContext,
3
+ EventAction,
4
+ type EventConditionalCountry,
5
+ } from '@botonic/core'
3
6
 
4
7
  import {
5
8
  getCommonFlowContentEventArgsForContentId,
@@ -15,18 +18,18 @@ export class FlowCountryConditional extends ContentFieldsBase {
15
18
 
16
19
  static fromHubtypeCMS(
17
20
  component: HtCountryConditionalNode,
18
- request: ActionRequest
21
+ botContext: BotContext
19
22
  ): FlowCountryConditional {
20
23
  const newCountryConditional = new FlowCountryConditional(component.id)
21
24
  newCountryConditional.code = component.code
22
25
  newCountryConditional.resultMapping = component.content.result_mapping
23
- newCountryConditional.setConditionalResult(request)
26
+ newCountryConditional.setConditionalResult(botContext)
24
27
 
25
28
  return newCountryConditional
26
29
  }
27
30
 
28
- setConditionalResult(request: ActionRequest): void {
29
- const country = request.getUserCountry()
31
+ setConditionalResult(botContext: BotContext): void {
32
+ const country = botContext.getUserCountry()
30
33
  const conditionalResult =
31
34
  this.resultMapping.find(rMap => rMap.result === country) ||
32
35
  this.resultMapping.find(rMap => rMap.result === 'default')
@@ -39,9 +42,9 @@ export class FlowCountryConditional extends ContentFieldsBase {
39
42
  this.followUp = conditionalResult.target
40
43
  }
41
44
 
42
- async trackFlow(request: ActionRequest): Promise<void> {
45
+ async trackFlow(botContext: BotContext): Promise<void> {
43
46
  const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
44
- getCommonFlowContentEventArgsForContentId(request, this.id)
47
+ getCommonFlowContentEventArgsForContentId(botContext, this.id)
45
48
  if (!this.conditionalResult?.result) {
46
49
  console.warn(
47
50
  `Tracking event for node ${this.code} but no conditional result found`
@@ -58,7 +61,12 @@ export class FlowCountryConditional extends ContentFieldsBase {
58
61
  country: (this.conditionalResult?.result as string) ?? '',
59
62
  }
60
63
  const { action, ...eventArgs } = eventCountryConditional
61
- await trackEvent(request, action, eventArgs)
64
+ await trackEvent(botContext, action, eventArgs)
65
+ }
66
+
67
+ async processContent(botContext: BotContext): Promise<void> {
68
+ await this.trackFlow(botContext)
69
+ return
62
70
  }
63
71
 
64
72
  toBotonic(): JSX.Element {
@@ -1,5 +1,8 @@
1
- import { EventAction, type EventConditionalCustom } from '@botonic/core'
2
- import type { ActionRequest } from '@botonic/react'
1
+ import {
2
+ type BotContext,
3
+ EventAction,
4
+ type EventConditionalCustom,
5
+ } from '@botonic/core'
3
6
 
4
7
  import {
5
8
  getCommonFlowContentEventArgsForContentId,
@@ -22,13 +25,13 @@ export class FlowCustomConditional extends ContentFieldsBase {
22
25
 
23
26
  static fromHubtypeCMS(
24
27
  component: HtCustomConditionalNode,
25
- request: ActionRequest
28
+ botContext: BotContext
26
29
  ): FlowCustomConditional {
27
30
  const newCustomConditional = new FlowCustomConditional(component.id)
28
31
  newCustomConditional.code = component.code
29
32
  newCustomConditional.arguments = component.content.arguments
30
33
  newCustomConditional.resultMapping = component.content.result_mapping
31
- newCustomConditional.setConditionalResult(request)
34
+ newCustomConditional.setConditionalResult(botContext)
32
35
  newCustomConditional.variableFormat = (
33
36
  component.content.arguments as HtFunctionArgument[]
34
37
  )[0].type
@@ -36,7 +39,7 @@ export class FlowCustomConditional extends ContentFieldsBase {
36
39
  return newCustomConditional
37
40
  }
38
41
 
39
- setConditionalResult(request: ActionRequest): void {
42
+ setConditionalResult(botContext: BotContext): void {
40
43
  const functionArgument = this.arguments.find(arg => {
41
44
  if ('name' in arg) {
42
45
  return arg.name === 'keyPath'
@@ -52,7 +55,7 @@ export class FlowCustomConditional extends ContentFieldsBase {
52
55
  throw new Error(`Key path not found for node ${this.code}`)
53
56
  }
54
57
 
55
- const botVariable = this.getValueFromKeyPath(request, keyPath)
58
+ const botVariable = this.getValueFromKeyPath(botContext, keyPath)
56
59
 
57
60
  let conditionalResult =
58
61
  this.resultMapping.find(rMap => rMap.result === botVariable) ||
@@ -80,9 +83,9 @@ export class FlowCustomConditional extends ContentFieldsBase {
80
83
  this.followUp = conditionalResult.target
81
84
  }
82
85
 
83
- async trackFlow(request: ActionRequest): Promise<void> {
86
+ async trackFlow(botContext: BotContext): Promise<void> {
84
87
  const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
85
- getCommonFlowContentEventArgsForContentId(request, this.id)
88
+ getCommonFlowContentEventArgsForContentId(botContext, this.id)
86
89
  if (!this.conditionalResult?.result) {
87
90
  console.warn(
88
91
  `Tracking event for node ${this.code} but no conditional result found`
@@ -100,7 +103,7 @@ export class FlowCustomConditional extends ContentFieldsBase {
100
103
  variableFormat: this.variableFormat,
101
104
  }
102
105
  const { action, ...eventArgs } = eventCustomConditional
103
- await trackEvent(request, action, eventArgs)
106
+ await trackEvent(botContext, action, eventArgs)
104
107
  }
105
108
 
106
109
  private isBooleanConditional(resultMapping: HtFunctionResult[]): boolean {
@@ -111,6 +114,11 @@ export class FlowCustomConditional extends ContentFieldsBase {
111
114
  )
112
115
  }
113
116
 
117
+ async processContent(botContext: BotContext): Promise<void> {
118
+ await this.trackFlow(botContext)
119
+ return
120
+ }
121
+
114
122
  toBotonic() {
115
123
  return <></>
116
124
  }
@@ -1,11 +1,5 @@
1
- import type { Button } from '@botonic/core'
2
- import {
3
- type ActionRequest,
4
- Element,
5
- Pic,
6
- Subtitle,
7
- Title,
8
- } from '@botonic/react'
1
+ import type { BotContext, Button } from '@botonic/core'
2
+ import { Element, Pic, Subtitle, Title } from '@botonic/react'
9
3
 
10
4
  import type { FlowBuilderApi } from '../api'
11
5
  import { ContentFieldsBase } from './content-fields-base'
@@ -60,13 +54,18 @@ export class FlowElement extends ContentFieldsBase {
60
54
  return newElement
61
55
  }
62
56
 
63
- async trackFlow(request: ActionRequest): Promise<void> {
57
+ async trackFlow(botContext: BotContext): Promise<void> {
64
58
  if (this.button) {
65
- await this.button.trackFlow(request)
59
+ await this.button.trackFlow(botContext)
66
60
  }
67
61
  }
68
62
 
69
- toBotonic(parentId: string): JSX.Element {
63
+ async processContent(botContext: BotContext): Promise<void> {
64
+ await this.trackFlow(botContext)
65
+ return
66
+ }
67
+
68
+ renderElement(parentId: string): JSX.Element {
70
69
  return (
71
70
  <Element key={`${parentId}-${this.id}`}>
72
71
  <Pic src={this.image} />