@botonic/plugin-flow-builder 0.57.0-rslib-esm.0 → 0.57.0-rslib-esm.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/README.md +1 -1
  2. package/lib/action/ai-agent-from-user-input.js.map +1 -0
  3. package/lib/action/context.js.map +1 -0
  4. package/lib/action/fallback.js.map +1 -0
  5. package/lib/action/first-interaction.js.map +1 -0
  6. package/lib/action/get-contents.js.map +1 -0
  7. package/lib/action/index.js.map +1 -0
  8. package/lib/action/payload.js.map +1 -0
  9. package/lib/api.js.map +1 -0
  10. package/lib/constants.js.map +1 -0
  11. package/lib/content-fields/content-fields-base.js.map +1 -0
  12. package/lib/content-fields/custom-conditional/custom-conditional-v2-evaluators.js.map +1 -0
  13. package/lib/content-fields/custom-conditional/custom-conditional-v2-resolver.js.map +1 -0
  14. package/lib/{esm/content-fields → content-fields}/custom-conditional/flow-custom-condition-v2.d.ts +1 -1
  15. package/lib/content-fields/custom-conditional/flow-custom-condition-v2.js.map +1 -0
  16. package/lib/{esm/content-fields → content-fields}/flow-ai-agent-base.js +6 -0
  17. package/lib/content-fields/flow-ai-agent-base.js.map +1 -0
  18. package/lib/content-fields/flow-ai-agent-router.js.map +1 -0
  19. package/lib/content-fields/flow-ai-agent.js.map +1 -0
  20. package/lib/content-fields/flow-bot-action.js.map +1 -0
  21. package/lib/content-fields/flow-button.js.map +1 -0
  22. package/lib/content-fields/flow-capture-user-input.js.map +1 -0
  23. package/lib/content-fields/flow-carousel.js.map +1 -0
  24. package/lib/content-fields/flow-channel-conditional.js.map +1 -0
  25. package/lib/content-fields/flow-country-conditional.js.map +1 -0
  26. package/lib/{esm/content-fields → content-fields}/flow-custom-conditional.d.ts +1 -1
  27. package/lib/content-fields/flow-custom-conditional.js.map +1 -0
  28. package/lib/content-fields/flow-element.js.map +1 -0
  29. package/lib/content-fields/flow-go-to-flow.js.map +1 -0
  30. package/lib/content-fields/flow-handoff.js.map +1 -0
  31. package/lib/content-fields/flow-image.js.map +1 -0
  32. package/lib/content-fields/flow-queue-status-conditional.js.map +1 -0
  33. package/lib/content-fields/flow-rating.js.map +1 -0
  34. package/lib/content-fields/flow-text.js.map +1 -0
  35. package/lib/content-fields/flow-video.js.map +1 -0
  36. package/lib/content-fields/flow-webview.js.map +1 -0
  37. package/lib/content-fields/flow-whatsapp-cta-url-button.js.map +1 -0
  38. package/lib/{esm/content-fields → content-fields}/flow-whatsapp-request-contact-info.d.ts +2 -1
  39. package/lib/{esm/content-fields → content-fields}/flow-whatsapp-request-contact-info.js +10 -0
  40. package/lib/content-fields/flow-whatsapp-request-contact-info.js.map +1 -0
  41. package/lib/content-fields/flow-whatsapp-template.js.map +1 -0
  42. package/lib/content-fields/hubtype-fields/ai-agent-router.js.map +1 -0
  43. package/lib/content-fields/hubtype-fields/ai-agent.js.map +1 -0
  44. package/lib/content-fields/hubtype-fields/bot-action.js.map +1 -0
  45. package/lib/content-fields/hubtype-fields/button.js.map +1 -0
  46. package/lib/content-fields/hubtype-fields/capture-user-input.js.map +1 -0
  47. package/lib/content-fields/hubtype-fields/carousel.js.map +1 -0
  48. package/lib/content-fields/hubtype-fields/channel-conditional.js.map +1 -0
  49. package/lib/content-fields/hubtype-fields/common.js.map +1 -0
  50. package/lib/content-fields/hubtype-fields/country-conditional.js.map +1 -0
  51. package/lib/content-fields/hubtype-fields/custom-conditional-v2.js.map +1 -0
  52. package/lib/content-fields/hubtype-fields/custom-conditional.js.map +1 -0
  53. package/lib/content-fields/hubtype-fields/fallback.js.map +1 -0
  54. package/lib/content-fields/hubtype-fields/function.js.map +1 -0
  55. package/lib/content-fields/hubtype-fields/go-to-flow.js.map +1 -0
  56. package/lib/content-fields/hubtype-fields/handoff.js.map +1 -0
  57. package/lib/content-fields/hubtype-fields/image.js.map +1 -0
  58. package/lib/content-fields/hubtype-fields/index.js.map +1 -0
  59. package/lib/content-fields/hubtype-fields/keyword.js.map +1 -0
  60. package/lib/content-fields/hubtype-fields/node-types.js.map +1 -0
  61. package/lib/content-fields/hubtype-fields/nodes.js.map +1 -0
  62. package/lib/content-fields/hubtype-fields/payload.js.map +1 -0
  63. package/lib/content-fields/hubtype-fields/queue-status-conditional.js.map +1 -0
  64. package/lib/content-fields/hubtype-fields/rating.js.map +1 -0
  65. package/lib/content-fields/hubtype-fields/smart-intent.js.map +1 -0
  66. package/lib/content-fields/hubtype-fields/text.js.map +1 -0
  67. package/lib/content-fields/hubtype-fields/url.js.map +1 -0
  68. package/lib/content-fields/hubtype-fields/video.js.map +1 -0
  69. package/lib/content-fields/hubtype-fields/webview.js.map +1 -0
  70. package/lib/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
  71. package/lib/content-fields/hubtype-fields/whatsapp-cta-url-button.js.map +1 -0
  72. package/lib/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +1 -0
  73. package/lib/content-fields/hubtype-fields/whatsapp-template.js.map +1 -0
  74. package/lib/{esm/content-fields → content-fields}/index.d.ts +1 -1
  75. package/lib/content-fields/index.js.map +1 -0
  76. package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
  77. package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
  78. package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
  79. package/lib/content-fields/whatsapp-button-list/index.js.map +1 -0
  80. package/lib/filters/index.js.map +1 -0
  81. package/lib/flow-factory.js.map +1 -0
  82. package/lib/functions/index.js.map +1 -0
  83. package/lib/index.js.map +1 -0
  84. package/lib/services/hubtype-queues-api.js.map +1 -0
  85. package/lib/structured-output/flow-builder-content.js.map +1 -0
  86. package/lib/tracking.js.map +1 -0
  87. package/lib/types.js.map +1 -0
  88. package/lib/user-input/capture-user-input-api.js.map +1 -0
  89. package/lib/user-input/index.js.map +1 -0
  90. package/lib/user-input/keyword.js.map +1 -0
  91. package/lib/user-input/smart-intent.js.map +1 -0
  92. package/lib/utils/ai-agent.js.map +1 -0
  93. package/lib/utils/authentication.js.map +1 -0
  94. package/lib/utils/flow-locale.js.map +1 -0
  95. package/lib/utils/get-flow-builder-plugin.js.map +1 -0
  96. package/lib/{esm/utils → utils}/hubtype-assistant-content.d.ts +1 -0
  97. package/lib/{esm/utils → utils}/hubtype-assistant-content.js +13 -0
  98. package/lib/utils/hubtype-assistant-content.js.map +1 -0
  99. package/lib/utils/input.js.map +1 -0
  100. package/lib/webview/contents-context.js.map +1 -0
  101. package/lib/webview/index.js.map +1 -0
  102. package/lib/webview/types.js.map +1 -0
  103. package/lib/webview/use-webview-contents.js.map +1 -0
  104. package/package.json +9 -8
  105. package/src/content-fields/flow-ai-agent-base.tsx +11 -0
  106. package/src/content-fields/flow-whatsapp-request-contact-info.tsx +17 -1
  107. package/src/content-fields/index.ts +2 -2
  108. package/src/utils/hubtype-assistant-content.ts +14 -0
  109. package/lib/esm/action/ai-agent-from-user-input.js.map +0 -1
  110. package/lib/esm/action/context.js.map +0 -1
  111. package/lib/esm/action/fallback.js.map +0 -1
  112. package/lib/esm/action/first-interaction.js.map +0 -1
  113. package/lib/esm/action/get-contents.js.map +0 -1
  114. package/lib/esm/action/index.js.map +0 -1
  115. package/lib/esm/action/payload.js.map +0 -1
  116. package/lib/esm/api.js.map +0 -1
  117. package/lib/esm/constants.js.map +0 -1
  118. package/lib/esm/content-fields/content-fields-base.js.map +0 -1
  119. package/lib/esm/content-fields/custom-conditional/custom-conditional-v2-evaluators.js.map +0 -1
  120. package/lib/esm/content-fields/custom-conditional/custom-conditional-v2-resolver.js.map +0 -1
  121. package/lib/esm/content-fields/custom-conditional/flow-custom-condition-v2.js.map +0 -1
  122. package/lib/esm/content-fields/flow-ai-agent-base.js.map +0 -1
  123. package/lib/esm/content-fields/flow-ai-agent-router.js.map +0 -1
  124. package/lib/esm/content-fields/flow-ai-agent.js.map +0 -1
  125. package/lib/esm/content-fields/flow-bot-action.js.map +0 -1
  126. package/lib/esm/content-fields/flow-button.js.map +0 -1
  127. package/lib/esm/content-fields/flow-capture-user-input.js.map +0 -1
  128. package/lib/esm/content-fields/flow-carousel.js.map +0 -1
  129. package/lib/esm/content-fields/flow-channel-conditional.js.map +0 -1
  130. package/lib/esm/content-fields/flow-country-conditional.js.map +0 -1
  131. package/lib/esm/content-fields/flow-custom-conditional.js.map +0 -1
  132. package/lib/esm/content-fields/flow-element.js.map +0 -1
  133. package/lib/esm/content-fields/flow-go-to-flow.js.map +0 -1
  134. package/lib/esm/content-fields/flow-handoff.js.map +0 -1
  135. package/lib/esm/content-fields/flow-image.js.map +0 -1
  136. package/lib/esm/content-fields/flow-queue-status-conditional.js.map +0 -1
  137. package/lib/esm/content-fields/flow-rating.js.map +0 -1
  138. package/lib/esm/content-fields/flow-text.js.map +0 -1
  139. package/lib/esm/content-fields/flow-video.js.map +0 -1
  140. package/lib/esm/content-fields/flow-webview.js.map +0 -1
  141. package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js.map +0 -1
  142. package/lib/esm/content-fields/flow-whatsapp-request-contact-info.js.map +0 -1
  143. package/lib/esm/content-fields/flow-whatsapp-template.js.map +0 -1
  144. package/lib/esm/content-fields/hubtype-fields/ai-agent-router.js.map +0 -1
  145. package/lib/esm/content-fields/hubtype-fields/ai-agent.js.map +0 -1
  146. package/lib/esm/content-fields/hubtype-fields/bot-action.js.map +0 -1
  147. package/lib/esm/content-fields/hubtype-fields/button.js.map +0 -1
  148. package/lib/esm/content-fields/hubtype-fields/capture-user-input.js.map +0 -1
  149. package/lib/esm/content-fields/hubtype-fields/carousel.js.map +0 -1
  150. package/lib/esm/content-fields/hubtype-fields/channel-conditional.js.map +0 -1
  151. package/lib/esm/content-fields/hubtype-fields/common.js.map +0 -1
  152. package/lib/esm/content-fields/hubtype-fields/country-conditional.js.map +0 -1
  153. package/lib/esm/content-fields/hubtype-fields/custom-conditional-v2.js.map +0 -1
  154. package/lib/esm/content-fields/hubtype-fields/custom-conditional.js.map +0 -1
  155. package/lib/esm/content-fields/hubtype-fields/fallback.js.map +0 -1
  156. package/lib/esm/content-fields/hubtype-fields/function.js.map +0 -1
  157. package/lib/esm/content-fields/hubtype-fields/go-to-flow.js.map +0 -1
  158. package/lib/esm/content-fields/hubtype-fields/handoff.js.map +0 -1
  159. package/lib/esm/content-fields/hubtype-fields/image.js.map +0 -1
  160. package/lib/esm/content-fields/hubtype-fields/index.js.map +0 -1
  161. package/lib/esm/content-fields/hubtype-fields/keyword.js.map +0 -1
  162. package/lib/esm/content-fields/hubtype-fields/node-types.js.map +0 -1
  163. package/lib/esm/content-fields/hubtype-fields/nodes.js.map +0 -1
  164. package/lib/esm/content-fields/hubtype-fields/payload.js.map +0 -1
  165. package/lib/esm/content-fields/hubtype-fields/queue-status-conditional.js.map +0 -1
  166. package/lib/esm/content-fields/hubtype-fields/rating.js.map +0 -1
  167. package/lib/esm/content-fields/hubtype-fields/smart-intent.js.map +0 -1
  168. package/lib/esm/content-fields/hubtype-fields/text.js.map +0 -1
  169. package/lib/esm/content-fields/hubtype-fields/url.js.map +0 -1
  170. package/lib/esm/content-fields/hubtype-fields/video.js.map +0 -1
  171. package/lib/esm/content-fields/hubtype-fields/webview.js.map +0 -1
  172. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js.map +0 -1
  173. package/lib/esm/content-fields/hubtype-fields/whatsapp-cta-url-button.js.map +0 -1
  174. package/lib/esm/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +0 -1
  175. package/lib/esm/content-fields/hubtype-fields/whatsapp-template.js.map +0 -1
  176. package/lib/esm/content-fields/index.js.map +0 -1
  177. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +0 -1
  178. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +0 -1
  179. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +0 -1
  180. package/lib/esm/content-fields/whatsapp-button-list/index.js.map +0 -1
  181. package/lib/esm/filters/index.js.map +0 -1
  182. package/lib/esm/flow-factory.js.map +0 -1
  183. package/lib/esm/functions/index.js.map +0 -1
  184. package/lib/esm/index.js.map +0 -1
  185. package/lib/esm/package.json +0 -3
  186. package/lib/esm/services/hubtype-queues-api.js.map +0 -1
  187. package/lib/esm/structured-output/flow-builder-content.js.map +0 -1
  188. package/lib/esm/tracking.js.map +0 -1
  189. package/lib/esm/types.js.map +0 -1
  190. package/lib/esm/user-input/capture-user-input-api.js.map +0 -1
  191. package/lib/esm/user-input/index.js.map +0 -1
  192. package/lib/esm/user-input/keyword.js.map +0 -1
  193. package/lib/esm/user-input/smart-intent.js.map +0 -1
  194. package/lib/esm/utils/ai-agent.js.map +0 -1
  195. package/lib/esm/utils/authentication.js.map +0 -1
  196. package/lib/esm/utils/flow-locale.js.map +0 -1
  197. package/lib/esm/utils/get-flow-builder-plugin.js.map +0 -1
  198. package/lib/esm/utils/hubtype-assistant-content.js.map +0 -1
  199. package/lib/esm/utils/input.js.map +0 -1
  200. package/lib/esm/webview/contents-context.js.map +0 -1
  201. package/lib/esm/webview/index.js.map +0 -1
  202. package/lib/esm/webview/types.js.map +0 -1
  203. package/lib/esm/webview/use-webview-contents.js.map +0 -1
  204. /package/lib/{esm/action → action}/ai-agent-from-user-input.d.ts +0 -0
  205. /package/lib/{esm/action → action}/ai-agent-from-user-input.js +0 -0
  206. /package/lib/{esm/action → action}/context.d.ts +0 -0
  207. /package/lib/{esm/action → action}/context.js +0 -0
  208. /package/lib/{esm/action → action}/fallback.d.ts +0 -0
  209. /package/lib/{esm/action → action}/fallback.js +0 -0
  210. /package/lib/{esm/action → action}/first-interaction.d.ts +0 -0
  211. /package/lib/{esm/action → action}/first-interaction.js +0 -0
  212. /package/lib/{esm/action → action}/get-contents.d.ts +0 -0
  213. /package/lib/{esm/action → action}/get-contents.js +0 -0
  214. /package/lib/{esm/action → action}/index.d.ts +0 -0
  215. /package/lib/{esm/action → action}/index.js +0 -0
  216. /package/lib/{esm/action → action}/payload.d.ts +0 -0
  217. /package/lib/{esm/action → action}/payload.js +0 -0
  218. /package/lib/{esm/api.d.ts → api.d.ts} +0 -0
  219. /package/lib/{esm/api.js → api.js} +0 -0
  220. /package/lib/{esm/constants.d.ts → constants.d.ts} +0 -0
  221. /package/lib/{esm/constants.js → constants.js} +0 -0
  222. /package/lib/{esm/content-fields → content-fields}/content-fields-base.d.ts +0 -0
  223. /package/lib/{esm/content-fields → content-fields}/content-fields-base.js +0 -0
  224. /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-evaluators.d.ts +0 -0
  225. /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-evaluators.js +0 -0
  226. /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-resolver.d.ts +0 -0
  227. /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-resolver.js +0 -0
  228. /package/lib/{esm/content-fields → content-fields}/custom-conditional/flow-custom-condition-v2.js +0 -0
  229. /package/lib/{esm/content-fields → content-fields}/flow-ai-agent-base.d.ts +0 -0
  230. /package/lib/{esm/content-fields → content-fields}/flow-ai-agent-router.d.ts +0 -0
  231. /package/lib/{esm/content-fields → content-fields}/flow-ai-agent-router.js +0 -0
  232. /package/lib/{esm/content-fields → content-fields}/flow-ai-agent.d.ts +0 -0
  233. /package/lib/{esm/content-fields → content-fields}/flow-ai-agent.js +0 -0
  234. /package/lib/{esm/content-fields → content-fields}/flow-bot-action.d.ts +0 -0
  235. /package/lib/{esm/content-fields → content-fields}/flow-bot-action.js +0 -0
  236. /package/lib/{esm/content-fields → content-fields}/flow-button.d.ts +0 -0
  237. /package/lib/{esm/content-fields → content-fields}/flow-button.js +0 -0
  238. /package/lib/{esm/content-fields → content-fields}/flow-capture-user-input.d.ts +0 -0
  239. /package/lib/{esm/content-fields → content-fields}/flow-capture-user-input.js +0 -0
  240. /package/lib/{esm/content-fields → content-fields}/flow-carousel.d.ts +0 -0
  241. /package/lib/{esm/content-fields → content-fields}/flow-carousel.js +0 -0
  242. /package/lib/{esm/content-fields → content-fields}/flow-channel-conditional.d.ts +0 -0
  243. /package/lib/{esm/content-fields → content-fields}/flow-channel-conditional.js +0 -0
  244. /package/lib/{esm/content-fields → content-fields}/flow-country-conditional.d.ts +0 -0
  245. /package/lib/{esm/content-fields → content-fields}/flow-country-conditional.js +0 -0
  246. /package/lib/{esm/content-fields → content-fields}/flow-custom-conditional.js +0 -0
  247. /package/lib/{esm/content-fields → content-fields}/flow-element.d.ts +0 -0
  248. /package/lib/{esm/content-fields → content-fields}/flow-element.js +0 -0
  249. /package/lib/{esm/content-fields → content-fields}/flow-go-to-flow.d.ts +0 -0
  250. /package/lib/{esm/content-fields → content-fields}/flow-go-to-flow.js +0 -0
  251. /package/lib/{esm/content-fields → content-fields}/flow-handoff.d.ts +0 -0
  252. /package/lib/{esm/content-fields → content-fields}/flow-handoff.js +0 -0
  253. /package/lib/{esm/content-fields → content-fields}/flow-image.d.ts +0 -0
  254. /package/lib/{esm/content-fields → content-fields}/flow-image.js +0 -0
  255. /package/lib/{esm/content-fields → content-fields}/flow-queue-status-conditional.d.ts +0 -0
  256. /package/lib/{esm/content-fields → content-fields}/flow-queue-status-conditional.js +0 -0
  257. /package/lib/{esm/content-fields → content-fields}/flow-rating.d.ts +0 -0
  258. /package/lib/{esm/content-fields → content-fields}/flow-rating.js +0 -0
  259. /package/lib/{esm/content-fields → content-fields}/flow-text.d.ts +0 -0
  260. /package/lib/{esm/content-fields → content-fields}/flow-text.js +0 -0
  261. /package/lib/{esm/content-fields → content-fields}/flow-video.d.ts +0 -0
  262. /package/lib/{esm/content-fields → content-fields}/flow-video.js +0 -0
  263. /package/lib/{esm/content-fields → content-fields}/flow-webview.d.ts +0 -0
  264. /package/lib/{esm/content-fields → content-fields}/flow-webview.js +0 -0
  265. /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-cta-url-button.d.ts +0 -0
  266. /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-cta-url-button.js +0 -0
  267. /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-template.d.ts +0 -0
  268. /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-template.js +0 -0
  269. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent-router.d.ts +0 -0
  270. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent-router.js +0 -0
  271. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent.d.ts +0 -0
  272. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent.js +0 -0
  273. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/bot-action.d.ts +0 -0
  274. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/bot-action.js +0 -0
  275. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/button.d.ts +0 -0
  276. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/button.js +0 -0
  277. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/capture-user-input.d.ts +0 -0
  278. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/capture-user-input.js +0 -0
  279. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/carousel.d.ts +0 -0
  280. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/carousel.js +0 -0
  281. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/channel-conditional.d.ts +0 -0
  282. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/channel-conditional.js +0 -0
  283. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/common.d.ts +0 -0
  284. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/common.js +0 -0
  285. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/country-conditional.d.ts +0 -0
  286. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/country-conditional.js +0 -0
  287. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional-v2.d.ts +0 -0
  288. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional-v2.js +0 -0
  289. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional.d.ts +0 -0
  290. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional.js +0 -0
  291. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/fallback.d.ts +0 -0
  292. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/fallback.js +0 -0
  293. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/function.d.ts +0 -0
  294. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/function.js +0 -0
  295. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/go-to-flow.d.ts +0 -0
  296. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/go-to-flow.js +0 -0
  297. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/handoff.d.ts +0 -0
  298. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/handoff.js +0 -0
  299. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/image.d.ts +0 -0
  300. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/image.js +0 -0
  301. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/index.d.ts +0 -0
  302. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/index.js +0 -0
  303. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/keyword.d.ts +0 -0
  304. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/keyword.js +0 -0
  305. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/node-types.d.ts +0 -0
  306. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/node-types.js +0 -0
  307. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/nodes.d.ts +0 -0
  308. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/nodes.js +0 -0
  309. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/payload.d.ts +0 -0
  310. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/payload.js +0 -0
  311. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/queue-status-conditional.d.ts +0 -0
  312. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/queue-status-conditional.js +0 -0
  313. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/rating.d.ts +0 -0
  314. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/rating.js +0 -0
  315. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/smart-intent.d.ts +0 -0
  316. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/smart-intent.js +0 -0
  317. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/text.d.ts +0 -0
  318. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/text.js +0 -0
  319. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/url.d.ts +0 -0
  320. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/url.js +0 -0
  321. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/video.d.ts +0 -0
  322. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/video.js +0 -0
  323. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/webview.d.ts +0 -0
  324. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/webview.js +0 -0
  325. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-button-list.d.ts +0 -0
  326. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-button-list.js +0 -0
  327. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-cta-url-button.d.ts +0 -0
  328. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-cta-url-button.js +0 -0
  329. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-request-contact-info.d.ts +0 -0
  330. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-request-contact-info.js +0 -0
  331. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-template.d.ts +0 -0
  332. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-template.js +0 -0
  333. /package/lib/{esm/content-fields → content-fields}/index.js +0 -0
  334. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +0 -0
  335. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-row.js +0 -0
  336. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +0 -0
  337. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-section.js +0 -0
  338. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list.d.ts +0 -0
  339. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list.js +0 -0
  340. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/index.d.ts +0 -0
  341. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/index.js +0 -0
  342. /package/lib/{esm/filters → filters}/index.d.ts +0 -0
  343. /package/lib/{esm/filters → filters}/index.js +0 -0
  344. /package/lib/{esm/flow-factory.d.ts → flow-factory.d.ts} +0 -0
  345. /package/lib/{esm/flow-factory.js → flow-factory.js} +0 -0
  346. /package/lib/{esm/functions → functions}/index.d.ts +0 -0
  347. /package/lib/{esm/functions → functions}/index.js +0 -0
  348. /package/lib/{esm/index.d.ts → index.d.ts} +0 -0
  349. /package/lib/{esm/index.js → index.js} +0 -0
  350. /package/lib/{esm/services → services}/hubtype-queues-api.d.ts +0 -0
  351. /package/lib/{esm/services → services}/hubtype-queues-api.js +0 -0
  352. /package/lib/{esm/structured-output → structured-output}/flow-builder-content.d.ts +0 -0
  353. /package/lib/{esm/structured-output → structured-output}/flow-builder-content.js +0 -0
  354. /package/lib/{esm/tracking.d.ts → tracking.d.ts} +0 -0
  355. /package/lib/{esm/tracking.js → tracking.js} +0 -0
  356. /package/lib/{esm/types.d.ts → types.d.ts} +0 -0
  357. /package/lib/{esm/types.js → types.js} +0 -0
  358. /package/lib/{esm/user-input → user-input}/capture-user-input-api.d.ts +0 -0
  359. /package/lib/{esm/user-input → user-input}/capture-user-input-api.js +0 -0
  360. /package/lib/{esm/user-input → user-input}/index.d.ts +0 -0
  361. /package/lib/{esm/user-input → user-input}/index.js +0 -0
  362. /package/lib/{esm/user-input → user-input}/keyword.d.ts +0 -0
  363. /package/lib/{esm/user-input → user-input}/keyword.js +0 -0
  364. /package/lib/{esm/user-input → user-input}/smart-intent.d.ts +0 -0
  365. /package/lib/{esm/user-input → user-input}/smart-intent.js +0 -0
  366. /package/lib/{esm/utils → utils}/ai-agent.d.ts +0 -0
  367. /package/lib/{esm/utils → utils}/ai-agent.js +0 -0
  368. /package/lib/{esm/utils → utils}/authentication.d.ts +0 -0
  369. /package/lib/{esm/utils → utils}/authentication.js +0 -0
  370. /package/lib/{esm/utils → utils}/flow-locale.d.ts +0 -0
  371. /package/lib/{esm/utils → utils}/flow-locale.js +0 -0
  372. /package/lib/{esm/utils → utils}/get-flow-builder-plugin.d.ts +0 -0
  373. /package/lib/{esm/utils → utils}/get-flow-builder-plugin.js +0 -0
  374. /package/lib/{esm/utils → utils}/input.d.ts +0 -0
  375. /package/lib/{esm/utils → utils}/input.js +0 -0
  376. /package/lib/{esm/webview → webview}/contents-context.d.ts +0 -0
  377. /package/lib/{esm/webview → webview}/contents-context.js +0 -0
  378. /package/lib/{esm/webview → webview}/index.d.ts +0 -0
  379. /package/lib/{esm/webview → webview}/index.js +0 -0
  380. /package/lib/{esm/webview → webview}/types.d.ts +0 -0
  381. /package/lib/{esm/webview → webview}/types.js +0 -0
  382. /package/lib/{esm/webview → webview}/use-webview-contents.d.ts +0 -0
  383. /package/lib/{esm/webview → webview}/use-webview-contents.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/flow-locale.js","sources":["../../src/utils/flow-locale.ts"],"sourcesContent":["import type { BotContext } from '@botonic/core'\n\nexport class FlowLocale {\n constructor(\n private readonly botContext: BotContext,\n private readonly flowLocales: string[],\n private readonly defaultLocaleCode: string\n ) {}\n\n resolve(): string {\n const priorityLocale = this.isLanguageDetectionEnabled()\n ? this.getPriorityLocale()\n : this.botContext.getSystemLocale()\n\n if (priorityLocale) {\n const exactMatch = this.matchExactLocale(priorityLocale)\n if (exactMatch) {\n return this.applyLocale(exactMatch)\n }\n\n const languageMatch = this.matchLanguage(priorityLocale)\n if (languageMatch) {\n return this.applyLocale(languageMatch)\n }\n }\n\n return this.applyLocale(this.getDefaultLocale())\n }\n\n private isLanguageDetectionEnabled(): boolean {\n return !!this.botContext.settings?.LANGUAGE_DETECTION_ENABLED\n }\n\n /**\n * Rules:\n * - If user and system languages differ, user locale takes priority.\n * - If both share the same language, the more specific locale wins.\n * - If both have the same specificity, user locale wins.\n */\n private getPriorityLocale(): string | undefined {\n const userLocale = this.botContext.getUserLocale()\n const systemLocale = this.botContext.getSystemLocale()\n\n if (!userLocale || !systemLocale) {\n return undefined\n }\n\n const userLanguage = this.getLanguage(userLocale)\n const systemLanguage = this.getLanguage(systemLocale)\n\n if (userLanguage !== systemLanguage) {\n return userLocale\n }\n const userIsSpecific = this.isSpecificLocale(userLocale)\n const systemIsSpecific = this.isSpecificLocale(systemLocale)\n\n if (userIsSpecific && !systemIsSpecific) {\n return userLocale\n }\n if (!userIsSpecific && systemIsSpecific) {\n return systemLocale\n }\n\n return userLocale\n }\n\n private matchExactLocale(locale: string): string | undefined {\n return this.flowLocales.includes(locale) ? locale : undefined\n }\n\n private matchLanguage(locale: string): string | undefined {\n const language = this.getLanguage(locale)\n return this.flowLocales.includes(language) ? language : undefined\n }\n\n private getDefaultLocale(): string {\n return this.defaultLocaleCode || 'en'\n }\n\n private applyLocale(locale: string): string {\n this.botContext.setSystemLocale(locale)\n this.botContext.session.user.system_locale_updated = true\n return locale\n }\n\n private getLanguage(locale: string): string {\n return locale.split('-')[0]\n }\n\n private isSpecificLocale(locale: string): boolean {\n return locale.includes('-')\n }\n}\n"],"names":["FlowLocale","priorityLocale","exactMatch","languageMatch","userLocale","systemLocale","undefined","userLanguage","systemLanguage","userIsSpecific","systemIsSpecific","locale","language","botContext","flowLocales","defaultLocaleCode"],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IAAI,CAAC,WAAW,CAACD;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAACC,YAAYA,WAAWN;IAC1D;IAEQ,mBAA2B;QACjC,OAAO,IAAI,CAAC,iBAAiB,IAAI;IACnC;IAEQ,YAAYK,MAAc,EAAU;QAC1C,IAAI,CAAC,UAAU,CAAC,eAAe,CAACA;QAChC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,qBAAqB,GAAG;QACrD,OAAOA;IACT;IAEQ,YAAYA,MAAc,EAAU;QAC1C,OAAOA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE;IAC7B;IAEQ,iBAAiBA,MAAc,EAAW;QAChD,OAAOA,OAAO,QAAQ,CAAC;IACzB;IAxFA,YACmBE,UAAsB,EACtBC,WAAqB,EACrBC,iBAAyB,CAC1C;aAHiBF,aAAAA;aACAC,cAAAA;aACAC,oBAAAA;IAChB;AAqFL"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/get-flow-builder-plugin.js","sources":["../../src/utils/get-flow-builder-plugin.ts"],"sourcesContent":["import type { ResolvedPlugins } from '@botonic/core'\n\nimport type BotonicPluginFlowBuilder from '../index'\n\nconst FLOW_BUILDER_PLUGIN_NAME = 'BotonicPluginFlowBuilder'\n\nexport function getFlowBuilderPlugin(\n plugins: ResolvedPlugins\n): BotonicPluginFlowBuilder {\n const ERROR_MESSAGE = `You must include '@botonic/plugin-flow-builder' in your plugins file.`\n\n if (Object.values(plugins).length === 0) {\n throw new Error(ERROR_MESSAGE)\n }\n\n const flowBuilderPlugin = Object.values(plugins).find(\n plugin => plugin.constructor.name === FLOW_BUILDER_PLUGIN_NAME\n ) as unknown as BotonicPluginFlowBuilder\n\n if (!flowBuilderPlugin) {\n throw new Error(ERROR_MESSAGE)\n }\n\n return flowBuilderPlugin\n}\n"],"names":["FLOW_BUILDER_PLUGIN_NAME","getFlowBuilderPlugin","plugins","ERROR_MESSAGE","Object","Error","flowBuilderPlugin","plugin"],"mappings":"AAIA,MAAMA,wBAAwBA,GAAG;AAE1B,SAASC,oBAAoBA,CAClCC,OAAwB;IAExB,MAAMC,gBAAgB,CAAC,qEAAqE,CAAC;IAE7F,IAAIC,OAAO,MAAM,CAACF,SAAS,MAAM,KAAK,GAAG;QACvC,MAAM,IAAIG,MAAMF;IAClB;IAEA,MAAMG,oBAAoBF,OAAO,MAAM,CAACF,SAAS,IAAI,CACnDK,CAAAA,SAAUA,OAAO,WAAW,CAAC,IAAI,KAAKP,wBAAwBA;IAGhE,IAAI,CAACM,mBAAmB;QACtB,MAAM,IAAID,MAAMF;IAClB;IAEA,OAAOG;AACT"}
