@botonic/plugin-flow-builder 0.46.2 → 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 (316) 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 -6
  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 +4 -2
  34. package/lib/cjs/content-fields/flow-button.js +5 -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 +10 -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.js.map +1 -0
  106. package/lib/cjs/tracking.js +6 -6
  107. package/lib/cjs/tracking.js.map +1 -1
  108. package/lib/cjs/types.d.ts +1 -1
  109. package/lib/cjs/user-input/capture-user-input-api.js +4 -4
  110. package/lib/cjs/user-input/capture-user-input-api.js.map +1 -1
  111. package/lib/cjs/user-input/index.js +4 -4
  112. package/lib/cjs/user-input/index.js.map +1 -1
  113. package/lib/cjs/user-input/smart-intent.js +2 -2
  114. package/lib/cjs/user-input/smart-intent.js.map +1 -1
  115. package/lib/cjs/utils/ai-agent.d.ts +18 -0
  116. package/lib/cjs/utils/ai-agent.js +177 -0
  117. package/lib/cjs/utils/ai-agent.js.map +1 -0
  118. package/lib/cjs/utils/authentication.d.ts +2 -0
  119. package/lib/cjs/utils/authentication.js +21 -0
  120. package/lib/cjs/utils/authentication.js.map +1 -0
  121. package/lib/cjs/{helpers.d.ts → utils/get-flow-builder-plugin.d.ts} +1 -1
  122. package/lib/cjs/{helpers.js → utils/get-flow-builder-plugin.js} +1 -1
  123. package/lib/cjs/utils/get-flow-builder-plugin.js.map +1 -0
  124. package/lib/cjs/{utils.d.ts → utils/input.d.ts} +1 -2
  125. package/lib/cjs/{utils.js → utils/input.js} +3 -21
  126. package/lib/cjs/utils/input.js.map +1 -0
  127. package/lib/esm/action/ai-agent-from-user-input.d.ts +3 -0
  128. package/lib/esm/action/ai-agent-from-user-input.js +23 -0
  129. package/lib/esm/action/ai-agent-from-user-input.js.map +1 -0
  130. package/lib/esm/action/context.d.ts +11 -0
  131. package/lib/esm/action/context.js +17 -0
  132. package/lib/esm/action/context.js.map +1 -0
  133. package/lib/esm/action/fallback.d.ts +1 -1
  134. package/lib/esm/action/first-interaction.d.ts +1 -1
  135. package/lib/esm/action/first-interaction.js +4 -4
  136. package/lib/esm/action/first-interaction.js.map +1 -1
  137. package/lib/esm/action/get-contents.d.ts +3 -0
  138. package/lib/esm/action/get-contents.js +44 -0
  139. package/lib/esm/action/get-contents.js.map +1 -0
  140. package/lib/esm/action/index.d.ts +6 -15
  141. package/lib/esm/action/index.js +31 -94
  142. package/lib/esm/action/index.js.map +1 -1
  143. package/lib/esm/action/knowledge-bases.d.ts +1 -1
  144. package/lib/esm/action/knowledge-bases.js +3 -3
  145. package/lib/esm/action/knowledge-bases.js.map +1 -1
  146. package/lib/esm/action/payload.d.ts +1 -1
  147. package/lib/esm/api.d.ts +0 -1
  148. package/lib/esm/api.js +0 -7
  149. package/lib/esm/api.js.map +1 -1
  150. package/lib/esm/content-fields/content-fields-base.d.ts +5 -4
  151. package/lib/esm/content-fields/content-fields-base.js +7 -7
  152. package/lib/esm/content-fields/content-fields-base.js.map +1 -1
  153. package/lib/esm/content-fields/flow-ai-agent.d.ts +14 -6
  154. package/lib/esm/content-fields/flow-ai-agent.js +100 -17
  155. package/lib/esm/content-fields/flow-ai-agent.js.map +1 -1
  156. package/lib/esm/content-fields/flow-bot-action.d.ts +4 -2
  157. package/lib/esm/content-fields/flow-bot-action.js +10 -5
  158. package/lib/esm/content-fields/flow-bot-action.js.map +1 -1
  159. package/lib/esm/content-fields/flow-button.d.ts +4 -2
  160. package/lib/esm/content-fields/flow-button.js +5 -2
  161. package/lib/esm/content-fields/flow-button.js.map +1 -1
  162. package/lib/esm/content-fields/flow-capture-user-input.d.ts +4 -3
  163. package/lib/esm/content-fields/flow-capture-user-input.js +7 -5
  164. package/lib/esm/content-fields/flow-capture-user-input.js.map +1 -1
  165. package/lib/esm/content-fields/flow-carousel.d.ts +4 -3
  166. package/lib/esm/content-fields/flow-carousel.js +11 -7
  167. package/lib/esm/content-fields/flow-carousel.js.map +1 -1
  168. package/lib/esm/content-fields/flow-channel-conditional.d.ts +5 -4
  169. package/lib/esm/content-fields/flow-channel-conditional.js +10 -7
  170. package/lib/esm/content-fields/flow-channel-conditional.js.map +1 -1
  171. package/lib/esm/content-fields/flow-country-conditional.d.ts +5 -4
  172. package/lib/esm/content-fields/flow-country-conditional.js +11 -7
  173. package/lib/esm/content-fields/flow-country-conditional.js.map +1 -1
  174. package/lib/esm/content-fields/flow-custom-conditional.d.ts +5 -4
  175. package/lib/esm/content-fields/flow-custom-conditional.js +11 -7
  176. package/lib/esm/content-fields/flow-custom-conditional.js.map +1 -1
  177. package/lib/esm/content-fields/flow-element.d.ts +4 -4
  178. package/lib/esm/content-fields/flow-element.js +7 -3
  179. package/lib/esm/content-fields/flow-element.js.map +1 -1
  180. package/lib/esm/content-fields/flow-go-to-flow.d.ts +3 -3
  181. package/lib/esm/content-fields/flow-go-to-flow.js +7 -15
  182. package/lib/esm/content-fields/flow-go-to-flow.js.map +1 -1
  183. package/lib/esm/content-fields/flow-handoff.d.ts +5 -4
  184. package/lib/esm/content-fields/flow-handoff.js +11 -7
  185. package/lib/esm/content-fields/flow-handoff.js.map +1 -1
  186. package/lib/esm/content-fields/flow-image.d.ts +4 -3
  187. package/lib/esm/content-fields/flow-image.js +8 -4
  188. package/lib/esm/content-fields/flow-image.js.map +1 -1
  189. package/lib/esm/content-fields/flow-knowledge-base.d.ts +4 -3
  190. package/lib/esm/content-fields/flow-knowledge-base.js +7 -3
  191. package/lib/esm/content-fields/flow-knowledge-base.js.map +1 -1
  192. package/lib/esm/content-fields/flow-queue-status-conditional.d.ts +3 -2
  193. package/lib/esm/content-fields/flow-queue-status-conditional.js +7 -3
  194. package/lib/esm/content-fields/flow-queue-status-conditional.js.map +1 -1
  195. package/lib/esm/content-fields/flow-rating.d.ts +4 -3
  196. package/lib/esm/content-fields/flow-rating.js +13 -9
  197. package/lib/esm/content-fields/flow-rating.js.map +1 -1
  198. package/lib/esm/content-fields/flow-text.d.ts +4 -4
  199. package/lib/esm/content-fields/flow-text.js +10 -6
  200. package/lib/esm/content-fields/flow-text.js.map +1 -1
  201. package/lib/esm/content-fields/flow-video.d.ts +4 -3
  202. package/lib/esm/content-fields/flow-video.js +8 -4
  203. package/lib/esm/content-fields/flow-video.js.map +1 -1
  204. package/lib/esm/content-fields/flow-webview.d.ts +3 -2
  205. package/lib/esm/content-fields/flow-webview.js +6 -3
  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 +5 -3
  208. package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js +14 -10
  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 +5 -3
  211. package/lib/esm/content-fields/flow-whatsapp-template.js +26 -22
  212. package/lib/esm/content-fields/flow-whatsapp-template.js.map +1 -1
  213. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +4 -3
  214. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +6 -4
  215. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
  216. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +4 -3
  217. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +7 -5
  218. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
  219. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +4 -3
  220. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +10 -6
  221. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
  222. package/lib/esm/content-fields/whatsapp-button-list/index.d.ts +3 -0
  223. package/lib/esm/content-fields/whatsapp-button-list/index.js +10 -0
  224. package/lib/esm/content-fields/whatsapp-button-list/index.js.map +1 -0
  225. package/lib/esm/filters/index.d.ts +1 -0
  226. package/lib/esm/filters/index.js +15 -0
  227. package/lib/esm/filters/index.js.map +1 -1
  228. package/lib/esm/index.d.ts +1 -1
  229. package/lib/esm/index.js +4 -8
  230. package/lib/esm/index.js.map +1 -1
  231. package/lib/esm/structured-output/flow-builder-content.js.map +1 -0
  232. package/lib/esm/tracking.js +6 -6
  233. package/lib/esm/tracking.js.map +1 -1
  234. package/lib/esm/types.d.ts +1 -1
  235. package/lib/esm/user-input/capture-user-input-api.js +4 -4
  236. package/lib/esm/user-input/capture-user-input-api.js.map +1 -1
  237. package/lib/esm/user-input/index.js +4 -4
  238. package/lib/esm/user-input/index.js.map +1 -1
  239. package/lib/esm/user-input/smart-intent.js +2 -2
  240. package/lib/esm/user-input/smart-intent.js.map +1 -1
  241. package/lib/esm/utils/ai-agent.d.ts +18 -0
  242. package/lib/esm/utils/ai-agent.js +177 -0
  243. package/lib/esm/utils/ai-agent.js.map +1 -0
  244. package/lib/esm/utils/authentication.d.ts +2 -0
  245. package/lib/esm/utils/authentication.js +21 -0
  246. package/lib/esm/utils/authentication.js.map +1 -0
  247. package/lib/esm/{helpers.d.ts → utils/get-flow-builder-plugin.d.ts} +1 -1
  248. package/lib/esm/{helpers.js → utils/get-flow-builder-plugin.js} +1 -1
  249. package/lib/esm/utils/get-flow-builder-plugin.js.map +1 -0
  250. package/lib/esm/{utils.d.ts → utils/input.d.ts} +1 -2
  251. package/lib/esm/{utils.js → utils/input.js} +3 -21
  252. package/lib/esm/utils/input.js.map +1 -0
  253. package/package.json +2 -2
  254. package/src/action/ai-agent-from-user-input.ts +35 -0
  255. package/src/action/context.ts +29 -0
  256. package/src/action/fallback.ts +1 -1
  257. package/src/action/first-interaction.ts +4 -4
  258. package/src/action/get-contents.ts +51 -0
  259. package/src/action/index.tsx +42 -136
  260. package/src/action/knowledge-bases.ts +5 -2
  261. package/src/action/payload.ts +1 -1
  262. package/src/api.ts +0 -8
  263. package/src/content-fields/content-fields-base.ts +11 -9
  264. package/src/content-fields/flow-ai-agent.tsx +166 -31
  265. package/src/content-fields/flow-bot-action.tsx +17 -6
  266. package/src/content-fields/flow-button.tsx +8 -3
  267. package/src/content-fields/flow-capture-user-input.tsx +9 -6
  268. package/src/content-fields/flow-carousel.tsx +21 -11
  269. package/src/content-fields/flow-channel-conditional.tsx +16 -9
  270. package/src/content-fields/flow-country-conditional.tsx +17 -9
  271. package/src/content-fields/flow-custom-conditional.tsx +17 -9
  272. package/src/content-fields/flow-element.tsx +10 -11
  273. package/src/content-fields/flow-go-to-flow.tsx +10 -24
  274. package/src/content-fields/flow-handoff.tsx +21 -10
  275. package/src/content-fields/flow-image.tsx +11 -5
  276. package/src/content-fields/flow-knowledge-base.tsx +11 -5
  277. package/src/content-fields/flow-queue-status-conditional.tsx +13 -5
  278. package/src/content-fields/flow-rating.tsx +16 -16
  279. package/src/content-fields/flow-text.tsx +13 -7
  280. package/src/content-fields/flow-video.tsx +11 -5
  281. package/src/content-fields/flow-webview.tsx +12 -5
  282. package/src/content-fields/flow-whatsapp-cta-url-button.tsx +16 -12
  283. package/src/content-fields/flow-whatsapp-template.tsx +28 -24
  284. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx +8 -5
  285. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx +8 -6
  286. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx +15 -15
  287. package/src/content-fields/whatsapp-button-list/index.ts +3 -0
  288. package/src/filters/index.ts +20 -0
  289. package/src/index.ts +3 -14
  290. package/src/tracking.ts +1 -1
  291. package/src/types.ts +1 -1
  292. package/src/user-input/capture-user-input-api.ts +2 -2
  293. package/src/user-input/index.ts +1 -1
  294. package/src/user-input/smart-intent.ts +1 -1
  295. package/src/utils/ai-agent.ts +233 -0
  296. package/src/utils/authentication.ts +23 -0
  297. package/src/{helpers.ts → utils/get-flow-builder-plugin.ts} +1 -1
  298. package/src/{utils.ts → utils/input.ts} +3 -23
  299. package/lib/cjs/action/ai-agent/index.d.ts +0 -3
  300. package/lib/cjs/action/ai-agent/index.js +0 -94
  301. package/lib/cjs/action/ai-agent/index.js.map +0 -1
  302. package/lib/cjs/action/ai-agent/structured-output/flow-builder-content.js.map +0 -1
  303. package/lib/cjs/helpers.js.map +0 -1
  304. package/lib/cjs/utils.js.map +0 -1
  305. package/lib/esm/action/ai-agent/index.d.ts +0 -3
  306. package/lib/esm/action/ai-agent/index.js +0 -94
  307. package/lib/esm/action/ai-agent/index.js.map +0 -1
  308. package/lib/esm/action/ai-agent/structured-output/flow-builder-content.js.map +0 -1
  309. package/lib/esm/helpers.js.map +0 -1
  310. package/lib/esm/utils.js.map +0 -1
  311. package/src/action/ai-agent/index.ts +0 -138
  312. /package/lib/cjs/{action/ai-agent/structured-output → structured-output}/flow-builder-content.d.ts +0 -0
  313. /package/lib/cjs/{action/ai-agent/structured-output → structured-output}/flow-builder-content.js +0 -0
  314. /package/lib/esm/{action/ai-agent/structured-output → structured-output}/flow-builder-content.d.ts +0 -0
  315. /package/lib/esm/{action/ai-agent/structured-output → structured-output}/flow-builder-content.js +0 -0
  316. /package/src/{action/ai-agent/structured-output → structured-output}/flow-builder-content.ts +0 -0