@@ -9,4 +9,5 @@ export declare class HubtypeAssistantContent {
9
9
  private static formatWhatsappButtonListContent;
10
10
  private static formatWhatsappCtaContent;
11
11
  private static formatWhatsappTemplateContent;
12
+ private static formatRequestContactInfoContent;
12
13
  }
@@ -4,6 +4,7 @@ import { FlowImage } from "../content-fields/flow-image.js";
4
4
  import { FlowText } from "../content-fields/flow-text.js";
5
5
  import { FlowVideo } from "../content-fields/flow-video.js";
6
6
  import { FlowWhatsappCtaUrlButtonNode } from "../content-fields/flow-whatsapp-cta-url-button.js";
7
+ import { FlowWhatsappRequestContactInfoNode } from "../content-fields/flow-whatsapp-request-contact-info.js";
7
8
  import { FlowWhatsappTemplate } from "../content-fields/flow-whatsapp-template.js";
8
9
  import { HtButtonStyle } from "../content-fields/hubtype-fields/index.js";
9
10
  import { FlowWhatsappButtonList } from "../content-fields/whatsapp-button-list/flow-whatsapp-button-list.js";
@@ -25,6 +26,8 @@ import { FlowWhatsappButtonList } from "../content-fields/whatsapp-button-list/f
25
26
 
26
27
 
27
28
 
29
+
30
+
28
31
 
29
32
  // biome-ignore lint/complexity/noStaticOnlyClass: namespace-like adapter with private static helpers
30
33
  class HubtypeAssistantContent {
@@ -50,6 +53,9 @@ class HubtypeAssistantContent {
50
53
  if (content instanceof FlowWhatsappTemplate) {
51
54
  return HubtypeAssistantContent.formatWhatsappTemplateContent(content);
52
55
  }
56
+ if (content instanceof FlowWhatsappRequestContactInfoNode) {
57
+ return HubtypeAssistantContent.formatRequestContactInfoContent(content);
58
+ }
53
59
  return '';
54
60
  }
55
61
  static quickReplyLabel(button) {
@@ -180,6 +186,13 @@ class HubtypeAssistantContent {
180
186
  const { name, language } = template.htWhatsappTemplate;
181
187
  return `WhatsApp Template: ${name} (${language})`;
182
188
  }
189
+ static formatRequestContactInfoContent(requestContactInfo) {
190
+ const body = requestContactInfo.text?.trim() ?? '';
191
+ if (!body) {
192
+ return '[WhatsApp Request Contact Info]';
193
+ }
194
+ return requestContactInfo.text;
195
+ }
183
196
  }
184
197
 
185
198
  export { HubtypeAssistantContent };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/hubtype-assistant-content.js","sources":["../../src/utils/hubtype-assistant-content.ts"],"sourcesContent":["import { WhatsappCTAUrlHeaderType } from '@botonic/react'\nimport type { FlowContent } from '../content-fields'\nimport type { FlowButton } from '../content-fields/flow-button'\nimport { FlowCarousel } from '../content-fields/flow-carousel'\nimport { FlowImage } from '../content-fields/flow-image'\nimport { FlowText } from '../content-fields/flow-text'\nimport { FlowVideo } from '../content-fields/flow-video'\nimport { FlowWhatsappCtaUrlButtonNode } from '../content-fields/flow-whatsapp-cta-url-button'\nimport { FlowWhatsappRequestContactInfoNode } from '../content-fields/flow-whatsapp-request-contact-info'\nimport { FlowWhatsappTemplate } from '../content-fields/flow-whatsapp-template'\nimport { HtButtonStyle } from '../content-fields/hubtype-fields'\nimport { FlowWhatsappButtonList } from '../content-fields/whatsapp-button-list/flow-whatsapp-button-list'\n\n// biome-ignore lint/complexity/noStaticOnlyClass: namespace-like adapter with private static helpers\nexport class HubtypeAssistantContent {\n static adapt(content: FlowContent): string {\n if (content instanceof FlowText) {\n return HubtypeAssistantContent.formatFlowTextContent(content)\n }\n if (content instanceof FlowCarousel) {\n return HubtypeAssistantContent.formatCarouselContent(content)\n }\n if (content instanceof FlowImage) {\n return content.src ? `[Image]\\n${content.src}` : '[Image]'\n }\n if (content instanceof FlowVideo) {\n return content.src ? `[Video]\\n${content.src}` : '[Video]'\n }\n if (content instanceof FlowWhatsappButtonList) {\n return HubtypeAssistantContent.formatWhatsappButtonListContent(content)\n }\n if (content instanceof FlowWhatsappCtaUrlButtonNode) {\n return HubtypeAssistantContent.formatWhatsappCtaContent(content)\n }\n if (content instanceof FlowWhatsappTemplate) {\n return HubtypeAssistantContent.formatWhatsappTemplateContent(content)\n }\n if (content instanceof FlowWhatsappRequestContactInfoNode) {\n return HubtypeAssistantContent.formatRequestContactInfoContent(content)\n }\n return ''\n }\n\n private static quickReplyLabel(button: FlowButton): string {\n const buttonText = button.text?.trim()\n if (buttonText) {\n return buttonText\n }\n\n return button.payload || 'Option'\n }\n\n private static persistentButtonLabel(button: FlowButton): string {\n return button.text?.trim() || 'Button'\n }\n\n private static carouselButtonLabel(button: FlowButton): string {\n return button.text?.trim() || 'Action'\n }\n\n private static formatFlowTextContent(text: FlowText): string {\n const body = text.text?.trim() ?? ''\n const buttons = text.buttons\n\n if (!body && buttons.length === 0) {\n return ''\n }\n\n if (buttons.length === 0) {\n return text.text\n }\n\n const isQuickReply = text.buttonStyle === HtButtonStyle.QUICK_REPLY\n const blockTitle = isQuickReply ? 'Quick replies:' : 'Buttons:'\n const lines = buttons.map((button, i) => {\n const label = isQuickReply\n ? HubtypeAssistantContent.quickReplyLabel(button)\n : HubtypeAssistantContent.persistentButtonLabel(button)\n return ` [${i + 1}] ${label}`\n })\n\n const block = [blockTitle, ...lines].join('\\n')\n if (!body) {\n return block\n }\n\n return `${body}\\n\\n${block}`\n }\n\n private static formatCarouselContent(carousel: FlowCarousel): string {\n const elements = carousel.elements\n const n = elements.length\n const mainText = (carousel.whatsappText ?? '').trim()\n\n if (n === 0) {\n return mainText\n }\n\n let header: string\n if (!mainText) {\n header = `Carousel displayed with ${n} items:`\n } else if (mainText.endsWith(':')) {\n header = mainText\n } else {\n header = `${mainText}\\nCarousel with ${n} items:`\n }\n\n const itemLines = elements.map((element, index) => {\n const title = element.title?.trim() || 'Item'\n const subtitle = element.subtitle?.trim()\n const subtitlePart = subtitle ? ` - ${subtitle}` : ''\n const btnLabels: string[] = []\n if (element.button) {\n btnLabels.push(\n HubtypeAssistantContent.carouselButtonLabel(element.button)\n )\n }\n const btnPart = btnLabels.length > 0 ? ` [${btnLabels.join(', ')}]` : ''\n\n return ` ${index + 1}. \"${title}\"${subtitlePart}${btnPart}`\n })\n\n return [header, ...itemLines].join('\\n')\n }\n\n private static formatWhatsappButtonListContent(\n list: FlowWhatsappButtonList\n ): string {\n const body = list.text?.trim() ?? ''\n const hasSections = list.sections.some(s => s.rows.length > 0)\n\n if (!body && !hasSections) {\n return '[WhatsApp Button List]'\n }\n\n const parts: string[] = []\n if (body) {\n parts.push(body)\n }\n\n if (hasSections) {\n const sectionBlocks = list.sections.map(section => {\n const rowLines = section.rows.map(row => {\n const rowTitle = row.title?.trim() ?? ''\n const rowDescription = row.description?.trim() ?? ''\n if (!rowTitle && !rowDescription) {\n return ' - '\n }\n if (!rowTitle) {\n return ` - ${rowDescription}`\n }\n if (!rowDescription) {\n return ` - ${rowTitle}`\n }\n return ` - ${rowTitle}: ${rowDescription}`\n })\n const rowsText = rowLines.join('\\n')\n\n const sectionTitle = section.title?.trim()\n if (sectionTitle) {\n return `${sectionTitle}:\\n${rowsText}`\n }\n\n return rowsText\n })\n parts.push(sectionBlocks.join('\\n'))\n }\n\n return parts.join('\\n\\n')\n }\n\n private static formatWhatsappCtaContent(\n cta: FlowWhatsappCtaUrlButtonNode\n ): string {\n const hasStructuredData =\n (cta.headerType === WhatsappCTAUrlHeaderType.Text &&\n !!cta.header?.trim()) ||\n cta.text?.trim() ||\n cta.footer?.trim() ||\n cta.displayText?.trim() ||\n cta.url\n\n if (!hasStructuredData) {\n return cta.text?.trim() || '[WhatsApp CTA Button]'\n }\n\n const lines: string[] = []\n if (\n cta.headerType === WhatsappCTAUrlHeaderType.Text &&\n cta.header?.trim()\n ) {\n lines.push(cta.header.trim())\n }\n if (cta.text?.trim()) {\n lines.push(cta.text.trim())\n }\n if (cta.footer?.trim()) {\n lines.push(cta.footer.trim())\n }\n const ctaLine = `[${cta.displayText || ''}]${cta.url ? ` (${cta.url})` : ''}`\n lines.push(ctaLine)\n\n return lines.join('\\n')\n }\n\n private static formatWhatsappTemplateContent(\n template: FlowWhatsappTemplate\n ): string {\n const { name, language } = template.htWhatsappTemplate\n return `WhatsApp Template: ${name} (${language})`\n }\n\n private static formatRequestContactInfoContent(\n requestContactInfo: FlowWhatsappRequestContactInfoNode\n ): string {\n const body = requestContactInfo.text?.trim() ?? ''\n if (!body) {\n return '[WhatsApp Request Contact Info]'\n }\n return requestContactInfo.text\n }\n}\n"],"names":["WhatsappCTAUrlHeaderType","FlowCarousel","FlowImage","FlowText","FlowVideo","FlowWhatsappCtaUrlButtonNode","FlowWhatsappRequestContactInfoNode","FlowWhatsappTemplate","HtButtonStyle","FlowWhatsappButtonList","HubtypeAssistantContent","content","button","buttonText","text","body","buttons","isQuickReply","blockTitle","lines","i","label","block","carousel","elements","n","mainText","header","itemLines","element","index","title","subtitle","subtitlePart","btnLabels","btnPart","list","hasSections","s","parts","sectionBlocks","section","rowLines","row","rowTitle","rowDescription","rowsText","sectionTitle","cta","hasStructuredData","ctaLine","template","name","language","requestContactInfo"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAyD;AAGK;AACN;AACF;AACE;AACqC;AACY;AAC1B;AACf;AACyC;AAEzG,qGAAqG;AAC9F,MAAMU,uBAAuBA;IAClC,OAAO,MAAMC,OAAoB,EAAU;QACzC,IAAIA,mBAAmBR,QAAQA,EAAE;YAC/B,OAAOO,uBAAuBA,CAAC,qBAAqB,CAACC;QACvD;QACA,IAAIA,mBAAmBV,YAAYA,EAAE;YACnC,OAAOS,uBAAuBA,CAAC,qBAAqB,CAACC;QACvD;QACA,IAAIA,mBAAmBT,SAASA,EAAE;YAChC,OAAOS,QAAQ,GAAG,GAAG,CAA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AU,KAAKhD,6BAA6B,IAC/C,CAAC,CAACgD,IAAI,MAAM,EAAE,UAChBA,IAAI,IAAI,EAAE,UACVA,IAAI,MAAM,EAAE,UACZA,IAAI,WAAW,EAAE,UACjBA,IAAI,GAAG;QAET,IAAI,CAACC,mBAAmB;YACtB,OAAOD,IAAI,IAAI,EAAE,UAAU;QAC7B;QAEA,MAAM7B,QAAkB,EAAE;QAC1B,IACE6B,IAAI,UAAU,KAAKhD,6BAA6B,IAChDgD,IAAI,MAAM,EAAE,QACZ;YACA7B,MAAM,IAAI,CAAC6B,IAAI,MAAM,CAAC,IAAI;QAC5B;QACA,IAAIA,IAAI,IAAI,EAAE,QAAQ;YACpB7B,MAAM,IAAI,CAAC6B,IAAI,IAAI,CAAC,IAAI;QAC1B;QACA,IAAIA,IAAI,MAAM,EAAE,QAAQ;YACtB7B,MAAM,IAAI,CAAC6B,IAAI,MAAM,CAAC,IAAI;QAC5B;QACA,MAAME,UAAU,CAAC,CAAC,EAAEF,IAAI,WAAW,IAAI,GAAG,CAAC,EAAEA,IAAI,GAAG,GAAG,CAAC,EAAE,EAAEA,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI;QAC7E7B,MAAM,IAAI,CAAC+B;QAEX,OAAO/B,MAAM,IAAI,CAAC;IACpB;IAEA,OAAe,8BACbgC,QAA8B,EACtB;QACR,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGF,SAAS,kBAAkB;QACtD,OAAO,CAAC,mBAAmB,EAAEC,KAAK,EAAE,EAAEC,SAAS,CAAC,CAAC;IACnD;IAEA,OAAe,gCACbC,kBAAsD,EAC9C;QACR,MAAMvC,OAAOuC,mBAAmB,IAAI,EAAE,UAAU;QAChD,IAAI,CAACvC,MAAM;YACT,OAAO;QACT;QACA,OAAOuC,mBAAmB,IAAI;IAChC;AACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/input.js","sources":["../../src/utils/input.ts"],"sourcesContent":["import { INPUT, type Input } from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\n\nimport type { InShadowingConfig } from '../types'\nimport { getFlowBuilderPlugin } from './get-flow-builder-plugin'\n\nexport function inputHasTextOrTranscript(input: Input): boolean {\n const isTextInput = Boolean(input.data) && input.type === INPUT.TEXT\n const isTranscriptText =\n Boolean(input.transcript) && input.type === INPUT.AUDIO\n\n return isTextInput || isTranscriptText\n}\n\nexport function getTextOrTranscript(input: Input): string | undefined {\n if (input.type === INPUT.TEXT && input.data) {\n return input.data\n }\n if (input.type === INPUT.AUDIO && input.transcript) {\n return input.transcript\n }\n\n console.error('No text or transcript found in input', input)\n return undefined\n}\n\nfunction isNluAllowed(\n request: ActionRequest,\n nluFlag: keyof InShadowingConfig\n): boolean {\n const shadowing = Boolean(request.session._shadowing)\n const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)\n return !shadowing || (shadowing && flowBuilderPlugin.inShadowing[nluFlag])\n}\n\nexport function isKeywordsAllowed(request: ActionRequest): boolean {\n return isNluAllowed(request, 'allowKeywords')\n}\n\nexport function isSmartIntentsAllowed(request: ActionRequest): boolean {\n return isNluAllowed(request, 'allowSmartIntents')\n}\n"],"names":["INPUT","getFlowBuilderPlugin","inputHasTextOrTranscript","input","isTextInput","Boolean","isTranscriptText","getTextOrTranscript","console","undefined","isNluAllowed","request","nluFlag","shadowing","flowBuilderPlugin","isKeywordsAllowed","isSmartIntentsAllowed"],"mappings":";;;;;AAAiD;AAIe;AAEzD,SAASE,wBAAwBA,CAACC,KAAY;IACnD,MAAMC,cAAcC,QAAQF,MAAM,IAAI,KAAKA,MAAM,IAAI,KAAKH,UAAU;IACpE,MAAMM,mBACJD,QAAQF,MAAM,UAAU,KAAKA,MAAM,IAAI,KAAKH,WAAW;IAEzD,OAAOI,eAAeE;AACxB;AAEO,SAASC,mBAAmBA,CAACJ,KAAY;IAC9C,IAAIA,MAAM,IAAI,KAAKH,UAAU,IAAIG,MAAM,IAAI,EAAE;QAC3C,OAAOA,MAAM,IAAI;IACnB;IACA,IAAIA,MAAM,IAAI,KAAKH,WAAW,IAAIG,MAAM,UAAU,EAAE;QAClD,OAAOA,MAAM,UAAU;IACzB;IAEAK,QAAQ,KAAK,CAAC,wCAAwCL;IACtD,OAAOM;AACT;AAEA,SAASC,YAAYA,CACnBC,OAAsB,EACtBC,OAAgC;IAEhC,MAAMC,YAAYR,QAAQM,QAAQ,OAAO,CAAC,UAAU;IACpD,MAAMG,oBAAoBb,oBAAoBA,CAACU,QAAQ,OAAO;IAC9D,OAAO,CAACE,aAAcA,aAAaC,kBAAkB,WAAW,CAACF,QAAQ;AAC3E;AAEO,SAASG,iBAAiBA,CAACJ,OAAsB;IACtD,OAAOD,YAAYA,CAACC,SAAS;AAC/B;AAEO,SAASK,qBAAqBA,CAACL,OAAsB;IAC1D,OAAOD,YAAYA,CAACC,SAAS;AAC/B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview/contents-context.js","sources":["../../src/webview/contents-context.ts"],"sourcesContent":["import { createContext } from 'react'\n\nimport type { MapContentsType, WebviewContentsContextType } from './types'\n\nexport const createWebviewContentsContext = <T extends MapContentsType>() =>\n createContext<WebviewContentsContextType<T>>({\n getTextContent: () => '',\n getImageSrc: () => '',\n setCurrentLocale: () => undefined,\n contents: {} as Record<keyof T, string>,\n })\n"],"names":["createContext","createWebviewContentsContext","undefined"],"mappings":";;;AAAqC;AAI9B,MAAMC,4BAA4BA,GAAG,IAC1CD,aAAaA,CAAgC;QAC3C,gBAAgB,IAAM;QACtB,aAAa,IAAM;QACnB,kBAAkB,IAAME;QACxB,UAAU,CAAC;IACb,GAAE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview/index.js","sources":["../../src/webview/index.ts"],"sourcesContent":["export { createWebviewContentsContext } from './contents-context'\nexport * from './types'\nexport { useWebviewContents } from './use-webview-contents'\n"],"names":["createWebviewContentsContext","useWebviewContents"],"mappings":";;;AAAiE;AAC1C;AACoC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview/types.js","sources":["../../src/webview/types.ts"],"sourcesContent":["import type { FlowBuilderJSONVersion } from '../types'\n\nexport enum WebviewContentType {\n TEXT = 'webview-text',\n IMAGE = 'webview-image',\n}\n\nexport type WebviewContentsResponse = (\n | WebviewTextContent\n | WebviewImageContent\n)[]\n\nexport interface WebviewTextContent {\n code: string\n type: WebviewContentType.TEXT\n content: {\n text: { message: string; locale: string }[]\n }\n}\n\nexport interface WebviewImageContent {\n code: string\n type: WebviewContentType.IMAGE\n content: {\n image: { file: string; locale: string }[]\n }\n}\n\nexport type MapContentsType = Record<string, string>\n\nexport interface UseWebviewContentsProps<T extends MapContentsType> {\n apiUrl?: string\n version?: FlowBuilderJSONVersion\n botId: string\n webviewId: string\n providerId: string\n locale: string\n mapContents: Record<keyof T, string>\n}\n\nexport interface UseWebviewContents<T extends MapContentsType> {\n isLoading: boolean\n error: boolean\n webviewContentsContext: WebviewContentsContextType<T>\n}\n\nexport interface WebviewContentsContextType<T extends MapContentsType> {\n getTextContent: (code: string) => string\n getImageSrc: (code: string) => string\n setCurrentLocale: (locale: string) => void\n contents: Record<keyof T, string>\n}\n"],"names":["WebviewContentType"],"mappings":"AAEO,IAAKA,wBAAkBA,0BAAlBA;;;WAAAA;MAGX"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview/use-webview-contents.js","sources":["../../src/webview/use-webview-contents.ts"],"sourcesContent":["import axios from 'axios'\nimport { useEffect, useState } from 'react'\n\nimport { FLOW_BUILDER_API_URL_PROD } from '../constants'\nimport { FlowBuilderJSONVersion } from '../types'\nimport {\n type MapContentsType,\n type UseWebviewContents,\n type UseWebviewContentsProps,\n type WebviewContentsResponse,\n WebviewContentType,\n type WebviewImageContent,\n type WebviewTextContent,\n} from './types'\n\nexport function useWebviewContents<T extends MapContentsType>({\n apiUrl = FLOW_BUILDER_API_URL_PROD,\n version = FlowBuilderJSONVersion.LATEST,\n botId,\n webviewId,\n providerId,\n locale,\n mapContents,\n}: UseWebviewContentsProps<T>): UseWebviewContents<T> {\n const [textContents, setTextContents] = useState<WebviewTextContent[]>()\n const [imageContents, setImageContents] = useState<WebviewImageContent[]>()\n const [contents, setContents] = useState<Record<keyof T, string>>(\n {} as Record<keyof T, string>\n )\n const [currentLocale, setCurrentLocale] = useState(locale)\n const [error, setError] = useState(false)\n\n const updateCurrentLocale = (textContents?: WebviewTextContent[]) => {\n if (!textContents || textContents.length === 0) {\n console.log('There is no text contents to check the locale')\n return\n }\n\n const locales = textContents[0].content.text.map(text => text.locale)\n const language = currentLocale.split('-')[0]\n\n if (locales.includes(currentLocale)) {\n setCurrentLocale(currentLocale)\n return\n }\n\n if (locales.includes(language)) {\n setCurrentLocale(language)\n return\n }\n\n console.error(\n `locale: ${currentLocale} cannot be resolved with: ${locales.join(', ')}`\n )\n }\n\n const getTextContent = (contentID: string): string => {\n return (\n textContents\n ?.find(textContent => textContent.code === contentID)\n ?.content.text.find(text => text.locale === currentLocale)?.message ||\n ''\n )\n }\n\n const getImageSrc = (contentID: string): string => {\n return (\n imageContents\n ?.find(imageContent => imageContent.code === contentID)\n ?.content.image.find(image => image.locale === currentLocale)?.file ||\n ''\n )\n }\n\n useEffect(() => {\n if (textContents || imageContents) {\n const contentsObject = {}\n for (const [key, value] of Object.entries<string>(mapContents)) {\n contentsObject[key] = getTextContent(value) || getImageSrc(value)\n }\n setContents(contentsObject as Record<keyof T, string>)\n }\n }, [textContents, imageContents, currentLocale])\n\n useEffect(() => {\n const getResponseContents = async () => {\n const url = `${apiUrl}/v1/bot_flows/${botId}/versions/${version}/webviews/${webviewId}/?provider_id=${providerId}`\n try {\n const response = await axios.get<WebviewContentsResponse>(url)\n\n const textResponseContents = response.data.filter(\n webviewContent => webviewContent.type === WebviewContentType.TEXT\n ) as WebviewTextContent[]\n setTextContents(textResponseContents)\n\n const imageResponseContents = response.data.filter(\n webviewContent => webviewContent.type === WebviewContentType.IMAGE\n ) as WebviewImageContent[]\n setImageContents(imageResponseContents)\n\n updateCurrentLocale(textResponseContents)\n } catch (error) {\n console.error('Error fetching webview contents:', error)\n setError(true)\n }\n }\n getResponseContents()\n }, [])\n\n return {\n isLoading: Object.keys(contents).length === 0,\n error,\n webviewContentsContext: {\n getTextContent,\n getImageSrc,\n setCurrentLocale,\n contents,\n },\n }\n}\n"],"names":["axios","useEffect","useState","FLOW_BUILDER_API_URL_PROD","FlowBuilderJSONVersion","WebviewContentType","useWebviewContents","apiUrl","version","botId","webviewId","providerId","locale","mapContents","textContents","setTextContents","imageContents","setImageContents","contents","setContents","currentLocale","setCurrentLocale","error","setError","updateCurrentLocale","console","locales","text","language","getTextContent","contentID","textContent","getImageSrc","imageContent","image","contentsObject","key","value","Object","getResponseContents","url","response","textResponseContents","webviewContent","imageResponseContents"],"mappings":";;;;;;;;;;;AAAyB;AACkB;AAEa;AACP;AASjC;AAET,SAASM,kBAAkBA,CAA4B,EAC5DC,SAASJ,yBAAyB,EAClCK,UAAUJ,6BAA6B,EACvCK,KAAK,EACLC,SAAS,EACTC,UAAU,EACVC,MAAM,EACNC,WAAW,EACgB;IAC3B,MAAM,CAACC,cAAcC,gBAAgB,GAAGb,QAAQA;IAChD,MAAM,CAACc,eAAeC,iBAAiB,GAAGf,QAAQA;IAClD,MAAM,CAACgB,UAAUC,YAAY,GAAGjB,QAAQA,CACtC,CAAC;IAEH,MAAM,CAACkB,eAAeC,iBAAiB,GAAGnB,QAAQA,CAACU;IACnD,MAAM,CAACU,OAAOC,SAAS,GAAGrB,QAAQA,CAAC;IAEnC,MAAMsB,sBAAsB,CAACV;QAC3B,IAAI,CAACA,gBAAgBA,aAAa,MAAM,KAAK,GAAG;YAC9CW,QAAQ,GAAG,CAAC;YACZ;QACF;QAEA,MAAMC,UAAUZ,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAACa,CAAAA,OAAQA,KAAK,MAAM;QACpE,MAAMC,WAAWR,cAAc,KAAK,CAAC,IAAI,CAAC,EAAE;QAE5C,IAAIM,QAAQ,QAAQ,CA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AAI,KAAKtC,wBAAwB;gBAEpEY,iBAAiB2B;gBAEjBpB,oBAAoBkB;YACtB,EAAE,OAAOpB,OAAO;gBACdG,QAAQ,KAAK,CAAC,oCAAoCH;gBAClDC,SAAS;YACX;QACF;QACAgB;IACF,GAAG,EAAE;IAEL,OAAO;QACL,WAAWD,OAAO,IAAI,CAACpB,UAAU,MAAM,KAAK;QAC5CI;QACA,wBAAwB;YACtBO;YACAG;YACAX;YACAH;QACF;IACF;AACF"}
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
+ "type": "module",
2
3
  "name": "@botonic/plugin-flow-builder",
3
- "version": "0.57.0-rslib-esm.0",
4
- "main": "./lib/esm/index.js",
5
- "module": "./lib/esm/index.js",
4
+ "version": "0.57.0-rslib-esm.2",
5
+ "main": "./lib/index.js",
6
+ "module": "./lib/index.js",
6
7
  "description": "Use Flow Builder to show your contents",
7
8
  "scripts": {
8
- "build": "node ../../scripts/build/clean.mjs && rslib build --no-env",
9
- "build:watch": "node ../../scripts/build/clean.mjs && rslib build --watch --no-env",
10
- "test": "../../node_modules/.bin/jest --coverage",
9
+ "build": "rslib build --no-env",
10
+ "build:watch": "rslib build --watch --no-env",
11
+ "test": "vitest run --coverage",
11
12
  "cloc": "../../scripts/qa/cloc-package.sh .",
12
13
  "prepublishOnly": "npm run build && npm run test && npm run lint",
13
14
  "lint": "biome check --write src/ tests/",
@@ -15,7 +16,7 @@
15
16
  "format": "biome format --write src/ tests/"
16
17
  },
17
18
  "dependencies": {
18
- "@botonic/react": "^0.57.0-rslib-esm.0",
19
+ "@botonic/react": "0.57.0-rslib-esm.2",
19
20
  "axios": "^1.18.1",
20
21
  "uuid": "^10.0.0"
21
22
  },
@@ -47,5 +48,5 @@
47
48
  "devDependencies": {
48
49
  "@types/uuid": "^10.0.0"
49
50
  },
50
- "types": "./lib/esm/index.d.ts"
51
+ "types": "./lib/index.d.ts"
51
52
  }