@@ -0,0 +1,29 @@
1
+ import type { BotContext } from '@botonic/core'
2
+
3
+ import type { FlowBuilderApi } from '../api'
4
+ import type BotonicPluginFlowBuilder from '../index'
5
+ import { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'
6
+
7
+ export interface FlowBuilderContext {
8
+ cmsApi: FlowBuilderApi
9
+ flowBuilderPlugin: BotonicPluginFlowBuilder
10
+ request: BotContext
11
+ resolvedLocale: string
12
+ contentID?: string
13
+ }
14
+
15
+ export function getFlowBuilderActionContext(
16
+ request: BotContext,
17
+ contentID?: string
18
+ ): FlowBuilderContext {
19
+ const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
20
+ const cmsApi = flowBuilderPlugin.cmsApi
21
+ const resolvedLocale = flowBuilderPlugin.cmsApi.getResolvedLocale()
22
+ return {
23
+ cmsApi,
24
+ flowBuilderPlugin,
25
+ request,
26
+ resolvedLocale,
27
+ contentID,
28
+ }
29
+ }
@@ -7,7 +7,7 @@ import {
7
7
  getCommonFlowContentEventArgsForContentId,
8
8
  trackEvent,
9
9
  } from '../tracking'
10
- import type { FlowBuilderContext } from './index'
10
+ import type { FlowBuilderContext } from './context'
11
11
 
12
12
  export async function getContentsByFallback({
13
13
  cmsApi,
@@ -2,9 +2,9 @@ import type { FlowBuilderApi } from '../api'
2
2
  import { MAIN_FLOW_NAME } from '../constants'
3
3
  import { FlowBotAction, type FlowContent } from '../content-fields'
4
4
  import type BotonicPluginFlowBuilder from '../index'
5
- import { inputHasTextOrTranscript } from '../utils'
6
- import { getContentsByAiAgent } from './ai-agent'
7
- import type { FlowBuilderContext } from './index'
5
+ import { inputHasTextOrTranscript } from '../utils/input'
6
+ import { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'
7
+ import type { FlowBuilderContext } from './context'
8
8
  import { getContentsByKnowledgeBase } from './knowledge-bases'
9
9
  import { getContentsByPayload } from './payload'
10
10
 
@@ -100,7 +100,7 @@ async function getContentsByUserInput(
100
100
  }
101
101
 
102
102
  if (!flowBuilderPlugin.disableAIAgentInFirstInteraction) {
103
- const contentsByAiAgent = await getContentsByAiAgent(context)
103
+ const contentsByAiAgent = await getContentsByAiAgentFromUserInput(context)
104
104
  return contentsByAiAgent
105
105
  }
106
106
 
@@ -0,0 +1,51 @@
1
+ import { type BotContext, INPUT } from '@botonic/core'
2
+ import { EMPTY_PAYLOAD } from '../constants'
3
+ import type { FlowContent } from '../content-fields'
4
+ import { inputHasTextOrTranscript } from '../utils/input'
5
+ import { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'
6
+ import { getFlowBuilderActionContext } from './context'
7
+ import { getContentsByFallback } from './fallback'
8
+ import { getContentsByFirstInteraction } from './first-interaction'
9
+ import { getContentsByKnowledgeBase } from './knowledge-bases'
10
+ import { getContentsByPayload } from './payload'
11
+
12
+ export async function getContents(
13
+ botContext: BotContext,
14
+ contentID?: string
15
+ ): Promise<FlowContent[]> {
16
+ const context = getFlowBuilderActionContext(botContext, contentID)
17
+
18
+ if (botContext.session.is_first_interaction) {
19
+ return await getContentsByFirstInteraction(context)
20
+ }
21
+ // TODO: Add needed logic when we can define contents for multi locale queue position message
22
+ if (botContext.input.type === INPUT.EVENT_QUEUE_POSITION_CHANGED) {
23
+ return []
24
+ }
25
+
26
+ if (botContext.input.payload?.startsWith(EMPTY_PAYLOAD)) {
27
+ botContext.input.payload = undefined
28
+ }
29
+
30
+ if (botContext.input.payload || contentID) {
31
+ const contentsByPayload = await getContentsByPayload(context)
32
+ if (contentsByPayload.length > 0) {
33
+ return contentsByPayload
34
+ }
35
+
36
+ return await getContentsByFallback(context)
37
+ }
38
+
39
+ if (inputHasTextOrTranscript(botContext.input)) {
40
+ const aiAgentContents = await getContentsByAiAgentFromUserInput(context)
41
+ if (aiAgentContents.length > 0) {
42
+ return aiAgentContents
43
+ }
44
+ const knowledgeBaseContents = await getContentsByKnowledgeBase(context)
45
+ if (knowledgeBaseContents.length > 0) {
46
+ return knowledgeBaseContents
47
+ }
48
+ }
49
+
50
+ return await getContentsByFallback(context)
51
+ }
@@ -1,6 +1,5 @@
1
- import { type BotContext, INPUT, isDev, isWebchat } from '@botonic/core'
1
+ import { type BotContext, isDev, isWebchat } from '@botonic/core'
2
2
  import {
3
- type ActionRequest,
4
3
  Multichannel,
5
4
  RequestContext,
6
5
  WebchatSettings,
@@ -8,19 +7,12 @@ import {
8
7
  } from '@botonic/react'
9
8
  import React from 'react'
10
9
 
11
- import type { FlowBuilderApi } from '../api'
12
- import { EMPTY_PAYLOAD } from '../constants'
13
- import { type FlowContent, FlowHandoff } from '../content-fields'
14
- import { FlowBotAction } from '../content-fields/flow-bot-action'
15
- import { ContentFilterExecutor } from '../filters'
16
- import { getFlowBuilderPlugin } from '../helpers'
17
- import type BotonicPluginFlowBuilder from '../index'
18
- import { inputHasTextOrTranscript } from '../utils'
19
- import { getContentsByAiAgent } from './ai-agent'
20
- import { getContentsByFallback } from './fallback'
10
+ import { FlowAiAgent, type FlowContent } from '../content-fields'
11
+ import { filterContents } from '../filters'
12
+ import { splitAiAgentContents } from '../utils/ai-agent'
13
+ import { getFlowBuilderActionContext } from './context'
21
14
  import { getContentsByFirstInteraction } from './first-interaction'
22
- import { getContentsByKnowledgeBase } from './knowledge-bases'
23
- import { getContentsByPayload } from './payload'
15
+ import { getContents } from './get-contents'
24
16
 
25
17
  export type FlowBuilderActionProps = {
26
18
  contents: FlowContent[]
@@ -32,62 +24,60 @@ export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
32
24
  declare context: React.ContextType<typeof RequestContext>
33
25
 
34
26
  static async executeConversationStart(
35
- request: ActionRequest
27
+ botContext: BotContext
36
28
  ): Promise<FlowBuilderActionProps> {
37
- const context = getContext(request)
29
+ const context = getFlowBuilderActionContext(botContext)
38
30
  const contents = await getContentsByFirstInteraction(context)
39
- const filteredContents = await filterContents(request, contents)
40
- await FlowBuilderAction.trackAllContents(request, filteredContents)
41
- await FlowBuilderAction.doHandoffAndBotActions(request, filteredContents)
31
+
32
+ const filteredContents = await FlowBuilderAction.prepareContentsToRender(
33
+ botContext,
34
+ contents
35
+ )
42
36
 
43
37
  return { contents: filteredContents }
44
38
  }
45
39
 
46
40
  static async botonicInit(
47
- request: ActionRequest,
41
+ botContext: BotContext,
48
42
  contentID?: string
49
43
  ): Promise<FlowBuilderActionProps> {
50
- const contents = await getContents(request, contentID)
51
- const filteredContents = await filterContents(request, contents)
52
- await FlowBuilderAction.trackAllContents(request, filteredContents)
53
- await FlowBuilderAction.doHandoffAndBotActions(request, filteredContents)
44
+ const contents = await getContents(botContext, contentID)
54
45
 
55
- return { contents: filteredContents }
56
- }
46
+ const contentsToRender = await FlowBuilderAction.prepareContentsToRender(
47
+ botContext,
48
+ contents
49
+ )
57
50
 
58
- static async trackAllContents(
59
- request: ActionRequest,
60
- contents: FlowContent[]
61
- ) {
62
- for (const content of contents) {
63
- await content.trackFlow(request)
64
- }
51
+ return { contents: contentsToRender }
65
52
  }
66
53
 
67
- static async doHandoffAndBotActions(
68
- request: ActionRequest,
54
+ static async prepareContentsToRender(
55
+ botContext: BotContext,
69
56
  contents: FlowContent[]
70
57
  ) {
71
- const handoffContent = contents.find(
72
- content => content instanceof FlowHandoff
73
- ) as FlowHandoff
74
- if (handoffContent) {
75
- await handoffContent.doHandoff(request)
58
+ const filteredContents = await filterContents(botContext, contents)
59
+
60
+ for (const content of filteredContents) {
61
+ if (content instanceof FlowAiAgent) {
62
+ const splitContents = splitAiAgentContents(filteredContents)
63
+ if (!splitContents) {
64
+ continue
65
+ }
66
+ const { contentsBeforeAiAgent } = splitContents
67
+ await content.processContent(botContext, contentsBeforeAiAgent)
68
+ } else {
69
+ await content.processContent(botContext)
70
+ }
76
71
  }
77
72
 
78
- const botActionContent = contents.find(
79
- content => content instanceof FlowBotAction
80
- ) as FlowBotAction
81
- if (botActionContent) {
82
- botActionContent.doBotAction(request)
83
- }
73
+ return filteredContents
84
74
  }
85
75
 
86
76
  render(): JSX.Element | JSX.Element[] {
87
77
  const { contents, webchatSettingsParams } = this.props
88
- const request = this.context as ActionRequest
78
+ const botContext = this.context as BotContext
89
79
  const shouldSendWebchatSettings =
90
- (isWebchat(request.session) || isDev(request.session)) &&
80
+ (isWebchat(botContext.session) || isDev(botContext.session)) &&
91
81
  !!webchatSettingsParams
92
82
 
93
83
  return (
@@ -95,7 +85,7 @@ export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
95
85
  {shouldSendWebchatSettings && (
96
86
  <WebchatSettings {...webchatSettingsParams} />
97
87
  )}
98
- {contents.map(content => content.toBotonic(content.id, request))}
88
+ {contents.map(content => content.toBotonic(botContext))}
99
89
  </>
100
90
  )
101
91
  }
@@ -104,9 +94,9 @@ export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
104
94
  export class FlowBuilderMultichannelAction extends FlowBuilderAction {
105
95
  render(): JSX.Element | JSX.Element[] {
106
96
  const { contents, webchatSettingsParams } = this.props
107
- const request = this.context as ActionRequest
97
+ const botContext = this.context as BotContext
108
98
  const shouldSendWebchatSettings =
109
- (isWebchat(request.session) || isDev(request.session)) &&
99
+ (isWebchat(botContext.session) || isDev(botContext.session)) &&
110
100
  !!webchatSettingsParams
111
101
 
112
102
  return (
@@ -114,92 +104,8 @@ export class FlowBuilderMultichannelAction extends FlowBuilderAction {
114
104
  {shouldSendWebchatSettings && (
115
105
  <WebchatSettings {...webchatSettingsParams} />
116
106
  )}
117
- {contents.map(content => content.toBotonic(content.id, request))}
107
+ {contents.map(content => content.toBotonic(botContext))}
118
108
  </Multichannel>
119
109
  )
120
110
  }
121
111
  }
122
-
123
- async function getContents(
124
- request: ActionRequest,
125
- contentID?: string
126
- ): Promise<FlowContent[]> {
127
- const context = getContext(request, contentID)
128
-
129
- if (request.session.is_first_interaction) {
130
- return await getContentsByFirstInteraction(context)
131
- }
132
- // TODO: Add needed logic when we can define contents for multi locale queue position message
133
- if (request.input.type === INPUT.EVENT_QUEUE_POSITION_CHANGED) {
134
- return []
135
- }
136
-
137
- if (request.input.payload?.startsWith(EMPTY_PAYLOAD)) {
138
- request.input.payload = undefined
139
- }
140
-
141
- if (request.input.payload || contentID) {
142
- const contentsByPayload = await getContentsByPayload(context)
143
- if (contentsByPayload.length > 0) {
144
- return contentsByPayload
145
- }
146
-
147
- return await getContentsByFallback(context)
148
- }
149
-
150
- if (inputHasTextOrTranscript(request.input)) {
151
- const aiAgentContents = await getContentsByAiAgent(context)
152
- if (aiAgentContents.length > 0) {
153
- return aiAgentContents
154
- }
155
- const knowledgeBaseContents = await getContentsByKnowledgeBase(context)
156
- if (knowledgeBaseContents.length > 0) {
157
- return knowledgeBaseContents
158
- }
159
- }
160
-
161
- return await getContentsByFallback(context)
162
- }
163
-
164
- async function filterContents(
165
- request: BotContext,
166
- contents: FlowContent[]
167
- ): Promise<FlowContent[]> {
168
- const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
169
- const contentFilters = flowBuilderPlugin.contentFilters
170
- const contentFilterExecutor = new ContentFilterExecutor({
171
- filters: contentFilters,
172
- })
173
-
174
- const filteredContents: FlowContent[] = []
175
- for (const content of contents) {
176
- const filteredContent = await contentFilterExecutor.filter(request, content)
177
- filteredContents.push(filteredContent)
178
- }
179
-
180
- return filteredContents
181
- }
182
-
183
- export interface FlowBuilderContext {
184
- cmsApi: FlowBuilderApi
185
- flowBuilderPlugin: BotonicPluginFlowBuilder
186
- request: ActionRequest
187
- resolvedLocale: string
188
- contentID?: string
189
- }
190
-
191
- function getContext(
192
- request: ActionRequest,
193
- contentID?: string
194
- ): FlowBuilderContext {
195
- const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
196
- const cmsApi = flowBuilderPlugin.cmsApi
197
- const resolvedLocale = flowBuilderPlugin.cmsApi.getResolvedLocale()
198
- return {
199
- cmsApi,
200
- flowBuilderPlugin,
201
- request,
202
- resolvedLocale,
203
- contentID,
204
- }
205
- }
@@ -17,8 +17,11 @@ import {
17
17
  trackEvent,
18
18
  } from '../tracking'
19
19
  import type { KnowledgeBaseFunction } from '../types'
20
- import { inputHasTextOrTranscript, isKnowledgeBasesAllowed } from '../utils'
21
- import type { FlowBuilderContext } from './index'
20
+ import {
21
+ inputHasTextOrTranscript,
22
+ isKnowledgeBasesAllowed,
23
+ } from '../utils/input'
24
+ import type { FlowBuilderContext } from './context'
22
25
 
23
26
  export async function getContentsByKnowledgeBase({
24
27
  cmsApi,
@@ -9,7 +9,7 @@ import {
9
9
  import type { FlowContent } from '../content-fields'
10
10
  import type { HtNodeWithContent } from '../content-fields/hubtype-fields'
11
11
  import { trackEvent } from '../tracking'
12
- import type { FlowBuilderContext } from './index'
12
+ import type { FlowBuilderContext } from './context'
13
13
 
14
14
  export async function getContentsByPayload(
15
15
  context: FlowBuilderContext
package/src/api.ts CHANGED
@@ -204,14 +204,6 @@ export class FlowBuilderApi {
204
204
  return UUID_REGEXP.test(str)
205
205
  }
206
206
 
207
- isGoToFlow(id: string): boolean {
208
- if (!this.isUUID(id)) {
209
- return false
210
- }
211
- const node = this.getNodeById(id)
212
- return node?.type === HtNodeWithContentType.GO_TO_FLOW
213
- }
214
-
215
207
  createPayloadWithParams(botActionNode: HtBotActionNode): string {
216
208
  const payloadId = botActionNode.content.payload_id
217
209
  const payloadNode = this.getNodeById<HtPayloadNode>(payloadId)
@@ -1,4 +1,4 @@
1
- import type { ActionRequest } from '@botonic/react'
1
+ import type { BotContext } from '@botonic/core'
2
2
 
3
3
  import {
4
4
  ACCESS_TOKEN_VARIABLE_KEY,
@@ -18,7 +18,9 @@ export abstract class ContentFieldsBase {
18
18
 
19
19
  constructor(public readonly id: string) {}
20
20
 
21
- abstract trackFlow(request: ActionRequest): Promise<void>
21
+ abstract trackFlow(botContext: BotContext): Promise<void>
22
+
23
+ abstract processContent(botContext: BotContext): Promise<void>
22
24
 
23
25
  static getTextByLocale(locale: string, text: HtTextLocale[]): string {
24
26
  const result = text.find(t => t.locale === locale)
@@ -42,17 +44,17 @@ export abstract class ContentFieldsBase {
42
44
  return queues.find(queue => queue.locale === locale)
43
45
  }
44
46
 
45
- replaceVariables(text: string, request: ActionRequest): string {
47
+ replaceVariables(text: string, botContext: BotContext): string {
46
48
  const matches = text.match(VARIABLE_PATTERN_GLOBAL)
47
49
 
48
50
  let replacedText = text
49
- if (matches && request) {
51
+ if (matches && botContext) {
50
52
  matches.forEach(match => {
51
53
  // remove \\ ( escape for _ ) added by text node with markdown
52
54
  const keyPath = match.slice(1, -1).replaceAll('\\', '')
53
55
  const botVariable = keyPath.endsWith(ACCESS_TOKEN_VARIABLE_KEY)
54
56
  ? match
55
- : this.getValueFromKeyPath(request, keyPath)
57
+ : this.getValueFromKeyPath(botContext, keyPath)
56
58
  // TODO In local if change variable and render multiple times the value is always the last update
57
59
  replacedText = replacedText.replace(
58
60
  match,
@@ -64,10 +66,10 @@ export abstract class ContentFieldsBase {
64
66
  return replacedText
65
67
  }
66
68
 
67
- getValueFromKeyPath(request: ActionRequest, keyPath: string): any {
69
+ getValueFromKeyPath(botContext: BotContext, keyPath: string): any {
68
70
  if (keyPath.startsWith('session.user.contact_info.')) {
69
71
  const name = keyPath.split('.').at(-1)
70
- return request.session.user.contact_info?.find(
72
+ return botContext.session.user.contact_info?.find(
71
73
  contact => contact.name === name
72
74
  )?.value
73
75
  }
@@ -75,14 +77,14 @@ export abstract class ContentFieldsBase {
75
77
  if (keyPath.startsWith('input.') || keyPath.startsWith('session.')) {
76
78
  return keyPath
77
79
  .split('.')
78
- .reduce((object, key) => this.resolveObjectKey(object, key), request)
80
+ .reduce((object, key) => this.resolveObjectKey(object, key), botContext)
79
81
  }
80
82
 
81
83
  return keyPath
82
84
  .split('.')
83
85
  .reduce(
84
86
  (object, key) => this.resolveObjectKey(object, key),
85
- request.session.user.extra_data
87
+ botContext.session.user.extra_data
86
88
  )
87
89
  }
88
90