@@ -16,6 +16,7 @@ import { HubtypeAssistantContent } from '../utils/hubtype-assistant-content'
16
16
  import { ContentFieldsBase } from './content-fields-base'
17
17
  import { FlowCarousel } from './flow-carousel'
18
18
  import { FlowText } from './flow-text'
19
+ import { FlowWhatsappRequestContactInfoNode } from './flow-whatsapp-request-contact-info'
19
20
  import type { HtInputGuardrailRule, HtNodeWithContent } from './hubtype-fields'
20
21
  import type { FlowContent } from './index'
21
22
 
@@ -89,6 +90,16 @@ export abstract class FlowAiAgentBase extends ContentFieldsBase {
89
90
  )
90
91
  }
91
92
 
93
+ if (message.type === OutputMessageType.RequestContactInfo) {
94
+ this.jsxElements.push(
95
+ FlowWhatsappRequestContactInfoNode.fromAIAgent(
96
+ this.id,
97
+ message,
98
+ botContext
99
+ )
100
+ )
101
+ }
102
+
92
103
  if (message.type === FlowBuilderOutputMessageType.FlowBuilderContent) {
93
104
  const flowContents = await this.getFlowContentsByContentId(
94
105
  botContext,
@@ -1,4 +1,8 @@
1
- import { type BotContext, isWhatsapp } from '@botonic/core'
1
+ import {
2
+ type BotContext,
3
+ isWhatsapp,
4
+ type RequestContactInfoMessage,
5
+ } from '@botonic/core'
2
6
  import { Text, WhatsappRequestContactInfo } from '@botonic/react'
3
7
 
4
8
  import { trackOneContent } from '../tracking'
@@ -26,6 +30,18 @@ export class FlowWhatsappRequestContactInfoNode extends ContentFieldsBase {
26
30
  return requestContactInfo
27
31
  }
28
32
 
33
+ static fromAIAgent(
34
+ id: string,
35
+ message: RequestContactInfoMessage,
36
+ botContext: BotContext
37
+ ): JSX.Element {
38
+ if (!isWhatsapp(botContext.session)) {
39
+ return <Text key={id}>{message.content.text}</Text>
40
+ }
41
+
42
+ return <WhatsappRequestContactInfo key={id} body={message.content.text} />
43
+ }
44
+
29
45
  async trackFlow(botContext: BotContext): Promise<void> {
30
46
  await trackOneContent(botContext, this)
31
47
  }
@@ -27,14 +27,15 @@ export { ContentFieldsBase } from './content-fields-base'
27
27
  export { FlowButton } from './flow-button'
28
28
  export { FlowElement } from './flow-element'
29
29
  export {
30
- FlowAiAgentRouter,
31
30
  FlowAiAgent,
31
+ FlowAiAgentRouter,
32
32
  FlowBotAction,
33
33
  FlowCaptureUserInput,
34
34
  FlowCarousel,
35
35
  FlowChannelConditional,
36
36
  FlowCountryConditional,
37
37
  FlowCustomConditional,
38
+ FlowCustomConditionalV2,
38
39
  FlowGoToFlow,
39
40
  FlowHandoff,
40
41
  FlowImage,
@@ -48,7 +49,6 @@ export {
48
49
  FlowWhatsappCtaUrlButtonNode,
49
50
  FlowWhatsappRequestContactInfoNode,
50
51
  FlowWhatsappTemplate,
51
- FlowCustomConditionalV2,
52
52
  }
53
53
 
54
54
  export type FlowContent =
@@ -6,6 +6,7 @@ import { FlowImage } from '../content-fields/flow-image'
6
6
  import { FlowText } from '../content-fields/flow-text'
7
7
  import { FlowVideo } from '../content-fields/flow-video'
8
8
  import { FlowWhatsappCtaUrlButtonNode } from '../content-fields/flow-whatsapp-cta-url-button'
9
+ import { FlowWhatsappRequestContactInfoNode } from '../content-fields/flow-whatsapp-request-contact-info'
9
10
  import { FlowWhatsappTemplate } from '../content-fields/flow-whatsapp-template'
10
11
  import { HtButtonStyle } from '../content-fields/hubtype-fields'
11
12
  import { FlowWhatsappButtonList } from '../content-fields/whatsapp-button-list/flow-whatsapp-button-list'
@@ -34,6 +35,9 @@ export class HubtypeAssistantContent {
34
35
  if (content instanceof FlowWhatsappTemplate) {
35
36
  return HubtypeAssistantContent.formatWhatsappTemplateContent(content)
36
37
  }
38
+ if (content instanceof FlowWhatsappRequestContactInfoNode) {
39
+ return HubtypeAssistantContent.formatRequestContactInfoContent(content)
40
+ }
37
41
  return ''
38
42
  }
39
43
 
@@ -205,4 +209,14 @@ export class HubtypeAssistantContent {
205
209
  const { name, language } = template.htWhatsappTemplate
206
210
  return `WhatsApp Template: ${name} (${language})`
207
211
  }
212
+
213
+ private static formatRequestContactInfoContent(
214
+ requestContactInfo: FlowWhatsappRequestContactInfoNode
215
+ ): string {
216
+ const body = requestContactInfo.text?.trim() ?? ''
217
+ if (!body) {
218
+ return '[WhatsApp Request Contact Info]'
219
+ }
220
+ return requestContactInfo.text
221
+ }
208
222
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"action/ai-agent-from-user-input.js","sources":["../../../src/action/ai-agent-from-user-input.ts"],"sourcesContent":["import type { FlowContent } from '../content-fields/index'\nimport { splitAiAgentContents } from '../utils/ai-agent'\nimport type { FlowBuilderContext } from './context'\n\nexport async function getContentsByAiAgentFromUserInput({\n cmsApi,\n flowBuilderPlugin,\n request,\n}: FlowBuilderContext): Promise<FlowContent[]> {\n const startNodeAiAgentFlow = cmsApi.getStartNodeAiAgentFlow()\n const isAiAgentEnabled = cmsApi.isAiAgentEnabled()\n if (!startNodeAiAgentFlow || !isAiAgentEnabled) {\n return []\n }\n\n const contents =\n await flowBuilderPlugin.getContentsByNode(startNodeAiAgentFlow)\n\n const splitContents = splitAiAgentContents(contents)\n\n if (!splitContents) {\n return []\n }\n\n if ('aiAgentRouterContent' in splitContents) {\n const { aiAgentRouterContent, contentsBeforeAiAgentRouter } = splitContents\n const aiAgentResponse = await aiAgentRouterContent.resolveAIAgentResponse(\n request,\n contentsBeforeAiAgentRouter\n )\n\n if (!aiAgentResponse || aiAgentResponse.exit) {\n return []\n }\n }\n\n if ('aiAgentWorkerContent' in splitContents) {\n const { aiAgentWorkerContent, contentsBeforeAiAgentWorker } = splitContents\n const aiAgentResponse = await aiAgentWorkerContent.resolveAIAgentResponse(\n request,\n contentsBeforeAiAgentWorker\n )\n\n if (!aiAgentResponse || aiAgentResponse.exit) {\n return []\n }\n }\n\n return contents\n}\n"],"names":["splitAiAgentContents","getContentsByAiAgentFromUserInput","cmsApi","flowBuilderPlugin","request","startNodeAiAgentFlow","isAiAgentEnabled","contents","splitContents","aiAgentRouterContent","contentsBeforeAiAgentRouter","aiAgentResponse","aiAgentWorkerContent","contentsBeforeAiAgentWorker"],"mappings":";;;AACwD;AAGjD,eAAeC,iCAAiCA,CAAC,EACtDC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EACY;IACnB,MAAMC,uBAAuBH,OAAO,uBAAuB;IAC3D,MAAMI,mBAAmBJ,OAAO,gBAAgB;IAChD,IAAI,CAACG,wBAAwB,CAACC,kBAAkB;QAC9C,OAAO,EAAE;IACX;IAEA,MAAMC,WACJ,MAAMJ,kBAAkB,iBAAiB,CAACE;IAE5C,MAAMG,gBAAgBR,oBAAoBA,CAACO;IAE3C,IAAI,CAACC,eAAe;QAClB,OAAO,EAAE;IACX;IAEA,IAAI,0BAA0BA,eAAe;QAC3C,MAAM,EAAEC,oBAAoB,EAAEC,2BAA2B,EAAE,GAAGF;QAC9D,MAAMG,kBAAkB,MAAMF,qBAAqB,sBAAsB,CACvEL,SACAM;QAGF,IAAI,CAACC,mBAAmBA,gBAAgB,IAAI,EAAE;YAC5C,OAAO,EAAE;QACX;IACF;IAEA,IAAI,0BAA0BH,eAAe;QAC3C,MAAM,EAAEI,oBAAoB,EAAEC,2BAA2B,EAAE,GAAGL;QAC9D,MAAMG,kBAAkB,MAAMC,qBAAqB,sBAAsB,CACvER,SACAS;QAGF,IAAI,CAACF,mBAAmBA,gBAAgB,IAAI,EAAE;YAC5C,OAAO,EAAE;QACX;IACF;IAEA,OAAOJ;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"action/context.js","sources":["../../../src/action/context.ts"],"sourcesContent":["import type { BotContext } from '@botonic/core'\n\nimport type { FlowBuilderApi } from '../api'\nimport type BotonicPluginFlowBuilder from '../index'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\n\nexport interface FlowBuilderContext {\n cmsApi: FlowBuilderApi\n flowBuilderPlugin: BotonicPluginFlowBuilder\n request: BotContext\n resolvedLocale: string\n contentID?: string\n}\n\nexport function getFlowBuilderActionContext(\n request: BotContext,\n contentID?: string\n): FlowBuilderContext {\n const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)\n const cmsApi = flowBuilderPlugin.cmsApi\n const resolvedLocale = flowBuilderPlugin.cmsApi.getResolvedLocale()\n return {\n cmsApi,\n flowBuilderPlugin,\n request,\n resolvedLocale,\n contentID,\n }\n}\n"],"names":["getFlowBuilderPlugin","getFlowBuilderActionContext","request","contentID","flowBuilderPlugin","cmsApi","resolvedLocale"],"mappings":";;;AAIuE;AAUhE,SAASC,2BAA2BA,CACzCC,OAAmB,EACnBC,SAAkB;IAElB,MAAMC,oBAAoBJ,oBAAoBA,CAACE,QAAQ,OAAO;IAC9D,MAAMG,SAASD,kBAAkB,MAAM;IACvC,MAAME,iBAAiBF,kBAAkB,MAAM,CAAC,iBAAiB;IACjE,OAAO;QACLC;QACAD;QACAF;QACAI;QACAH;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"action/fallback.js","sources":["../../../src/action/fallback.ts"],"sourcesContent":["import { EventAction, type EventFallback } from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport type { FlowContent } from '../content-fields'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport type { FlowBuilderContext } from './context'\n\nexport async function getContentsByFallback({\n cmsApi,\n flowBuilderPlugin,\n request,\n}: FlowBuilderContext): Promise<FlowContent[]> {\n const fallbackNode = await getFallbackNode(cmsApi, request)\n const fallbackContents =\n await flowBuilderPlugin.getContentsByNode(fallbackNode)\n\n return fallbackContents\n}\n\nasync function getFallbackNode(cmsApi: FlowBuilderApi, request: ActionRequest) {\n if (request.session.user.extra_data?.isFirstFallbackOption === undefined) {\n request.session.user.extra_data = {\n ...request.session.user.extra_data,\n isFirstFallbackOption: true,\n }\n }\n\n const isFirstFallbackOption =\n !!request.session.user.extra_data.isFirstFallbackOption\n const fallbackNode = cmsApi.getFallbackNode(isFirstFallbackOption)\n request.session.user.extra_data.isFirstFallbackOption = !isFirstFallbackOption\n\n const { flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(request, fallbackNode.id)\n\n const event: EventFallback = {\n action: EventAction.Fallback,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n userInput: request.input.data as string,\n fallbackOut: isFirstFallbackOption ? 1 : 2,\n fallbackMessageId: request.input.message_id,\n }\n const { action, ...eventArgs } = event\n\n await trackEvent(request, action, eventArgs)\n\n return fallbackNode\n}\n"],"names":["EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","getContentsByFallback","cmsApi","flowBuilderPlugin","request","fallbackNode","getFallbackNode","fallbackContents","undefined","isFirstFallbackOption","flowId","flowName","flowNodeId","flowNodeContentId","event","action","eventArgs"],"mappings":";;;;;AAA+D;AAQ3C;AAGb,eAAeG,qBAAqBA,CAAC,EAC1CC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EACY;IACnB,MAAMC,eAAe,MAAMC,eAAeA,CAACJ,QAAQE;IACnD,MAAMG,mBACJ,MAAMJ,kBAAkB,iBAAiB,CAACE;IAE5C,OAAOE;AACT;AAEA,eAAeD,eAAeA,CAACJ,MAAsB,EAAEE,OAAsB;IAC3E,IAAIA,QAAQ,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,0BAA0BI,WAAW;QACxEJ,QAAQ,OAAO,CAAC,IAAI,CAAC,UAAU,GAAG;YAChC,GAAGA,QAAQ,OAAO,CAAC,IAAI,CAAC,UAAU;YAClC,uBAAuB;QACzB;IACF;IAEA,MAAMK,wBACJ,CAAC,CAACL,QAAQ,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB;IACzD,MAAMC,eAAeH,OAAO,eAAe,CAACO;IAC5CL,QAAQ,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,GAAG,CAACK;IAEzD,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GACvDd,yCAAyCA,CAACK,SAASC,aAAa,EAAE;IAEpE,MAAMS,QAAuB;QAC3B,QAAQhB,oBAAoB;QAC5BY;QACAC;QACAC;QACAC;QACA,WAAWT,QAAQ,KAAK,CAAC,IAAI;QAC7B,aAAaK,wBAAwB,IAAI;QACzC,mBAAmBL,QAAQ,KAAK,CAAC,UAAU;IAC7C;IACA,MAAM,EAAEW,MAAM,EAAE,GAAGC,WAAW,GAAGF;IAEjC,MAAMd,UAAUA,CAACI,SAASW,QAAQC;IAElC,OAAOX;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"action/first-interaction.js","sources":["../../../src/action/first-interaction.ts"],"sourcesContent":["import type { FlowBuilderApi } from '../api'\nimport { MAIN_FLOW_NAME } from '../constants'\nimport {\n FlowAiAgent,\n FlowAiAgentRouter,\n FlowBotAction,\n type FlowContent,\n} from '../content-fields'\nimport type BotonicPluginFlowBuilder from '../index'\nimport { inputHasTextOrTranscript } from '../utils/input'\nimport { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'\nimport type { FlowBuilderContext } from './context'\nimport { getContentsByPayload } from './payload'\n\nexport async function getContentsByFirstInteraction(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { contentID, flowBuilderPlugin, request } = context\n\n /*\n * If the contentID is provided, the firstInteractionContents are obtained even if they are not used\n * because when obtain this firstInteractionContents is when the session.flow_thread_id is updated.\n * This is needed for example when send a WhatsApp campaign is sent,\n * the bot not receives the message because this message is sent directly by the backend\n * we expect the bot to respond only with the contents of the contentID and not with the firstInteractionContents.\n */\n const firstInteractionContents = await flowBuilderPlugin.getStartContents()\n\n if (contentID) {\n try {\n const contentsByContentID =\n await flowBuilderPlugin.getContentsByContentID(contentID)\n\n if (contentsByContentID.length > 0) {\n return contentsByContentID\n }\n } catch (_error) {\n console.warn(\n `The contentID ${contentID} is not found. Returning the firstInteractionContents`\n )\n }\n }\n\n // Bot actions and AI agents already consume the user input. Matching\n // keywords/intents/KB/AI-agent-from-user-input on top would duplicate replies\n // (e.g. Main start → Go to flow → AI Agents).\n if (startContentsAlreadyHandleUserInput(firstInteractionContents)) {\n return firstInteractionContents\n }\n\n if (request.input.nluResolution || inputHasTextOrTranscript(request.input)) {\n const contentsByUserInput = await getContentsByUserInput(context)\n\n return [...firstInteractionContents, ...contentsByUserInput]\n }\n\n return firstInteractionContents\n}\n\nfunction startContentsAlreadyHandleUserInput(contents: FlowContent[]): boolean {\n if (contents.at(-1) instanceof FlowBotAction) {\n return true\n }\n\n // To avoid duplicated ai agent response, we check if there is an ai agent or ai agent router in the first interaction contents.\n return contents.some(\n content =>\n content instanceof FlowAiAgent || content instanceof FlowAiAgentRouter\n )\n}\n\nasync function getContentsByUserInput(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request, resolvedLocale } = context\n const payloadByNlu = request.input.nluResolution?.payload\n\n if (payloadByNlu) {\n request.input.payload = payloadByNlu\n const conversationStartId = getConversationStartId(cmsApi)\n\n if (request.input.payload === conversationStartId) {\n return []\n }\n\n const contentsByKeywordsOrIntents = await getContentsByPayload({\n cmsApi,\n flowBuilderPlugin,\n request,\n resolvedLocale,\n })\n\n const hasRepeatedContent = await checkRepeatedContents(\n flowBuilderPlugin,\n contentsByKeywordsOrIntents\n )\n\n if (hasRepeatedContent) {\n return []\n }\n\n if (contentsByKeywordsOrIntents.length > 0) {\n return contentsByKeywordsOrIntents\n }\n }\n\n if (!flowBuilderPlugin.disableAIAgentInFirstInteraction) {\n const contentsByAiAgent = await getContentsByAiAgentFromUserInput(context)\n return contentsByAiAgent\n }\n\n return []\n}\n\nfunction getConversationStartId(cmsApi: FlowBuilderApi) {\n const conversationStartId = cmsApi.flow.flows.find(\n flow => flow.name === MAIN_FLOW_NAME\n )?.start_node_id\n\n return conversationStartId\n}\n\nasync function checkRepeatedContents(\n flowBuilderPlugin: BotonicPluginFlowBuilder,\n contentsByKeywordsOrIntents: FlowContent[]\n) {\n const startContents = await flowBuilderPlugin.getStartContents()\n const contentIds = new Set(\n contentsByKeywordsOrIntents.map(content => content.id)\n )\n const hasRepeatedContent = startContents.some(content =>\n contentIds.has(content.id)\n )\n\n return hasRepeatedContent\n}\n"],"names":["MAIN_FLOW_NAME","FlowAiAgent","FlowAiAgentRouter","FlowBotAction","inputHasTextOrTranscript","getContentsByAiAgentFromUserInput","getContentsByPayload","getContentsByFirstInteraction","context","contentID","flowBuilderPlugin","request","firstInteractionContents","contentsByContentID","_error","console","startContentsAlreadyHandleUserInput","contentsByUserInput","getContentsByUserInput","contents","content","cmsApi","resolvedLocale","payloadByNlu","conversationStartId","getConversationStartId","contentsByKeywordsOrIntents","hasRepeatedContent","checkRepeatedContents","contentsByAiAgent","flow","startContents","contentIds","Set"],"mappings":";;;;;;;;;;;AAC6C;AAMnB;AAE+B;AACqB;AAE9B;AAEzC,eAAeO,6BAA6BA,CACjDC,OAA2B;IAE3B,MAAM,EAAEC,SAAS,EAAEC,iBAAiB,EAAEC,OAAO,EAAE,GAAGH;IAElD;;;;;;GAMC,GACD,MAAMI,2BAA2B,MAAMF,kBAAkB,gBAAgB;IAEzE,IAAID,WAAW;QACb,IAAI;YACF,MAAMI,sBACJ,MAAMH,kBAAkB,sBAAsB,CAACD;YAEjD,IAAII,oBAAoB,MAAM,GAAG,GAAG;gBAClC,OAAOA;YACT;QACF,EAAE,OAAOC,QAAQ;YACfC,QAAQ,IAAI,CACV,CAAC,cAAc,EAAEN,UAAU,qDAAqD,CAAC;QAErF;IACF;IAEA,qEAAqE;IACrE,8EAA8E;IAC9E,8CAA8C;IAC9C,IAAIO,mCAAmCA,CAACJ,2BAA2B;QACjE,OAAOA;IACT;IAEA,IAAID,QAAQ,KAAK,CAAC,aAAa,IAAIP,wBAAwBA,CAACO,QAAQ,KAAK,GAAG;QAC1E,MAAMM,sBAAsB,MAAMC,sBAAsBA,CAACV;QAEzD,OAAO;eAAII;eAA6BK;SAAoB;IAC9D;IAEA,OAAOL;AACT;AAEA,SAASI,mCAAmCA,CAACG,QAAuB;IAClE,IAAIA,SAAS,EAAE,CAAC,CAAC,cAAchB,aAAaA,EAAE;QAC5C,OAAO;IACT;IAEA,gIAAgI;IAChI,OAAOgB,SAAS,IAAI,CAClB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EAAE;IAG3B,OAAOO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"action/get-contents.js","sources":["../../../src/action/get-contents.ts"],"sourcesContent":["import { type BotContext, INPUT } from '@botonic/core'\nimport { EMPTY_PAYLOAD } from '../constants'\nimport type { FlowContent } from '../content-fields'\nimport { inputHasTextOrTranscript } from '../utils/input'\nimport { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'\nimport { getFlowBuilderActionContext } from './context'\nimport { getContentsByFallback } from './fallback'\nimport { getContentsByFirstInteraction } from './first-interaction'\nimport { getContentsByPayload } from './payload'\n\nexport async function getContents(\n botContext: BotContext,\n contentID?: string\n): Promise<FlowContent[]> {\n const context = getFlowBuilderActionContext(botContext, contentID)\n\n if (botContext.session.is_first_interaction) {\n return await getContentsByFirstInteraction(context)\n }\n // TODO: Add needed logic when we can define contents for multi locale queue position message\n if (botContext.input.type === INPUT.EVENT_QUEUE_POSITION_CHANGED) {\n return []\n }\n\n if (botContext.input.payload?.startsWith(EMPTY_PAYLOAD)) {\n botContext.input.payload = undefined\n }\n\n if (botContext.input.payload || contentID) {\n const contentsByPayload = await getContentsByPayload(context)\n if (contentsByPayload.length > 0) {\n return contentsByPayload\n }\n\n return await getContentsByFallback(context)\n }\n\n if (inputHasTextOrTranscript(botContext.input)) {\n const aiAgentContents = await getContentsByAiAgentFromUserInput(context)\n if (aiAgentContents.length > 0) {\n return aiAgentContents\n }\n }\n\n return await getContentsByFallback(context)\n}\n"],"names":["INPUT","EMPTY_PAYLOAD","inputHasTextOrTranscript","getContentsByAiAgentFromUserInput","getFlowBuilderActionContext","getContentsByFallback","getContentsByFirstInteraction","getContentsByPayload","getContents","botContext","contentID","context","undefined","contentsByPayload","aiAgentContents"],"mappings":";;;;;;;;;;;;;;;;;AAAsD;AACV;AAEa;AACqB;AACvB;AACL;AACiB;AACnB;AAEzC,eAAeQ,WAAWA,CAC/BC,UAAsB,EACtBC,SAAkB;IAElB,MAAMC,UAAUP,2BAA2BA,CAACK,YAAYC;IAExD,IAAID,WAAW,OAAO,CAAC,oBAAoB,EAAE;QAC3C,OAAO,MAAMH,6BAA6BA,CAACK;IAC7C;IACA,6FAA6F;IAC7F,IAAIF,WAAW,KAAK,CAAC,IAAI,KAAKT,kCAAkC,EAAE;QAChE,OAAO,EAAE;IACX;IAEA,IAAIS,WAAW,KAAK,CAAC,OAAO,EAAE,WAAWR,aAAaA,GAAG;QACvDQ,WAAW,KAAK,CAAC,OAAO,GAAGG;IAC7B;IAEA,IAAIH,WAAW,KAAK,CAAC,OAAO,IAAIC,WAAW;QACzC,MAAMG,oBAAoB,MAAMN,oBAAoBA,CAACI;QACrD,IAAIE,kBAAkB,MAAM,GAAG,GAAG;YAChC,OAAOA;QACT;QAEA,OAAO,MAAMR,qBAAqBA,CAACM;IACrC;IAEA,IAAIT,wBAAwBA,CAACO,WAAW,KAAK,GAAG;QAC9C,MAAMK,kBAAkB,MAAMX,iCAAiCA,CAACQ;QAChE,IAAIG,gBAAgB,MAAM,GAAG,GAAG;YAC9B,OAAOA;QACT;IACF;IAEA,OAAO,MAAMT,qBAAqBA,CAACM;AACrC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"action/index.js","sources":["../../../src/action/index.tsx"],"sourcesContent":["import { type BotContext, isDev, isWebchat } from '@botonic/core'\nimport {\n Multichannel,\n RequestContext,\n WebchatSettings,\n type WebchatSettingsProps,\n} from '@botonic/react'\nimport React from 'react'\n\nimport {\n FlowAiAgent,\n FlowAiAgentRouter,\n type FlowContent,\n} from '../content-fields'\nimport { splitAiAgentContents } from '../utils/ai-agent'\nimport { getFlowBuilderActionContext } from './context'\nimport { getContentsByFirstInteraction } from './first-interaction'\nimport { getContents } from './get-contents'\n\nexport type FlowBuilderActionProps = {\n contents: FlowContent[]\n webchatSettingsParams?: WebchatSettingsProps\n}\n\nexport class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {\n static contextType = RequestContext\n declare context: React.ContextType<typeof RequestContext>\n\n static async executeConversationStart(\n botContext: BotContext\n ): Promise<FlowBuilderActionProps> {\n const context = getFlowBuilderActionContext(botContext)\n const contents = await getContentsByFirstInteraction(context)\n\n const filteredContents = await FlowBuilderAction.prepareContentsToRender(\n botContext,\n contents\n )\n\n return { contents: filteredContents }\n }\n\n static async botonicInit(\n botContext: BotContext,\n contentID?: string\n ): Promise<FlowBuilderActionProps> {\n const contents = await getContents(botContext, contentID)\n\n const contentsToRender = await FlowBuilderAction.prepareContentsToRender(\n botContext,\n contents\n )\n\n return { contents: contentsToRender }\n }\n\n static async prepareContentsToRender(\n botContext: BotContext,\n contents: FlowContent[]\n ) {\n for (const content of contents) {\n if (FlowBuilderAction.isAiAgentContent(content)) {\n await FlowBuilderAction.processAiAgentContent(botContext, contents)\n continue\n }\n\n await content.processContent(botContext)\n }\n\n return contents\n }\n\n private static isAiAgentContent(content: FlowContent): boolean {\n return (\n content instanceof FlowAiAgent || content instanceof FlowAiAgentRouter\n )\n }\n\n // TODO: Refactor this to be more generic and reusable\n private static async processAiAgentContent(\n botContext: BotContext,\n contents: FlowContent[]\n ) {\n const splitContents = splitAiAgentContents(contents)\n if (!splitContents) {\n return\n }\n\n if ('aiAgentRouterContent' in splitContents) {\n const { aiAgentRouterContent, contentsBeforeAiAgentRouter } =\n splitContents\n await aiAgentRouterContent.processContent(\n botContext,\n contentsBeforeAiAgentRouter\n )\n }\n\n if ('aiAgentWorkerContent' in splitContents) {\n const { aiAgentWorkerContent, contentsBeforeAiAgentWorker } =\n splitContents\n await aiAgentWorkerContent.processContent(\n botContext,\n contentsBeforeAiAgentWorker\n )\n }\n }\n\n protected getWebchatSettingsParams(botContext: BotContext): {\n shouldSendWebchatSettings: boolean\n webchatSettingsParams?: WebchatSettingsProps\n } {\n let { webchatSettingsParams } = this.props\n if (botContext.session.user.system_locale_updated) {\n webchatSettingsParams = {\n ...webchatSettingsParams,\n user: {\n ...webchatSettingsParams?.user,\n system_locale: botContext.session.user.system_locale,\n },\n }\n }\n const shouldSendWebchatSettings =\n (isWebchat(botContext.session) || isDev(botContext.session)) &&\n !!webchatSettingsParams\n\n return {\n shouldSendWebchatSettings,\n webchatSettingsParams,\n }\n }\n\n render(): JSX.Element | JSX.Element[] {\n const { contents } = this.props\n const botContext = this.context as BotContext\n const { shouldSendWebchatSettings, webchatSettingsParams } =\n this.getWebchatSettingsParams(botContext)\n\n return (\n <>\n {shouldSendWebchatSettings && (\n <WebchatSettings {...webchatSettingsParams} />\n )}\n {contents.map(content => content.toBotonic(botContext))}\n </>\n )\n }\n}\n\nexport class FlowBuilderMultichannelAction extends FlowBuilderAction {\n render(): JSX.Element | JSX.Element[] {\n const { contents } = this.props\n const botContext = this.context as BotContext\n const { shouldSendWebchatSettings, webchatSettingsParams } =\n this.getWebchatSettingsParams(botContext)\n\n return (\n <Multichannel text={{ buttonsAsText: false }}>\n {shouldSendWebchatSettings && (\n <WebchatSettings {...webchatSettingsParams} />\n )}\n {contents.map(content => content.toBotonic(botContext))}\n </Multichannel>\n )\n }\n}\n"],"names":["isDev","isWebchat","Multichannel","RequestContext","WebchatSettings","React","FlowAiAgent","FlowAiAgentRouter","splitAiAgentContents","getFlowBuilderActionContext","getContentsByFirstInteraction","getContents","FlowBuilderAction","botContext","context","contents","filteredContents","contentID","contentsToRender","content","splitContents","aiAgentRouterContent","contentsBeforeAiAgentRouter","aiAgentWorkerContent","contentsBeforeAiAgentWorker","webchatSettingsParams","shouldSendWebchatSettings","FlowBuilderMultichannelAction"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAiE;AAM1C;AACE;AAMC;AAC8B;AACD;AACY;AACvB;AAOrC,MAAMY,iBAAiBA,SAASP,eAAe;IAIpD,aAAa,yBACXQ,UAAsB,EACW;QACjC,MAAMC,UAAUL,2BAA2BA,CAACI;QAC5C,MAAME,WAAW,MAAML,6BAA6BA,CAACI;QAErD,MAAME,mBAAmB,MAAMJ,iBAAiBA,CAAC,uBAAuB,CACtEC,YACAE;QAGF,OAAO;YAAE,UAAUC;QAAiB;IACtC;IAEA,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Aa;gBACtD;YACF;QACF;QACA,MAAMa,4BACHzB,CAAAA,SAASA,CAACY,WAAW,OAAO,KAAKb,KAAKA,CAACa,WAAW,OAAO,MAC1D,CAAC,CAACY;QAEJ,OAAO;YACLC;YACAD;QACF;IACF;IAEA,SAAsC;QACpC,MAAM,EAAEV,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK;QAC/B,MAAMF,aAAa,IAAI,CAAC,OAAO;QAC/B,MAAM,EAAEa,yBAAyB,EAAED,qBAAqB,EAAE,GACxD,IAAI,CAAC,wBAAwB,CAACZ;QAEhC,qBACE;;gBACGa,2CACC,IAACtB,eAAeA;oBAAE,GAAGqB,qBAAqB;;gBAE3CV,SAAS,GAAG,CAACI,CAAAA,UAAWA,QAAQ,SAAS,CAACN;;;IAGjD;AACF;AA1HaD,iBAAiBA,CACrB,cAAcT,cAAcA;AA2H9B,MAAMwB,6BAA6BA,SAASf,iBAAiBA;IAClE,SAAsC;QACpC,MAAM,EAAEG,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK;QAC/B,MAAMF,aAAa,IAAI,CAAC,OAAO;QAC/B,MAAM,EAAEa,yBAAyB,EAAED,qBAAqB,EAAE,GACxD,IAAI,CAAC,wBAAwB,CAACZ;QAEhC,qBACE,KAACX,YAAYA;YAAC,MAAM;gBAAE,eAAe;YAAM;;gBACxCwB,2CACC,IAACtB,eAAeA;oBAAE,GAAGqB,qBAAqB;;gBAE3CV,SAAS,GAAG,CAACI,CAAAA,UAAWA,QAAQ,SAAS,CAACN;;;IAGjD;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"action/payload.js","sources":["../../../src/action/payload.ts"],"sourcesContent":["import { EventAction, type EventFeedback, storeCaseRating } from '@botonic/core'\nimport { v7 as uuid } from 'uuid'\n\nimport {\n AGENT_RATING_PAYLOAD,\n PUSH_FLOW_PAYLOAD,\n SEPARATOR,\n} from '../constants'\nimport type { FlowContent } from '../content-fields'\nimport type { HtNodeWithContent } from '../content-fields/hubtype-fields'\nimport { trackEvent } from '../tracking'\nimport type { FlowBuilderContext } from './context'\n\nexport async function getContentsByPayload(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request, contentID } = context\n if (request.input.payload?.startsWith(AGENT_RATING_PAYLOAD)) {\n return await resolveRatingPayload(context)\n }\n if (request.input.payload?.startsWith(PUSH_FLOW_PAYLOAD)) {\n return await resolvePushFlowPayload(context)\n }\n\n const id = contentID\n ? cmsApi.getNodeByContentID(contentID)?.id\n : request.input.payload\n const targetNode = id ? cmsApi.getNodeById<HtNodeWithContent>(id) : undefined\n\n if (targetNode) {\n return await flowBuilderPlugin.getContentsByNode(targetNode)\n }\n\n return []\n}\n\nasync function resolveRatingPayload(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request } = context\n\n if (!request.input.payload) {\n return []\n }\n\n const { target, text, value, possibleOptions, possibleValues } =\n flowBuilderPlugin.getRatingSubmittedInfo(request.input.payload)\n\n if (request.session._hubtype_case_id) {\n const event: EventFeedback = {\n action: EventAction.FeedbackCase,\n feedbackTargetId: request.session._hubtype_case_id,\n feedbackGroupId: uuid().toString(),\n possibleOptions,\n possibleValues,\n option: text,\n value,\n }\n\n await storeCaseRating(request.session, value)\n await trackEvent(request, EventAction.FeedbackCase, event)\n }\n\n const targetNode = target\n ? cmsApi.getNodeById<HtNodeWithContent>(target.id)\n : undefined\n\n if (targetNode) {\n return await flowBuilderPlugin.getContentsByNode(targetNode)\n }\n\n return []\n}\n\nasync function resolvePushFlowPayload(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request } = context\n\n if (!request.input.payload) {\n return []\n }\n\n const parts = request.input.payload.split(SEPARATOR)\n const pushFlowId = parts.length > 1 ? parts[1] : ''\n\n if (!pushFlowId) {\n return []\n }\n\n try {\n const pushFlowNode =\n cmsApi.getNodeByCampaignId<HtNodeWithContent>(pushFlowId)\n\n if (!pushFlowNode) {\n return []\n }\n\n return await flowBuilderPlugin.getContentsByNode(pushFlowNode)\n } catch {\n // Campaign not found - return empty to trigger fallback\n return []\n }\n}\n"],"names":["EventAction","storeCaseRating","v7","uuid","AGENT_RATING_PAYLOAD","PUSH_FLOW_PAYLOAD","SEPARATOR","trackEvent","getContentsByPayload","context","cmsApi","flowBuilderPlugin","request","contentID","resolveRatingPayload","resolvePushFlowPayload","id","targetNode","undefined","target","text","value","possibleOptions","possibleValues","event","parts","pushFlowId","pushFlowNode"],"mappings":";;;;;;;;;AAAgF;AAC/C;AAMZ;AAGmB;AAGjC,eAAeQ,oBAAoBA,CACxCC,OAA2B;IAE3B,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGJ;IAC1D,IAAIG,QAAQ,KAAK,CAAC,OAAO,EAAE,WAAWR,oBAAoBA,GAAG;QAC3D,OAAO,MAAMU,oBAAoBA,CAACL;IACpC;IACA,IAAIG,QAAQ,KAAK,CAAC,OAAO,EAAE,WAAWP,iBAAiBA,GAAG;QACxD,OAAO,MAAMU,sBAAsBA,CAACN;IACtC;IAEA,MAAMO,KAAKH,YACPH,OAAO,kBAAkB,CAACG,YAAY,KACtCD,QAAQ,KAAK,CAAC,OAAO;IACzB,MAAMK,aAAaD,KAAKN,OAAO,WAAW,CAAoBM,MAAME;IAEpE,IAAID,YAAY;QACd,OAAO,MAAMN,kBAAkB,iBAAiB,CAACM;IACnD;IAEA,OAAO,EAAE;AACX;AAEA,eAAeH,oBAAoBA,CACjCL,OAA2B;IAE3B,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,OAAO,EAAE,GAAGH;IAE/C,IAAI,CAACG,QAAQ,KAAK,CAAC,OAAO,EAAE;QAC1B,OAAO,EAAE;IACX;IAEA,MAAM,EAAEO,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAEC,eAAe,EAAEC,cAAc,EAAE,GAC5DZ,kBAAkB,sBAAsB,CAACC,QAAQ,KAAK,CAAC,OAAO;IAEhE,IAAIA,QAAQ,OAAO,CAAC,gBAAgB,EAAE;QACpC,MAAMY,QAAuB;YAC3B,QAAQxB,wBAAwB;YAChC,kBAAkBY,QAAQ,OAAO,CAAC,gBAAgB;YAClD,iBAAiBT,EAAIA,GAAG,QAAQ;YAChCmB;YACAC;YACA,QAAQH;YACRC;QACF;QAEA,MAAMpB,eAAeA,CAACW,QAAQ,OAAO,EAAES;QACvC,MAAMd,UAAUA,CAACK,SAASZ,wBAAwB,EAAEwB;IACtD;IAEA,MAAMP,aAAaE,SACfT,OAAO,WAAW,CAAoBS,OAAO,EAAE,IAC/CD;IAEJ,IAAID,YAAY;QACd,OAAO,MAAMN,kBAAkB,iBAAiB,CAACM;IACnD;IAEA,OAAO,EAAE;AACX;AAEA,eAAeF,sBAAsBA,CACnCN,OAA2B;IAE3B,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,OAAO,EAAE,GAAGH;IAE/C,IAAI,CAACG,QAAQ,KAAK,CAAC,OAAO,EAAE;QAC1B,OAAO,EAAE;IACX;IAEA,MAAMa,QAAQb,QAAQ,KAAK,CAAC,OAAO,CAAC,KAAK,CAACN,SAASA;IACnD,MAAMoB,aAAaD,MAAM,MAAM,GAAG,IAAIA,KAAK,CAAC,EAAE,GAAG;IAEjD,IAAI,CAACC,YAAY;QACf,OAAO,EAAE;IACX;IAEA,IAAI;QACF,MAAMC,eACJjB,OAAO,mBAAmB,CAAoBgB;QAEhD,IAAI,CAACC,cAAc;YACjB,OAAO,EAAE;QACX;QAEA,OAAO,MAAMhB,kBAAkB,iBAAiB,CAACgB;IACnD,EAAE,OAAM;QACN,wDAAwD;QACxD,OAAO,EAAE;IACX;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sources":["../../src/api.ts"],"sourcesContent":["import type { PluginPreRequest } from '@botonic/core'\nimport axios from 'axios'\n\nimport { AI_AGENTS_FLOW_NAME, SEPARATOR, UUID_REGEXP } from './constants'\nimport {\n type HtBotActionNode,\n type HtCaptureUserInputNode,\n type HtFallbackNode,\n type HtFlowBuilderData,\n type HtFlowWebview,\n type HtGoToFlow,\n type HtKeywordNode,\n type HtNodeComponent,\n type HtNodeLink,\n type HtNodeWithContent,\n HtNodeWithContentType,\n type HtPayloadNode,\n type HtRatingButton,\n type HtRatingNode,\n type HtSmartIntentNode,\n} from './content-fields/hubtype-fields'\nimport {\n type FlowBuilderApiOptions,\n type PayloadParamsBase,\n ProcessEnvNodeEnvs,\n} from './types'\nimport { FlowLocale } from './utils/flow-locale'\n\nexport class FlowBuilderApi {\n url: string\n flowUrl: string\n flow: HtFlowBuilderData\n request: PluginPreRequest\n\n private constructor() {}\n\n static async create(options: FlowBuilderApiOptions): Promise<FlowBuilderApi> {\n const newApi = new FlowBuilderApi()\n\n newApi.url = options.url\n newApi.request = options.request\n // TODO: Refactor later to combine logic from `FlowBuilderApi.create`, `resolveFlowUrl` and `getAccessToken` to be in one place\n if (process.env.NODE_ENV === ProcessEnvNodeEnvs.DEVELOPMENT) {\n await newApi.updateSessionWithUserInfo(options.accessToken)\n }\n const updatedRequest = newApi.request\n newApi.flowUrl = options.flowUrl.replace(\n '{bot_id}',\n updatedRequest.session.bot.id\n )\n newApi.flow = options.flow ?? (await newApi.getFlow(options.accessToken))\n return newApi\n }\n\n private async getFlow(token: string): Promise<HtFlowBuilderData> {\n const { data } = await axios.get(this.flowUrl, {\n headers: { Authorization: `Bearer ${token}` },\n })\n return data as HtFlowBuilderData\n }\n\n private async updateSessionWithUserInfo(token: string) {\n const url = `${this.url}/v1/flow_builder/user_info/`\n const response = await axios.get(url, {\n headers: { Authorization: `Bearer ${token}` },\n })\n this.request.session.organization_id = response.data.organization_id\n this.request.session.bot.id = response.data.bot_id\n }\n\n getNodeByFlowId(id: string): HtNodeWithContent {\n const subFlow = this.flow.flows.find(subFlow => subFlow.id === id)\n if (!subFlow) {\n throw Error(`SubFlow with id: '${id}' not found`)\n }\n return this.getNodeById<HtNodeWithContent>(subFlow.start_node_id)\n }\n\n getNodeByCampaignId<T extends HtNodeComponent>(id: string): T {\n const campaign = this.flow.campaigns.find(campaign => campaign.id === id)\n if (!campaign) {\n throw Error(`Campaign with id: '${id}' not found`)\n }\n return this.getNodeById<T>(campaign.start_node_id)\n }\n\n getNodeById<T extends HtNodeComponent>(id: string): T {\n const node = this.flow.nodes.find(node => node.id === id)\n if (!node) {\n console.error(`Node with id: '${id}' not found`)\n }\n\n return node as T\n }\n\n getRatingNodeByButtonId(id: string): HtRatingNode {\n const ratingNodes = this.flow.nodes.filter(\n node => node.type === HtNodeWithContentType.RATING\n ) as HtRatingNode[]\n const ratingNode = ratingNodes.find(node =>\n node.content.buttons.some(button => button.id === id)\n ) as HtRatingNode | undefined\n\n if (!ratingNode) {\n throw Error(`Rating node with button id: '${id}' not found`)\n }\n\n return ratingNode\n }\n\n getRatingButtonById(ratingNode: HtRatingNode, id: string): HtRatingButton {\n const ratingButton = ratingNode.content.buttons.find(\n button => button.id === id\n ) as HtRatingButton | undefined\n if (!ratingButton) {\n throw Error(`Rating button with id: '${id}' not found`)\n }\n\n return ratingButton\n }\n\n getNodeByContentID(contentID: string): HtNodeComponent {\n const content = this.flow.nodes.find(node =>\n 'code' in node ? node.code === contentID : false\n )\n if (!content) {\n throw Error(`Node with contentID: '${contentID}' not found`)\n }\n return content\n }\n\n getStartNode(): HtNodeWithContent {\n const startNodeId = this.flow.start_node_id\n if (!startNodeId) {\n throw new Error('Start node id must be defined')\n }\n return this.getNodeById(startNodeId)\n }\n\n getFallbackNode(alternate: boolean): HtNodeWithContent {\n const fallbackNode = this.flow.nodes.find(\n node => node.type === HtNodeWithContentType.FALLBACK\n ) as HtFallbackNode | undefined\n if (!fallbackNode) {\n throw new Error('Fallback node must be defined')\n }\n const fallbackFirstMessage = fallbackNode.content.first_message\n if (!fallbackFirstMessage) {\n throw new Error('Fallback 1st message must be defined')\n }\n const fallbackSecondMessage = fallbackNode.content.second_message\n if (!fallbackSecondMessage) {\n return this.getNodeById(fallbackFirstMessage.id)\n }\n return alternate\n ? this.getNodeById(fallbackFirstMessage.id)\n : this.getNodeById(fallbackSecondMessage.id)\n }\n\n getSmartIntentNodes(): HtSmartIntentNode[] {\n return this.flow.nodes.filter(\n node => node.type === HtNodeWithContentType.SMART_INTENT\n ) as HtSmartIntentNode[]\n }\n\n getKeywordNodes(): HtKeywordNode[] {\n return this.flow.nodes.filter(\n node => node.type === HtNodeWithContentType.KEYWORD\n ) as HtKeywordNode[]\n }\n\n getPayload(target?: HtNodeLink): string | undefined {\n if (!target) {\n return undefined\n }\n\n return target.id\n }\n\n isBotAction(id: string): boolean {\n if (!this.isUUID(id)) {\n return false\n }\n const node = this.getNodeById(id)\n return node?.type === HtNodeWithContentType.BOT_ACTION\n }\n\n private isUUID(str: string): boolean {\n return UUID_REGEXP.test(str)\n }\n\n createPayloadWithParams(botActionNode: HtBotActionNode): string {\n const payloadId = botActionNode.content.payload_id\n const payloadNode = this.getNodeById<HtPayloadNode>(payloadId)\n const customParams = JSON.parse(\n botActionNode.content.payload_params || '{}'\n )\n\n const contentID = botActionNode.code\n\n const followUpContentID = this.getFollowUpContentID(\n botActionNode.follow_up?.id\n )\n\n const payloadParams: PayloadParamsBase = {\n contentID,\n followUpContentID,\n }\n\n const payloadJson = JSON.stringify({\n ...customParams,\n ...payloadParams,\n })\n return `${payloadNode.content.payload}${SEPARATOR}${payloadJson}`\n }\n\n private getFollowUpContentID(id?: string): string | undefined {\n const followUpNode = id\n ? this.getNodeById<HtNodeWithContent | HtGoToFlow>(id)\n : undefined\n\n return followUpNode?.code\n }\n\n getFlowName(flowId: string): string {\n const flow = this.flow.flows.find(flow => flow.id === flowId)\n return flow ? flow.name : this.getCampaignFlowName(flowId)\n }\n\n getCampaignFlowName(campaignId: string): string {\n const campaign = this.flow.campaigns.find(\n campaign => campaign.id === campaignId\n )\n return campaign ? campaign.name : ''\n }\n\n getStartNodeAiAgentFlow(): HtNodeWithContent | undefined {\n const aiAgentFlow = this.flow.flows.find(\n flow => flow.name === AI_AGENTS_FLOW_NAME\n )\n\n if (!aiAgentFlow) {\n return undefined\n }\n\n return this.getNodeById<HtNodeWithContent>(aiAgentFlow.start_node_id)\n }\n\n isAiAgentEnabled(): boolean {\n return this.flow.is_ai_agent_active || false\n }\n\n getWebviewById(id: string): HtFlowWebview | undefined {\n return this.flow.webviews.find(webview => webview.id === id)\n }\n\n shouldCaptureUserInput(): boolean {\n return !!this.getCaptureUserInputId()\n }\n\n getCaptureUserInputId(): string | undefined {\n return this.request.session.capture_user_input?.node_id\n }\n\n setCaptureUserInputId(id: string): void {\n if (this.request.session.capture_user_input) {\n this.request.session.capture_user_input.node_id = id\n }\n this.request.session.capture_user_input = { node_id: id }\n }\n\n removeCaptureUserInputId(): void {\n this.request.session.capture_user_input = undefined\n }\n\n setUserExtraDataVariable(key: string, value: string): void {\n if (this.request.session.user.extra_data) {\n this.request.session.user.extra_data[key] = value\n }\n }\n\n getCaptureUserInputNode(): HtCaptureUserInputNode | undefined {\n const captureUserInputId = this.getCaptureUserInputId()\n if (!captureUserInputId) {\n return undefined\n }\n return this.getNodeById<HtCaptureUserInputNode>(captureUserInputId)\n }\n\n getResolvedLocale(): string {\n const flowLocales = this.flow.locales\n const defaultLocaleCode = this.flow.default_locale_code\n\n return new FlowLocale(\n this.request,\n flowLocales,\n defaultLocaleCode\n ).resolve()\n }\n}\n"],"names":["axios","AI_AGENTS_FLOW_NAME","SEPARATOR","UUID_REGEXP","HtNodeWithContentType","ProcessEnvNodeEnvs","FlowLocale","FlowBuilderApi","options","newApi","process","updatedRequest","token","data","url","response","id","subFlow","Error","campaign","node","console","ratingNodes","ratingNode","button","ratingButton","contentID","content","startNodeId","alternate","fallbackNode","fallbackFirstMessage","fallbackSecondMessage","target","undefined","str","botActionNode","payloadId","payloadNode","customParams","JSON","followUpContentID","payloadParams","payloadJson","followUpNode","flowId","flow","campaignId","aiAgentFlow","webview","key","value","captureUserInputId","flowLocales","defaultLocaleCode"],"m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AE;YACxC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAACD,IAAI,GAAGC;QAC9C;IACF;IAEA,0BAA8D;QAC5D,MAAMC,qBAAqB,IAAI,CAAC,qBAAqB;QACrD,IAAI,CAACA,oBAAoB;YACvB,OAAOlB;QACT;QACA,OAAO,IAAI,CAAC,WAAW,CAAyBkB;IAClD;IAEA,oBAA4B;QAC1B,MAAMC,cAAc,IAAI,CAAC,IAAI,CAAC,OAAO;QACrC,MAAMC,oBAAoB,IAAI,CAAC,IAAI,CAAC,mBAAmB;QAEvD,OAAO,IAAIhD,UAAUA,CACnB,IAAI,CAAC,OAAO,EACZ+C,aACAC,mBACA,OAAO;IACX;IAxQA,aAAsB,CAAC;AAyQzB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sources":["../../src/constants.ts"],"sourcesContent":["export const FLOW_BUILDER_API_URL_PROD =\n process.env.HUBTYPE_API_URL || 'https://api.hubtype.com'\nexport const SEPARATOR = '|'\nexport const SOURCE_INFO_SEPARATOR = `${SEPARATOR}source_`\nexport const EMPTY_PAYLOAD = 'fb-empty-payload'\nexport const VARIABLE_PATTERN_GLOBAL = /{([^{}]+)}/g\nexport const ACCESS_TOKEN_VARIABLE_KEY = '_access_token'\nexport const REG_EXP_PATTERN = /^\\/(.*)\\/([gimyus]*)$/\nexport const UUID_REGEXP =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\n/* ********** PAYLOADS ********** */\nexport const AGENT_RATING_PAYLOAD = 'agent-rating'\nexport const PUSH_FLOW_PAYLOAD = 'push-flow'\n\n/* ********** FLOW NAMES ********** */\nexport const MAIN_FLOW_NAME = 'Main'\nexport const AI_AGENTS_FLOW_NAME = 'AI Agents'\nexport const FALLBACK_FLOW_NAME = 'Fallback'\n"],"names":["FLOW_BUILDER_API_URL_PROD","process","SEPARATOR","SOURCE_INFO_SEPARATOR","EMPTY_PAYLOAD","VARIABLE_PATTERN_GLOBAL","ACCESS_TOKEN_VARIABLE_KEY","REG_EXP_PATTERN","UUID_REGEXP","AGENT_RATING_PAYLOAD","PUSH_FLOW_PAYLOAD","MAIN_FLOW_NAME","AI_AGENTS_FLOW_NAME","FALLBACK_FLOW_NAME"],"mappings":"AAAO,MAAMA,yBAAyBA,GACpCC,QAAQ,GAAG,CAAC,eAAe,IAAI,0BAAyB;AACnD,MAAMC,SAASA,GAAG,IAAG;AACrB,MAAMC,qBAAqBA,GAAG,GAAGD,SAASA,CAAC,OAAO,CAAC;AACnD,MAAME,aAAaA,GAAG,mBAAkB;AACxC,MAAMC,uBAAuBA,GAAG,cAAa;AAC7C,MAAMC,yBAAyBA,GAAG,gBAAe;AACjD,MAAMC,eAAeA,GAAG,wBAAuB;AAC/C,MAAMC,WAAWA,GACtB,kEAAiE;AAEnE,kCAAkC,GAC3B,MAAMC,oBAAoBA,GAAG,eAAc;AAC3C,MAAMC,iBAAiBA,GAAG,YAAW;AAE5C,oCAAoC,GAC7B,MAAMC,cAAcA,GAAG,OAAM;AAC7B,MAAMC,mBAAmBA,GAAG,YAAW;AACvC,MAAMC,kBAAkBA,GAAG,WAAU"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-fields/content-fields-base.js","sources":["../../../src/content-fields/content-fields-base.ts"],"sourcesContent":["import type { BotContext } from '@botonic/core'\nimport {\n ACCESS_TOKEN_VARIABLE_KEY,\n VARIABLE_PATTERN_GLOBAL,\n} from '../constants'\nimport { ContentFilterExecutor } from '../filters'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport type {\n HtMediaFileLocale,\n HtNodeLink,\n HtQueueLocale,\n HtTextLocale,\n HtVideoLocale,\n} from './hubtype-fields'\nimport type { FlowContent } from './index'\n\nexport abstract class ContentFieldsBase {\n public code: string\n public followUp?: HtNodeLink\n\n constructor(public readonly id: string) {}\n\n abstract trackFlow(botContext: BotContext): Promise<void>\n\n abstract processContent(botContext: BotContext): Promise<void>\n\n async filterContent(\n botContext: BotContext,\n content: FlowContent\n ): Promise<FlowContent> {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const contentFilters = flowBuilderPlugin.contentFilters\n const contentFilterExecutor = new ContentFilterExecutor({\n filters: contentFilters,\n })\n const filteredContent = await contentFilterExecutor.filter(\n botContext,\n content\n )\n return filteredContent\n }\n\n static getTextByLocale(locale: string, text: HtTextLocale[]): string {\n const result = text.find(t => t.locale === locale)\n return result?.message ?? ''\n }\n\n static getAssetByLocale(locale: string, asset: HtMediaFileLocale[]): string {\n const result = asset.find(i => i.locale === locale)\n return result?.file ?? ''\n }\n\n static getVideoByLocale(locale: string, video: HtVideoLocale[]): string {\n const result = video.find(v => v.locale === locale)\n return result?.url ?? ''\n }\n\n static getQueueByLocale(\n locale: string,\n queues: HtQueueLocale[]\n ): HtQueueLocale | undefined {\n return queues.find(queue => queue.locale === locale)\n }\n\n replaceVariables(text: string, botContext: BotContext): string {\n if (!botContext) {\n return text\n }\n\n return text.replace(VARIABLE_PATTERN_GLOBAL, match => {\n // remove \\\\ ( escape for _ ) added by text node with markdown\n const keyPath = match.slice(1, -1).replaceAll('\\\\', '')\n\n const botVariable = keyPath.endsWith(ACCESS_TOKEN_VARIABLE_KEY)\n ? match\n : this.getValueFromKeyPath(botContext, keyPath)\n\n return this.isValidType(botVariable) ? String(botVariable) : match\n })\n }\n\n getValueFromKeyPath(botContext: BotContext, keyPath: string): any {\n if (keyPath.startsWith('session.user.contact_info.')) {\n const name = keyPath.split('.').at(-1)\n return botContext.session.user.contact_info?.find(\n contact => contact.name === name\n )?.value\n }\n\n if (keyPath.startsWith('input.') || keyPath.startsWith('session.')) {\n return keyPath\n .split('.')\n .reduce((object, key) => this.resolveObjectKey(object, key), botContext)\n }\n\n return keyPath\n .split('.')\n .reduce(\n (object, key) => this.resolveObjectKey(object, key),\n botContext.session.user.extra_data\n )\n }\n\n private resolveObjectKey(object: any, key: string): any {\n if (object && object[key] !== undefined) {\n return object[key]\n }\n return undefined\n }\n\n private isValidType(botVariable: any): boolean {\n const validTypes = ['boolean', 'string', 'number']\n return validTypes.includes(typeof botVariable)\n }\n}\n"],"names":["ACCESS_TOKEN_VARIABLE_KEY","VARIABLE_PATTERN_GLOBAL","ContentFilterExecutor","getFlowBuilderPlugin","ContentFieldsBase","botContext","content","flowBuilderPlugin","contentFilters","contentFilterExecutor","filteredContent","locale","text","result","t","asset","i","video","v","queues","queue","match","keyPath","botVariable","String","name","contact","object","key","undefined","validTypes","id"],"mappings":";;;;;;;AAIqB;AAC6B;AACqB;AAUhE,MAAeI,iBAAiBA;IAUrC,MAAM,cACJC,UAAsB,EACtBC,OAAoB,EACE;QACtB,MAAMC,oBAAoBJ,oBAAoBA,CAACE,WAAW,OAAO;QACjE,MAAMG,iBAAiBD,kBAAkB,cAAc;QACvD,MAAME,wBAAwB,IAAIP,qBAAqBA,CAAC;YACtD,SAASM;QACX;QACA,MAAME,kBAAkB,MAAMD,sBAAsB,MAAM,CACxDJ,YACAC;QAEF,OAAOI;IACT;IAEA,OAAO,gBAAgBC,MAAc,EAAEC,IAAoB,EAAU;QACnE,MAAMC,SAASD,KAAK,IAAI,CAACE,CAAAA,IAAKA,EAAE,MAAM,KAAKH;QAC3C,OAAOE,QAAQ,WAAW;IAC5B;IAEA,OAAO,iBAAiBF,MAAc,EAAEI,KAA0B,EAAU;QAC1E,MAAMF,SAASE,MAAM,IAAI,CAACC,CAAAA,IAAKA,EAAE,MAAM,KAAKL;QAC5C,OAAOE,QAAQ,QAAQ;IACzB;IAEA,OAAO,iBAAiBF,MAAc,EAAEM,KAAsB,EAAU;QACtE,MAAMJ,SAASI,MAAM,IAAI,CAACC,CAAAA,IAAKA,EAAE,MAAM,KAAKP;QAC5C,OAAOE,QAAQ,OAAO;IACxB;IAEA,OAAO,iBACLF,MAAc,EACdQ,MAAuB,EACI;QAC3B,OAAOA,OAAO,IAAI,CAACC,CAAAA,QAASA,MAAM,MAAM,KAA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S;QAClD,OAAOA,WAAW,QAAQ,CAAC,OAAOP;IACpC;IA7FA,YAA4BQ,EAAU,CAAE;aAAZA,KAAAA;IAAa;AA8F3C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-fields/custom-conditional/custom-conditional-v2-evaluators.js","sources":["../../../../src/content-fields/custom-conditional/custom-conditional-v2-evaluators.ts"],"sourcesContent":["import {\n BooleanConditionOperator,\n type HtBooleanCondition,\n type HtNumberCondition,\n type HtStringCondition,\n NumberConditionOperator,\n StringConditionOperator,\n} from '../hubtype-fields'\n\ntype StringEvaluator = (variable: string, value: string) => boolean\n\ntype NumberEvaluator = (\n variable: number,\n value: number,\n condition: HtNumberCondition\n) => boolean\n\ntype BooleanEvaluator = (variable: boolean) => boolean\n\nexport function getMinAndMax(condition: HtNumberCondition): {\n min: number\n max: number\n} {\n if (condition.min !== undefined && condition.max !== undefined) {\n return { min: condition.min, max: condition.max }\n }\n throw new Error(\n `Min or max not found for number condition ${condition.operator}`\n )\n}\n\nexport const STRING_CONDITION_EVALUATORS: Record<\n StringConditionOperator,\n StringEvaluator\n> = {\n [StringConditionOperator.Contains]: (variable, value) =>\n variable.includes(value),\n [StringConditionOperator.NotContains]: (variable, value) =>\n !variable.includes(value),\n [StringConditionOperator.EqualsTo]: (variable, value) => variable === value,\n [StringConditionOperator.NotEqualsTo]: (variable, value) =>\n variable !== value,\n [StringConditionOperator.StartsWith]: (variable, value) =>\n variable.startsWith(value),\n [StringConditionOperator.NotStartsWith]: (variable, value) =>\n !variable.startsWith(value),\n [StringConditionOperator.EndsWith]: (variable, value) =>\n variable.endsWith(value),\n [StringConditionOperator.NotEndsWith]: (variable, value) =>\n !variable.endsWith(value),\n}\n\nexport const NUMBER_CONDITION_EVALUATORS: Record<\n NumberConditionOperator,\n NumberEvaluator\n> = {\n [NumberConditionOperator.EqualsTo]: (variable, value) => variable === value,\n [NumberConditionOperator.NotEqualsTo]: (variable, value) =>\n variable !== value,\n [NumberConditionOperator.GreaterThan]: (variable, value) => variable > value,\n [NumberConditionOperator.LessThan]: (variable, value) => variable < value,\n [NumberConditionOperator.GreaterThanOrEqualTo]: (variable, value) =>\n variable >= value,\n [NumberConditionOperator.LessThanOrEqualTo]: (variable, value) =>\n variable <= value,\n [NumberConditionOperator.Between]: (variable, _value, condition) => {\n const { min, max } = getMinAndMax(condition)\n return variable >= min && variable <= max\n },\n [NumberConditionOperator.NotBetween]: (variable, _value, condition) => {\n const { min, max } = getMinAndMax(condition)\n return variable < min || variable > max\n },\n}\n\nexport const BOOLEAN_CONDITION_EVALUATORS: Record<\n BooleanConditionOperator,\n BooleanEvaluator\n> = {\n [BooleanConditionOperator.IsTruthy]: variable => !!variable,\n}\n\nexport function evaluateStringCondition(\n variable: string,\n condition: HtStringCondition\n): boolean {\n if (condition.value === undefined) {\n throw new Error(\n `Value not found for string condition ${condition.operator}`\n )\n }\n const evaluator = STRING_CONDITION_EVALUATORS[condition.operator]\n if (!evaluator) {\n throw new Error(`Invalid string condition operator ${condition.operator}`)\n }\n return evaluator(variable, condition.value)\n}\n\nexport function evaluateNumberCondition(\n variable: number,\n condition: HtNumberCondition\n): boolean {\n if (condition.value === undefined) {\n throw new Error(\n `Value not found for number condition ${condition.operator}`\n )\n }\n const evaluator = NUMBER_CONDITION_EVALUATORS[condition.operator]\n if (!evaluator) {\n throw new Error(`Invalid number condition operator ${condition.operator}`)\n }\n return evaluator(variable, condition.value, condition)\n}\n\nexport function evaluateBooleanCondition(\n variable: boolean,\n condition: HtBooleanCondition\n): boolean {\n const evaluator = BOOLEAN_CONDITION_EVALUATORS[condition.operator]\n if (!evaluator) {\n throw new Error(`Invalid boolean condition operator ${condition.operator}`)\n }\n return evaluator(variable)\n}\n"],"names":["BooleanConditionOperator","NumberConditionOperator","StringConditionOperator","getMinAndMax","condition","undefined","Error","STRING_CONDITION_EVALUATORS","variable","value","NUMBER_CONDITION_EVALUATORS","_value","min","max","BOOLEAN_CONDITION_EVALUATORS","evaluateStringCondition","evaluator","evaluateN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ACtCV,QAAiB,EACjBJ,SAA6B;IAE7B,MAAMY,YAAYF,4BAA4B,CAACV,UAAU,QAAQ,CAAC;IAClE,IAAI,CAACY,WAAW;QACd,MAAM,IAAIV,MAAM,CAAC,mCAAmC,EAAEF,UAAU,QAAQ,EAAE;IAC5E;IACA,OAAOY,UAAUR;AACnB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-fields/custom-conditional/custom-conditional-v2-resolver.js","sources":["../../../../src/content-fields/custom-conditional/custom-conditional-v2-resolver.ts"],"sourcesContent":["import {\n type HtCondition,\n type HtNodeLink,\n type HtNumberCondition,\n type HtStringCondition,\n NumberConditionOperator,\n VariableFormat,\n} from '../hubtype-fields'\n\nexport type ConditionMatch = {\n customResult: string\n target: HtNodeLink\n operator: string\n}\n\nexport function getConditionCustomResult(\n condition: HtCondition,\n variableFormat: VariableFormat\n): string {\n switch (variableFormat) {\n case VariableFormat.String:\n return String((condition as HtStringCondition).value)\n case VariableFormat.Number:\n return getNumberConditionCustomResult(condition as HtNumberCondition)\n case VariableFormat.Boolean:\n // Only reached after evaluateBooleanCondition succeeds; today that is isTruthy → 'true'\n return 'true'\n default:\n throw new Error(`Invalid variable format ${variableFormat}`)\n }\n}\n\nfunction getNumberConditionCustomResult(condition: HtNumberCondition): string {\n const numberCondition = condition as HtNumberCondition\n if (\n numberCondition.operator === NumberConditionOperator.Between ||\n numberCondition.operator === NumberConditionOperator.NotBetween\n ) {\n return `min: ${numberCondition.min} - max: ${numberCondition.max}`\n }\n return String(numberCondition.value)\n}\n\nexport function findLastMatchingCondition<T extends HtCondition>(\n conditions: T[],\n variable: unknown,\n variableFormat: VariableFormat,\n evaluate: (variable: unknown, condition: T) => boolean\n): ConditionMatch | undefined {\n let lastMatch: ConditionMatch | undefined\n\n for (const condition of conditions) {\n if (!evaluate(variable, condition)) {\n continue\n }\n\n if (!condition.target) {\n continue\n }\n\n lastMatch = {\n customResult: getConditionCustomResult(condition, variableFormat),\n target: condition.target,\n operator: condition.operator,\n }\n }\n\n return lastMatch\n}\n\nexport function resolveWithDefaultTarget(\n match: ConditionMatch | undefined,\n defaultTarget: HtNodeLink,\n nodeCode: string,\n defaultCustomResult: string = 'default'\n): ConditionMatch {\n if (match) {\n return match\n }\n\n if (!defaultTarget) {\n throw new Error(\n `Default target not found for custom condition node ${nodeCode}`\n )\n }\n\n return {\n customResult: defaultCustomResult,\n target: defaultTarget,\n operator: '',\n }\n}\n"],"names":["NumberConditionOperator","VariableFormat","getConditionCustomResult","condition","variableFormat","String","getNumberConditionCustomResult","Error","numberCondition","findLastMatchingCondition","conditions","variable","evaluate","lastMatch","resolveWithDefaultTarget","match","defaultTarget","nodeCode","defaultCustomResult"],"mappings":";;;AAO0B;AAQnB,SAASE,wBAAwBA,CACtCC,SAAsB,EACtBC,cAA8B;IAE9B,OAAQA;QACN,KAAKH,qBAAqB;YACxB,OAAOI,OAAQF,UAAgC,KAAK;QACtD,KAAKF,qBAAqB;YACxB,OAAOK,8BAA8BA,CAACH;QACxC,KAAKF,sBAAsB;YACzB,wFAAwF;YACxF,OAAO;QACT;YACE,MAAM,IAAIM,MAAM,CAAC,wBAAwB,EAAEH,gBAAgB;IAC/D;AACF;AAEA,SAASE,8BAA8BA,CAACH,SAA4B;IAClE,MAAMK,kBAAkBL;IACxB,IACEK,gBAAgB,QAAQ,KAAKR,+BAA+B,IAC5DQ,gBAAgB,QAAQ,KAAKR,kCAAkC,EAC/D;QACA,OAAO,CAAC,KAAK,EAAEQ,gBAAgB,GAAG,CAAC,QAAQ,EAAEA,gBAAgB,GAAG,EAAE;IACpE;IACA,OAAOH,OAAOG,gBAAgB,KAAK;AACrC;AAEO,SAASC,yBAAyBA,CACvCC,UAAe,EACfC,QAAiB,EACjBP,cAA8B,EAC9BQ,QAAsD;IAEtD,IAAIC;IAEJ,KAAK,MAAMV,aAAaO,WAAY;QAClC,IAAI,CAACE,SAASD,UAAUR,YAAY;YAClC;QACF;QAEA,IAAI,CAACA,UAAU,MAAM,EAAE;YACrB;QACF;QAEAU,YAAY;YACV,cAAcX,wBAAwBA,CAACC,WAAWC;YAClD,QAAQD,UAAU,MAAM;YACxB,UAAUA,UAAU,QAAQ;QAC9B;IACF;IAEA,OAAOU;AACT;AAEO,SAASC,wBAAwBA,CACtCC,KAAiC,EACjCC,aAAyB,EACzBC,QAAgB,EAChBC,sBAA8B,SAAS;IAEvC,IAAIH,OAAO;QACT,OAAOA;IACT;IAEA,IAAI,CAACC,eAAe;QAClB,MAAM,IAAIT,MACR,CAAC,mDAAmD,EAAEU,UAAU;IAEpE;IAEA,OAAO;QACL,cAAcC;QACd,QAAQF;QACR,UAAU;IACZ;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-fields/custom-conditional/flow-custom-condition-v2.js","sources":["../../../../src/content-fields/custom-conditional/flow-custom-condition-v2.tsx"],"sourcesContent":["import {\n type BotContext,\n EventAction,\n type EventConditionalCustom,\n} from '@botonic/core'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../../tracking'\nimport { ContentFieldsBase } from '../content-fields-base'\nimport {\n type HtBooleanCondition,\n type HtCondition,\n type HtCustomConditionalV2Node,\n type HtNodeLink,\n type HtNumberCondition,\n type HtStringCondition,\n VariableFormat,\n} from '../hubtype-fields'\nimport {\n evaluateBooleanCondition,\n evaluateNumberCondition,\n evaluateStringCondition,\n} from './custom-conditional-v2-evaluators'\nimport {\n type ConditionMatch,\n findLastMatchingCondition,\n resolveWithDefaultTarget,\n} from './custom-conditional-v2-resolver'\n\nexport class FlowCustomConditionalV2 extends ContentFieldsBase {\n public variableFormat: VariableFormat\n public keyPath: string\n public conditions: HtCondition[]\n public defaultTarget: HtNodeLink\n public customResult = ''\n public resolvedOperator = ''\n\n static fromHubtypeCMS(\n component: HtCustomConditionalV2Node,\n botContext: BotContext\n ): FlowCustomConditionalV2 {\n const newCustomConditionalV2 = new FlowCustomConditionalV2(component.id)\n newCustomConditionalV2.code = component.code\n newCustomConditionalV2.variableFormat = component.content.type\n newCustomConditionalV2.keyPath = component.content.key_path\n newCustomConditionalV2.conditions = component.content.conditions\n newCustomConditionalV2.defaultTarget = component.content.default_target\n newCustomConditionalV2.setFollowUp(botContext)\n\n return newCustomConditionalV2\n }\n\n private setFollowUp(botContext: BotContext): void {\n const botVariable = this.getValueFromKeyPath(botContext, this.keyPath)\n const resolved = this.evaluateConditions(botVariable)\n\n this.customResult = resolved.customResult\n this.resolvedOperator = resolved.operator\n this.followUp = resolved.target\n }\n\n private evaluateConditions(botVariable: unknown): ConditionMatch {\n switch (this.variableFormat) {\n case VariableFormat.String: {\n const match = findLastMatchingCondition(\n this.conditions as HtStringCondition[],\n botVariable,\n this.variableFormat,\n (variable, condition) =>\n evaluateStringCondition(variable as string, condition)\n )\n return resolveWithDefaultTarget(match, this.defaultTarget, this.code)\n }\n case VariableFormat.Number: {\n const match = findLastMatchingCondition(\n this.conditions as HtNumberCondition[],\n botVariable,\n this.variableFormat,\n (variable, condition) =>\n evaluateNumberCondition(variable as number, condition)\n )\n return resolveWithDefaultTarget(match, this.defaultTarget, this.code)\n }\n case VariableFormat.Boolean: {\n const match = findLastMatchingCondition(\n this.conditions as HtBooleanCondition[],\n botVariable,\n this.variableFormat,\n (variable, condition) =>\n evaluateBooleanCondition(variable as boolean, condition)\n )\n return resolveWithDefaultTarget(\n match,\n this.defaultTarget,\n this.code,\n 'false'\n )\n }\n default:\n throw new Error(\n `Invalid variable format ${this.variableFormat} for custom condition node ${this.code}`\n )\n }\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n const eventCustomConditional: EventConditionalCustom = {\n action: EventAction.ConditionalCustom,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowNodeIsMeaningful: false,\n conditionalVariable: this.customResult,\n variableFormat: this.variableFormat,\n operator: this.resolvedOperator,\n }\n const { action, ...eventArgs } = eventCustomConditional\n await trackEvent(botContext, action, eventArgs)\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic() {\n return <></>\n }\n}\n"],"names":["EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","ContentFieldsBase","VariableFormat","evaluateBooleanCondition","evaluateNumberCondition","evaluateStringCondition","findLastMatchingCondition","resolveWithDefaultTarget","FlowCustomConditionalV2","component","botContext","newCustomConditionalV2","botVariable","resolved","match","variable","condition","Error","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","eventCustomConditional","action","eventArgs"],"mappings":";;;;;;;;;;;;;;;;AAIsB;AAIC;AACmC;AAShC;AAKiB;AAKF;AAElC,MAAMU,uBAAuBA,SAASP,iBAAiBA;IAQ5D,OAAO,eACLQ,SAAoC,EACpCC,UAAsB,EACG;QACzB,MAAMC,yBAAyB,IAAIH,uBAAuBA,CAACC,UAAU,EAAE;QACvEE,uBAAuB,IAAI,GAAGF,UAAU,IAAI;QAC5CE,uBAAuB,cAAc,GAAGF,UAAU,OAAO,CAAC,IAAI;QAC9DE,uBAAuB,OAAO,GAAGF,UAAU,OAAO,CAAC,QAAQ;QAC3DE,uBAAuB,UAAU,GAAGF,UAAU,OAAO,CAAC,UAAU;QAChEE,uBAAuB,aAAa,GAAGF,UAAU,OAAO,CAAC,cAAc;QACvEE,uBAAuB,WAAW,CAACD;QAEnC,OAAOC;IACT;IAEQ,YAAYD,UAAsB,EAAQ;QAChD,MAAME,cAAc,IAAI,CAAC,mBAAmB,CAACF,YAAY,IAAI,CAAC,OAAO;QACrE,MAAMG,WAAW,IAAI,CAAC,kBAAkB,CAACD;QAEzC,IAAI,CAAC,YAAY,GAAGC,SAAS,YAAY;QACzC,IAAI,CAAC,gBAAgB,GAAGA,SAAS,QAAQ;QACzC,IAAI,CAAC,QAAQ,GAAGA,SAAS,MAAM;IACjC;IAEQ,mBAAmBD,WAAoB,EAAkB;QAC/D,OAAQ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C,UAAU,IAAI,CAAC,gBAAgB;QACjC;QACA,MAAM,EAAEE,MAAM,EAAE,GAAGC,WAAW,GAAGF;QACjC,MAAMvB,UAAUA,CAACU,YAAYc,QAAQC;IACvC;IAEA,MAAM,eAAef,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,aAAa,CAACA,YAAY,IAAI;QACzC,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,YAAY;QACV,qBAAO;IACT;;QAxGK,qBAKE,eAAe,SACf,mBAAmB;;AAmG5B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-fields/flow-ai-agent-base.js","sources":["../../../src/content-fields/flow-ai-agent-base.tsx"],"sourcesContent":["import {\n type AgenticOutputMessage,\n type BotContext,\n type GuardrailRule,\n type HubtypeAssistantMessage,\n type InferenceResponse,\n OutputMessageType,\n VerbosityLevel,\n} from '@botonic/core'\nimport {\n type FlowBuilderContentMessage,\n FlowBuilderOutputMessageType,\n} from '../structured-output/flow-builder-content'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport { HubtypeAssistantContent } from '../utils/hubtype-assistant-content'\nimport { ContentFieldsBase } from './content-fields-base'\nimport { FlowCarousel } from './flow-carousel'\nimport { FlowText } from './flow-text'\nimport type { HtInputGuardrailRule, HtNodeWithContent } from './hubtype-fields'\nimport type { FlowContent } from './index'\n\nexport abstract class FlowAiAgentBase extends ContentFieldsBase {\n public name: string = ''\n public instructions: string = ''\n public model: string = ''\n public verbosity: VerbosityLevel = VerbosityLevel.Medium\n public inputGuardrailRules: HtInputGuardrailRule[] = []\n\n public aiAgentResponse?: InferenceResponse<FlowBuilderContentMessage>\n public messages: AgenticOutputMessage<FlowBuilderContentMessage>[] = []\n public jsxElements: JSX.Element[] = []\n\n abstract getAIAgentResponse(\n botContext: BotContext,\n previousContents?: FlowContent[]\n ): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined>\n\n abstract trackAiAgentResponse(botContext: BotContext): Promise<void>\n\n async resolveAIAgentResponse(\n botContext: BotContext,\n previousContents?: FlowContent[]\n ): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined> {\n const aiAgentResponse = await this.getAIAgentResponse(\n botContext,\n previousContents\n )\n\n if (aiAgentResponse) {\n this.aiAgentResponse = aiAgentResponse\n await this.trackAiAgentResponse(botContext)\n this.messages = aiAgentResponse.messages\n }\n\n return aiAgentResponse\n }\n\n async trackFlow(_botContext: BotContext): Promise<void> {\n return\n }\n\n async getFlowContentsByContentId(\n botContext: BotContext,\n contentId: string\n ): Promise<FlowContent[]> {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const cmsApi = flowBuilderPlugin.cmsApi\n const node = cmsApi.getNodeByContentID(contentId)\n const flowContents = await flowBuilderPlugin.getContentsByNode(\n node as HtNodeWithContent\n )\n\n return flowContents\n }\n\n async messagesToBotonicJSXElements(botContext: BotContext): Promise<void> {\n for (const message of this.messages) {\n if (\n message.type === OutputMessageType.Text ||\n message.type === OutputMessageType.TextWithButtons ||\n message.type === OutputMessageType.BotExecutor\n ) {\n this.jsxElements.push(FlowText.fromAIAgent(this.id, message))\n }\n\n if (message.type === OutputMessageType.Carousel) {\n this.jsxElements.push(\n FlowCarousel.fromAIAgent(this.id, message, botContext)\n )\n }\n\n if (message.type === FlowBuilderOutputMessageType.FlowBuilderContent) {\n const flowContents = await this.getFlowContentsByContentId(\n botContext,\n message.contentId\n )\n for (const content of flowContents) {\n await content.processContent(botContext)\n this.jsxElements.push(content.toBotonic(botContext))\n }\n }\n }\n return\n }\n\n async processContent(\n botContext: BotContext,\n previousContents?: FlowContent[]\n ): Promise<void> {\n if (this.messages.length === 0) {\n await this.resolveAIAgentResponse(botContext, previousContents)\n }\n if (this.jsxElements.length === 0) {\n await this.filterContent(botContext, this as unknown as FlowContent)\n await this.messagesToBotonicJSXElements(botContext)\n }\n return\n }\n\n toBotonic(): JSX.Element {\n return <>{this.jsxElements}</>\n }\n\n protected getPreviousHubtypeContents(\n previousContents?: FlowContent[]\n ): HubtypeAssistantMessage[] {\n return (\n previousContents?.map(content => {\n return {\n role: 'assistant',\n content: HubtypeAssistantContent.adapt(content),\n }\n }) || []\n )\n }\n\n protected getActiveInputGuardrailRules(\n inputGuardrailRules: HtInputGuardrailRule[]\n ): GuardrailRule[] {\n return (\n inputGuardrailRules\n ?.filter(rule => rule.is_active)\n ?.map(rule => ({\n name: rule.name,\n description: rule.description,\n })) || []\n )\n }\n}\n"],"names":["OutputMessageType","VerbosityLevel","FlowBuilderOutputMessageType","getFlowBuilderPlugin","HubtypeAssistantContent","ContentFieldsBase","FlowCarousel","FlowText","FlowAiAgentBase","botContext","previousContents","aiAgentResponse","_botContext","contentId","flowBuilderPlugin","cmsApi","node","flowContents","message","content","inputGuardrailRules","rule"],"mappings":";;;;;;;;;;;;;;;;;;AAQsB;AAI4B;AACqB;AACK;AACnB;AACX;AACR;AAI/B,MAAeQ,eAAeA,SAASH,iBAAiBA;IAkB7D,MAAM,uBACJI,UAAsB,EACtBC,gBAAgC,EACmC;QACnE,MAAMC,kBAAkB,MAAM,IAAI,CAAC,kBAAkB,CACnDF,YACAC;QAGF,IAAIC,iBAAiB;YACnB,IAAI,CAAC,eAAe,GAAGA;YACvB,MAAM,IAAI,CAAC,oBAAoB,CAACF;YAChC,IAAI,CAAC,QAAQ,GAAGE,gBAAgB,QAAQ;QAC1C;QAEA,OAAOA;IACT;IAEA,MAAM,UAAUC,WAAuB,EAAiB;QACtD;IACF;IAEA,MAAM,2BACJH,UAAsB,EACtBI,SAAiB,EACO;QACxB,MAAMC,oBAAoBX,oBAAoBA,CAACM,WAAW,OAAO;QACjE,MAAMM,SAASD,kBAAkB,MAAM;QACvC,MAAME,OAAOD,OAAO,kBAAkB,CAACF;QACvC,MAAMI,eAAe,MAAMH,kBAAkB,iBAAiB,CAC5DE;QAGF,OAAOC;IACT;IAEA,MAAM,6BAA6BR,UAAsB,EAAiB;QACxE,KAAK,MAAMS,WAAW,IAAI,CAAC,QAAQ,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KAAK,SAAS,GAC7B,IAAIA,CAAAA,OAAS;gBACb,MAAMA,KAAK,IAAI;gBACf,aAAaA,KAAK,WAAW;YAC/B,OAAO,EAAE;IAEf;;QA9HK,qBACE,OAAe,SACf,eAAuB,SACvB,QAAgB,SAChB,YAA4BpB,qBAAqB,OACjD,sBAA8C,EAAE,OAGhD,WAA8D,EAAE,OAChE,cAA6B,EAAE;;AAsHxC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-fields/flow-ai-agent-router.js","sources":["../../../src/content-fields/flow-ai-agent-router.tsx"],"sourcesContent":["import {\n AiAgentType,\n type BotContext,\n EventAction,\n type EventAiAgent,\n type EventAiAgentRouter,\n type InferenceResponse,\n} from '@botonic/core'\nimport {\n type FlowBuilderContentMessage,\n FlowBuilderContentSchema,\n} from '../structured-output/flow-builder-content'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport { FlowAiAgent } from './flow-ai-agent'\nimport { FlowAiAgentBase } from './flow-ai-agent-base'\nimport type { HtAiAgentNode, HtAiAgentRouterNode } from './hubtype-fields'\nimport type { FlowContent } from './index'\n\nexport interface AvailableSpecialists {\n agent: FlowAiAgent\n description: string\n name: string\n}\n\nexport class FlowAiAgentRouter extends FlowAiAgentBase {\n public availableSpecialists: AvailableSpecialists[] = []\n\n static fromHubtypeCMS(\n component: HtAiAgentRouterNode,\n botContext: BotContext\n ): FlowAiAgentRouter {\n const newAiAgentRouter = new FlowAiAgentRouter(component.id)\n newAiAgentRouter.code = component.code\n newAiAgentRouter.name = component.content.name\n newAiAgentRouter.instructions = newAiAgentRouter.replaceVariables(\n component.content.instructions,\n botContext\n )\n newAiAgentRouter.model = component.content.model\n newAiAgentRouter.verbosity = component.content.verbosity\n newAiAgentRouter.availableSpecialists =\n FlowAiAgentRouter.getAvailableSpecialistsFromHubtypeCMS(\n component,\n botContext\n )\n newAiAgentRouter.inputGuardrailRules =\n component.content.input_guardrail_rules || []\n return newAiAgentRouter\n }\n\n private static getAvailableSpecialistsFromHubtypeCMS(\n component: HtAiAgentRouterNode,\n botContext: BotContext\n ): AvailableSpecialists[] {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const cmsApi = flowBuilderPlugin.cmsApi\n\n return component.content.available_specialists.map((agentSlot, index) => {\n const aiAgentSpecialistNode = cmsApi.getNodeById<HtAiAgentNode>(\n agentSlot.target.id\n )\n const specialist = FlowAiAgent.fromHubtypeCMS(\n aiAgentSpecialistNode,\n botContext\n )\n const specialistName = FlowAiAgentRouter.specialistAgentBaseName(\n agentSlot.name,\n index\n )\n const specialistDescription = specialist.replaceVariables(\n agentSlot.description || `Transfer to ${specialistName}`,\n botContext\n )\n\n return {\n agent: specialist,\n description: specialistDescription,\n name: `transfer_to_${specialistName}`,\n }\n })\n }\n\n private static specialistAgentBaseName(\n name: string | undefined,\n index: number\n ): string {\n return name?.trim().toLowerCase().replace(/ /g, '_') || `ai_agent_${index}`\n }\n\n async getAIAgentResponse(\n botContext: BotContext,\n previousContents?: FlowContent[]\n ): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined> {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const aiAgentResponse = await flowBuilderPlugin.getAiAgentResponse?.(\n botContext,\n {\n type: AiAgentType.Router,\n name: this.name,\n instructions: this.instructions,\n model: this.model,\n verbosity: this.verbosity,\n specialists: this.availableSpecialists.map(\n ({ agent, description, name }) => ({\n type: AiAgentType.Specialist,\n name,\n description,\n instructions: agent.instructions,\n model: agent.model,\n verbosity: agent.verbosity,\n activeTools: agent.activeTools ?? [],\n inputGuardrailRules: this.getActiveInputGuardrailRules(\n agent.inputGuardrailRules\n ),\n sourceIds: agent.sources?.map(s => s.id) ?? [],\n })\n ),\n inputGuardrailRules: this.getActiveInputGuardrailRules(\n this.inputGuardrailRules\n ),\n outputMessagesSchemas: [FlowBuilderContentSchema],\n previousHubtypeMessages:\n this.getPreviousHubtypeContents(previousContents),\n }\n )\n\n return aiAgentResponse\n }\n\n async trackAiAgentResponse(botContext: BotContext) {\n const isTransferredToSpecialist =\n this.aiAgentResponse?.isTransferredToSpecialist ?? false\n\n await this.trackAIAgentRouterEvent(botContext, isTransferredToSpecialist)\n\n if (isTransferredToSpecialist) {\n await this.trackAIAgentSpecialistEvent(botContext)\n }\n }\n\n private async trackAIAgentRouterEvent(\n botContext: BotContext,\n isTransferredToSpecialist: boolean\n ) {\n const { flowThreadId, flowId, flowName, flowNodeId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n const routerEvent: EventAiAgentRouter = {\n action: EventAction.AiAgentRouter,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId: this.name,\n flowNodeIsMeaningful: true,\n memoryLength: this.aiAgentResponse?.memoryLength ?? 0,\n inputMessageId: botContext.input.message_id!,\n exit: this.aiAgentResponse?.exit ?? true,\n error: this.aiAgentResponse?.error ?? false,\n inputGuardrailsTriggered:\n this.aiAgentResponse?.inputGuardrailsTriggered ?? [],\n outputGuardrailsTriggered:\n this.aiAgentResponse?.outputGuardrailsTriggered ?? [],\n startingAgentName: this.aiAgentResponse?.startingAgentName || this.name,\n lastAgentName: this.aiAgentResponse?.lastAgentName || this.name,\n availableSpecialists: this.aiAgentResponse?.availableSpecialists ?? [],\n isTransferredToSpecialist,\n }\n const { action, ...routerEventArgs } = routerEvent\n await trackEvent(botContext, action, routerEventArgs)\n }\n\n private async trackAIAgentSpecialistEvent(botContext: BotContext) {\n const { flowThreadId, flowId, flowName, flowNodeId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n const specialistEvent: EventAiAgent = {\n action: EventAction.AiAgent,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId: this.aiAgentResponse?.lastAgentName ?? '',\n flowNodeIsMeaningful: true,\n toolsExecuted: this.aiAgentResponse?.toolsExecuted ?? [],\n memoryLength: this.aiAgentResponse?.memoryLength ?? 0,\n inputMessageId: botContext.input.message_id!,\n exit: this.aiAgentResponse?.exit ?? true,\n error: this.aiAgentResponse?.error ?? false,\n inputGuardrailsTriggered: [],\n outputGuardrailsTriggered:\n this.aiAgentResponse?.outputGuardrailsTriggered ?? [],\n }\n const { action, ...specialistEventArgs } = specialistEvent\n await trackEvent(botContext, action, specialistEventArgs)\n }\n}\n"],"names":["AiAgentType","EventAction","FlowBuilderContentSchema","getCommonFlowContentEventArgsForContentId","trackEvent","getFlowBuilderPlugin","FlowAiAgent","FlowAiAgentBase","FlowAiAgentRouter","component","botContext","newAiAgentRouter","flowBuilderPlugin","cmsApi","agentSlot","index","aiAgentSpecialistNode","specialist","specialistName","specialistDescription","name","previousContents","aiAgentResponse","agent","description","s","isTransferredToSpecialist","flowThreadId","flowId","flowName","flowNodeId","routerEvent","action","routerEventArgs","specialistEvent","specialistEventArgs"],"mappings":";;;;;;;;;;;;;AAOsB;AAI4B;AAI9B;AACmD;AAC1B;AACS;AAU/C,MAAMQ,iBAAiBA,SAASD,eAAeA;IAGpD,OAAO,eACLE,SAA8B,EAC9BC,UAAsB,EACH;QACnB,MAAMC,mBAAmB,IAAIH,iBAAiBA,CAACC,UAAU,EAAE;QAC3DE,iBAAiB,IAAI,GAAGF,UAAU,IAAI;QACtCE,iBAAiB,IAAI,GAAGF,UAAU,OAAO,CAAC,IAAI;QAC9CE,iBAAiB,YAAY,GAAGA,iBAAiB,gBAAgB,CAC/DF,UAAU,OAAO,CAAC,YAAY,EAC9BC;QAEFC,iBAAiB,KAAK,GAAGF,UAAU,OAAO,CAAC,KAAK;QAChDE,iBAAiB,SAAS,GAAGF,UAAU,OAAO,CAAC,SAAS;QACxDE,iBAAiB,oBAAoB,GACnCH,iBAAiBA,CAAC,qCAAqC,CACrDC,WACAC;QAEJC,iBAAiB,mBAAmB,GAClCF,UAAU,OAAO,CAAC,qBAAqB,IAAI,EAAE;QAC/C,OAAOE;IACT;IAEA,OAAe,sCACbF,SAA8B,EAC9B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AAsB,IAAI,CAAC,eAAe,EAAE,wBAAwB,EAAE;YACtEgB;QACF;QACA,MAAM,EAAEM,MAAM,EAAE,GAAGC,iBAAiB,GAAGF;QACvC,MAAM3B,UAAUA,CAACM,YAAYsB,QAAQC;IACvC;IAEA,MAAc,4BAA4BvB,UAAsB,EAAE;QAChE,MAAM,EAAEiB,YAAY,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAE,GAClD3B,yCAAyCA,CAACO,YAAY,IAAI,CAAC,EAAE;QAE/D,MAAMwB,kBAAgC;YACpC,QAAQjC,mBAAmB;YAC3B0B;YACAC;YACAC;YACAC;YACA,mBAAmB,IAAI,CAAC,eAAe,EAAE,iBAAiB;YAC1D,sBAAsB;YACtB,eAAe,IAAI,CAAC,eAAe,EAAE,iBAAiB,EAAE;YACxD,cAAc,IAAI,CAAC,eAAe,EAAE,gBAAgB;YACpD,gBAAgBpB,WAAW,KAAK,CAAC,UAAU;YAC3C,MAAM,IAAI,CAAC,eAAe,EAAE,QAAQ;YACpC,OAAO,IAAI,CAAC,eAAe,EAAE,SAAS;YACtC,0BAA0B,EAAE;YAC5B,2BACE,IAAI,CAAC,eAAe,EAAE,6BAA6B,EAAE;QACzD;QACA,MAAM,EAAEsB,MAAM,EAAE,GAAGG,qBAAqB,GAAGD;QAC3C,MAAM9B,UAAUA,CAACM,YAAYsB,QAAQG;IACvC;;QA3KK,qBACE,uBAA+C,EAAE;;AA2K1D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-fields/flow-ai-agent.js","sources":["../../../src/content-fields/flow-ai-agent.tsx"],"sourcesContent":["import {\n AiAgentType,\n type BotContext,\n EventAction,\n type EventAiAgent,\n type InferenceResponse,\n} from '@botonic/core'\nimport {\n type FlowBuilderContentMessage,\n FlowBuilderContentSchema,\n} from '../structured-output/flow-builder-content'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport { FlowAiAgentBase } from './flow-ai-agent-base'\nimport type { HtAiAgentNode } from './hubtype-fields/ai-agent'\nimport type { FlowContent } from './index'\n\nexport class FlowAiAgent extends FlowAiAgentBase {\n public activeTools?: { name: string }[]\n public sources?: { id: string; name: string }[]\n\n static fromHubtypeCMS(\n component: HtAiAgentNode,\n botContext: BotContext\n ): FlowAiAgent {\n const newAiAgent = new FlowAiAgent(component.id)\n newAiAgent.code = component.code\n newAiAgent.name = component.content.name\n newAiAgent.instructions = newAiAgent.replaceVariables(\n component.content.instructions,\n botContext\n )\n newAiAgent.model = component.content.model\n newAiAgent.verbosity = component.content.verbosity\n newAiAgent.activeTools = component.content.active_tools\n newAiAgent.inputGuardrailRules =\n component.content.input_guardrail_rules || []\n newAiAgent.sources = component.content.sources\n newAiAgent.followUp = component.follow_up\n\n return newAiAgent\n }\n\n async getAIAgentResponse(\n botContext: BotContext,\n previousContents?: FlowContent[]\n ): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined> {\n const activeInputGuardrailRules = this.getActiveInputGuardrailRules(\n this.inputGuardrailRules\n )\n\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n\n const aiAgentResponse = await flowBuilderPlugin.getAiAgentResponse?.(\n botContext,\n {\n type: AiAgentType.Specialist,\n name: this.name,\n instructions: this.instructions,\n model: this.model,\n verbosity: this.verbosity,\n activeTools: this.activeTools ?? [],\n inputGuardrailRules: activeInputGuardrailRules,\n sourceIds: this.sources?.map(source => source.id) ?? [],\n outputMessagesSchemas: [FlowBuilderContentSchema],\n previousHubtypeMessages:\n this.getPreviousHubtypeContents(previousContents),\n }\n )\n\n return aiAgentResponse\n }\n\n async trackAiAgentResponse(botContext: BotContext) {\n const { flowThreadId, flowId, flowName, flowNodeId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n const event: EventAiAgent = {\n action: EventAction.AiAgent,\n flowThreadId: flowThreadId,\n flowId: flowId,\n flowName: flowName,\n flowNodeId: flowNodeId,\n flowNodeContentId: this.name,\n flowNodeIsMeaningful: true,\n toolsExecuted: this.aiAgentResponse?.toolsExecuted ?? [],\n memoryLength: this.aiAgentResponse?.memoryLength ?? 0,\n inputMessageId: botContext.input.message_id!,\n exit: this.aiAgentResponse?.exit ?? true,\n inputGuardrailsTriggered:\n this.aiAgentResponse?.inputGuardrailsTriggered ?? [],\n outputGuardrailsTriggered: [], //aiAgentResponse.outputGuardrailsTriggered,\n error: this.aiAgentResponse?.error ?? false,\n }\n const { action, ...eventArgs } = event\n\n await trackEvent(botContext, action, eventArgs)\n }\n}\n"],"names":["AiAgentType","EventAction","FlowBuilderContentSchema","getCommonFlowContentEventArgsForContentId","trackEvent","getFlowBuilderPlugin","FlowAiAgentBase","FlowAiAgent","component","botContext","newAiAgent","previousContents","activeInputGuardrailRules","flowBuilderPlugin","aiAgentResponse","source","flowThreadId","flowId","flowName","flowNodeId","event","action","eventArgs"],"mappings":";;;;;;;;;;;AAMsB;AAI4B;AAI9B;AACmD;AACjB;AAI/C,MAAMO,WAAWA,SAASD,eAAeA;IAI9C,OAAO,eACLE,SAAwB,EACxBC,UAAsB,EACT;QACb,MAAMC,aAAa,IAAIH,WAAWA,CAACC,UAAU,EAAE;QAC/CE,WAAW,IAAI,GAAGF,UAAU,IAAI;QAChCE,WAAW,IAAI,GAAGF,UAAU,OAAO,CAAC,IAAI;QACxCE,WAAW,YAAY,GAAGA,WAAW,gBAAgB,CACnDF,UAAU,OAAO,CAAC,YAAY,EAC9BC;QAEFC,WAAW,KAAK,GAAGF,UAAU,OAAO,CAAC,KAAK;QAC1CE,WAAW,SAAS,GAAGF,UAAU,OAAO,CAAC,SAAS;QAClDE,WAAW,WAAW,GAAGF,UAAU,OAAO,CAAC,YAAY;QACvDE,WAAW,mBAAmB,GAC5BF,UAAU,OAAO,CAAC,qBAAqB,IAAI,EAAE;QAC/CE,WAAW,OAAO,GAAGF,UAAU,OAAO,CAAC,OAAO;QAC9CE,WAAW,QAAQ,GAAGF,UAAU,SAAS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,MAAM,EAAEY,MAAM,EAAE,GAAGC,WAAW,GAAGF;QAEjC,MAAMhB,UAAUA,CAACK,YAAYY,QAAQC;IACvC;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-fields/flow-bot-action.js","sources":["../../../src/content-fields/flow-bot-action.tsx"],"sourcesContent":["import {\n type BotContext,\n BotonicAction,\n EventAction,\n type EventBotAction,\n} from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type { HtBotActionNode } from './hubtype-fields'\n\nexport class FlowBotAction extends ContentFieldsBase {\n public code: string\n public payload: string\n\n static fromHubtypeCMS(\n cmsBotAction: HtBotActionNode,\n cmsApi: FlowBuilderApi\n ): FlowBotAction {\n const newBotAction = new FlowBotAction(cmsBotAction.id)\n newBotAction.code = cmsBotAction.code\n newBotAction.payload = cmsApi.createPayloadWithParams(cmsBotAction)\n newBotAction.followUp = cmsBotAction.follow_up\n\n return newBotAction\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n const eventBotAction: EventBotAction = {\n action: EventAction.BotAction,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowNodeIsMeaningful: false,\n payload: this.payload,\n }\n const { action, ...eventArgs } = eventBotAction\n await trackEvent(botContext, action, eventArgs)\n }\n\n doBotAction(botContext: ActionRequest): void {\n botContext.session._botonic_action = `${BotonicAction.Redirect}:${this.payload}`\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n this.doBotAction(botContext)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic(): JSX.Element {\n return <></>\n }\n}\n"],"names":["BotonicAction","EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","ContentFieldsBase","FlowBotAction","cmsBotAction","cmsApi","newBotAction","botContext","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","eventBotAction","action","eventArgs"],"mappings":";;;;;;;;;;AAKsB;AAOF;AACqC;AAGlD,MAAMK,aAAaA,SAASD,iBAAiBA;IAIlD,OAAO,eACLE,YAA6B,EAC7BC,MAAsB,EACP;QACf,MAAMC,eAAe,IAAIH,aAAaA,CAACC,aAAa,EAAE;QACtDE,aAAa,IAAI,GAAGF,aAAa,IAAI;QACrCE,aAAa,OAAO,GAAGD,OAAO,uBAAuB,CAACD;QACtDE,aAAa,QAAQ,GAAGF,aAAa,SAAS;QAE9C,OAAOE;IACT;IAEA,MAAM,UAAUC,UAAsB,EAAiB;QACrD,MAAM,EAAEC,YAAY,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GACrEZ,yCAAyCA,CAACO,YAAY,IAAI,CAAC,EAAE;QAC/D,MAAMM,iBAAiC;YACrC,QAAQd,qBAAqB;YAC7BS;YACAC;YACAC;YACAC;YACAC;YACA,sBAAsB;YACtB,SAAS,IAAI,CAAC,OAAO;QACvB;QACA,MAAM,EAAEE,MAAM,EAAE,GAAGC,WAAW,GAAGF;QACjC,MAAMZ,UAAUA,CAACM,YAAYO,QAAQC;IACvC;IAEA,YAAYR,UAAyB,EAAQ;QAC3CA,WAAW,OAAO,CAAC,eAAe,GAAG,GAAGT,sBAAsB,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE;IAClF;IAEA,MAAM,eAAeS,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,aAAa,CAACA,YAAY,IAAI;QACzC,IAAI,CAAC,WAAW,CAACA;QACjB,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,YAAyB;QACvB,qBAAO;IACT;AACF"}