@botonic/nx-plugin 2.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/CHANGELOG.md +420 -0
  2. package/README.md +279 -0
  3. package/executors.json +55 -0
  4. package/generators.json +61 -0
  5. package/migrations.json +40 -0
  6. package/package.json +54 -0
  7. package/src/cursor-commands/update-bot.md +114 -0
  8. package/src/cursor-commands/update-botonic.md +63 -0
  9. package/src/executors/build-node-app/executor.d.ts +5 -0
  10. package/src/executors/build-node-app/executor.js +65 -0
  11. package/src/executors/build-node-app/schema.d.js +16 -0
  12. package/src/executors/build-node-app/schema.json +25 -0
  13. package/src/executors/delete-bot/executor.d.ts +5 -0
  14. package/src/executors/delete-bot/executor.js +112 -0
  15. package/src/executors/delete-bot/schema.d.js +16 -0
  16. package/src/executors/delete-bot/schema.json +35 -0
  17. package/src/executors/deploy-local-runtime/executor.d.ts +5 -0
  18. package/src/executors/deploy-local-runtime/executor.js +144 -0
  19. package/src/executors/deploy-local-runtime/schema.d.js +16 -0
  20. package/src/executors/deploy-local-runtime/schema.json +34 -0
  21. package/src/executors/deploy-netlify-snapshot/executor.d.ts +8 -0
  22. package/src/executors/deploy-netlify-snapshot/executor.js +79 -0
  23. package/src/executors/deploy-netlify-snapshot/schema.d.js +16 -0
  24. package/src/executors/deploy-netlify-snapshot/schema.json +31 -0
  25. package/src/executors/deploy-to-hubtype/executor.d.ts +5 -0
  26. package/src/executors/deploy-to-hubtype/executor.js +308 -0
  27. package/src/executors/deploy-to-hubtype/schema.d.js +16 -0
  28. package/src/executors/deploy-to-hubtype/schema.json +31 -0
  29. package/src/executors/e2e-webchat/botonic-package-publish.spec.ts +84 -0
  30. package/src/executors/e2e-webchat/executor.d.ts +5 -0
  31. package/src/executors/e2e-webchat/executor.js +134 -0
  32. package/src/executors/e2e-webchat/schema.d.js +16 -0
  33. package/src/executors/e2e-webchat/schema.json +35 -0
  34. package/src/executors/integrate-provider/executor.d.ts +5 -0
  35. package/src/executors/integrate-provider/executor.js +155 -0
  36. package/src/executors/integrate-provider/schema.d.js +16 -0
  37. package/src/executors/integrate-provider/schema.json +30 -0
  38. package/src/executors/login-to-hubtype/executor.d.ts +5 -0
  39. package/src/executors/login-to-hubtype/executor.js +79 -0
  40. package/src/executors/login-to-hubtype/schema.d.js +16 -0
  41. package/src/executors/login-to-hubtype/schema.json +25 -0
  42. package/src/executors/logout-from-hubtype/executor.d.ts +3 -0
  43. package/src/executors/logout-from-hubtype/executor.js +54 -0
  44. package/src/executors/logout-from-hubtype/schema.d.js +16 -0
  45. package/src/executors/logout-from-hubtype/schema.json +9 -0
  46. package/src/executors/run-lambda/executor.d.ts +5 -0
  47. package/src/executors/run-lambda/executor.js +65 -0
  48. package/src/executors/run-lambda/schema.d.js +16 -0
  49. package/src/executors/run-lambda/schema.json +20 -0
  50. package/src/executors/serve-bot/executor.d.ts +5 -0
  51. package/src/executors/serve-bot/executor.js +330 -0
  52. package/src/executors/serve-bot/schema.d.js +16 -0
  53. package/src/executors/serve-bot/schema.json +40 -0
  54. package/src/generators/action/files/__name__.spec.ts.template +15 -0
  55. package/src/generators/action/files/__name__.ts.template +15 -0
  56. package/src/generators/action/generator.d.ts +4 -0
  57. package/src/generators/action/generator.js +112 -0
  58. package/src/generators/action/schema.d.ts +7 -0
  59. package/src/generators/action/schema.js +16 -0
  60. package/src/generators/action/schema.json +43 -0
  61. package/src/generators/bot-app/files/.eslintrc.json.template +18 -0
  62. package/src/generators/bot-app/files/README.md.template +148 -0
  63. package/src/generators/bot-app/files/src/client/custom-messages/index.ts.template +2 -0
  64. package/src/generators/bot-app/files/src/client/webchat/index.html.template +35 -0
  65. package/src/generators/bot-app/files/src/client/webchat/index.tsx.template +107 -0
  66. package/src/generators/bot-app/files/src/client/webchat/styles.css.template +17 -0
  67. package/src/generators/bot-app/files/src/client/webchat/webchat-tokens-overrides.css.template +2 -0
  68. package/src/generators/bot-app/files/src/client/webviews/app.tsx.template +8 -0
  69. package/src/generators/bot-app/files/src/client/webviews/index.html.template +32 -0
  70. package/src/generators/bot-app/files/src/client/webviews/index.tsx.template +18 -0
  71. package/src/generators/bot-app/files/src/server/bot/actions/index.ts.template +2 -0
  72. package/src/generators/bot-app/files/src/server/bot/actions/not-found.ts.template +13 -0
  73. package/src/generators/bot-app/files/src/server/bot/actions/welcome.ts.template +13 -0
  74. package/src/generators/bot-app/files/src/server/bot/index.ts.template +43 -0
  75. package/src/generators/bot-app/files/src/server/bot/plugins/ai-agents/index.ts.template +30 -0
  76. package/src/generators/bot-app/files/src/server/bot/plugins/flow-builder/index.ts.template +28 -0
  77. package/src/generators/bot-app/files/src/server/bot/plugins/index.ts.template +11 -0
  78. package/src/generators/bot-app/files/src/server/bot/routes.ts.template +23 -0
  79. package/src/generators/bot-app/files/src/server/bot/tools/index.ts.template +5 -0
  80. package/src/generators/bot-app/files/src/server/bot/tracking.ts.template +35 -0
  81. package/src/generators/bot-app/files/src/server/bot/types.ts.template +4 -0
  82. package/src/generators/bot-app/files/src/server/bot/utils.ts.template +9 -0
  83. package/src/generators/bot-app/files/src/server/lambda/handler.js.template +24 -0
  84. package/src/generators/bot-app/files/src/server/lambda/package.json +20 -0
  85. package/src/generators/bot-app/files/src/server/lambda/template.yaml.template +20 -0
  86. package/src/generators/bot-app/files/src/shared/constants.ts.template +12 -0
  87. package/src/generators/bot-app/files/vite/base-client.config.ts.template +14 -0
  88. package/src/generators/bot-app/files/vite/base.config.ts.template +20 -0
  89. package/src/generators/bot-app/files/vite/build.config.ts.template +65 -0
  90. package/src/generators/bot-app/files/vite/node.config.ts.template +41 -0
  91. package/src/generators/bot-app/files/vite/plugins/move-html.plugin.ts.template +36 -0
  92. package/src/generators/bot-app/files/vite/webchat.config.ts.template +58 -0
  93. package/src/generators/bot-app/files/vite/webviews.config.ts.template +57 -0
  94. package/src/generators/bot-app/files/vite.config.ts.template +36 -0
  95. package/src/generators/bot-app/generator.d.ts +4 -0
  96. package/src/generators/bot-app/generator.js +294 -0
  97. package/src/generators/bot-app/schema.d.ts +6 -0
  98. package/src/generators/bot-app/schema.js +16 -0
  99. package/src/generators/bot-app/schema.json +36 -0
  100. package/src/generators/bot-app-migrations/migrate-fix-css-code-split/generator.d.ts +5 -0
  101. package/src/generators/bot-app-migrations/migrate-fix-css-code-split/generator.js +92 -0
  102. package/src/generators/bot-app-migrations/migrate-fix-css-code-split/schema.json +15 -0
  103. package/src/generators/bot-app-migrations/migrate-pnpm-compat/generator.d.ts +5 -0
  104. package/src/generators/bot-app-migrations/migrate-pnpm-compat/generator.js +97 -0
  105. package/src/generators/bot-app-migrations/migrate-pnpm-compat/schema.json +15 -0
  106. package/src/generators/bot-app-migrations/migrate-webchat-trigger/generator.d.ts +5 -0
  107. package/src/generators/bot-app-migrations/migrate-webchat-trigger/generator.js +165 -0
  108. package/src/generators/bot-app-migrations/migrate-webchat-trigger/schema.json +15 -0
  109. package/src/generators/custom-message/files/__name__-output.ts.template +21 -0
  110. package/src/generators/custom-message/files/__name__.spec.tsx.template +27 -0
  111. package/src/generators/custom-message/files/__name__.tsx.template +18 -0
  112. package/src/generators/custom-message/generator.d.ts +4 -0
  113. package/src/generators/custom-message/generator.js +235 -0
  114. package/src/generators/custom-message/schema.d.ts +7 -0
  115. package/src/generators/custom-message/schema.js +16 -0
  116. package/src/generators/custom-message/schema.json +44 -0
  117. package/src/generators/preset/files/.cursor/commands/update-bot.md +5 -0
  118. package/src/generators/preset/files/.cursor/commands/update-botonic.md +5 -0
  119. package/src/generators/preset/files/.cursor/scripts/update-bot/discover-bots.sh +67 -0
  120. package/src/generators/preset/files/.cursor/scripts/update-bot/find-migration-guides.sh +70 -0
  121. package/src/generators/preset/files/.cursor/skills/botonic-action/SKILL.md +167 -0
  122. package/src/generators/preset/files/.cursor/skills/botonic-custom-message/SKILL.md +231 -0
  123. package/src/generators/preset/files/.cursor/skills/botonic-webview/SKILL.md +179 -0
  124. package/src/generators/preset/files/.env.prod.template +2 -0
  125. package/src/generators/preset/files/.env.template +2 -0
  126. package/src/generators/preset/files/.npmrc.template +1 -0
  127. package/src/generators/preset/files/README.md.template +174 -0
  128. package/src/generators/preset/files/nx.json +66 -0
  129. package/src/generators/preset/files/package.json +26 -0
  130. package/src/generators/preset/files/tsconfig.base.json +27 -0
  131. package/src/generators/preset/files/tsconfig.base.json.template +27 -0
  132. package/src/generators/preset/files/tsconfig.json +9 -0
  133. package/src/generators/preset/generator.d.ts +4 -0
  134. package/src/generators/preset/generator.js +127 -0
  135. package/src/generators/preset/schema.d.ts +6 -0
  136. package/src/generators/preset/schema.js +16 -0
  137. package/src/generators/preset/schema.json +50 -0
  138. package/src/generators/remove-custom-message/generator.d.ts +4 -0
  139. package/src/generators/remove-custom-message/generator.js +259 -0
  140. package/src/generators/remove-custom-message/schema.d.ts +6 -0
  141. package/src/generators/remove-custom-message/schema.js +16 -0
  142. package/src/generators/remove-custom-message/schema.json +39 -0
  143. package/src/generators/shared/bot-app-utils.d.ts +25 -0
  144. package/src/generators/shared/bot-app-utils.js +209 -0
  145. package/src/generators/webview/files/__name__.spec.tsx.template +20 -0
  146. package/src/generators/webview/files/__name__.tsx.template +19 -0
  147. package/src/generators/webview/generator.d.ts +4 -0
  148. package/src/generators/webview/generator.js +179 -0
  149. package/src/generators/webview/schema.d.ts +5 -0
  150. package/src/generators/webview/schema.js +16 -0
  151. package/src/generators/webview/schema.json +34 -0
  152. package/src/index.d.ts +7 -0
  153. package/src/index.js +56 -0
  154. package/src/lib/api-service.d.ts +110 -0
  155. package/src/lib/api-service.js +591 -0
  156. package/src/lib/bot-config.d.ts +30 -0
  157. package/src/lib/bot-config.js +203 -0
  158. package/src/lib/cloudflared-tunnel.d.ts +29 -0
  159. package/src/lib/cloudflared-tunnel.js +95 -0
  160. package/src/lib/constants.d.ts +13 -0
  161. package/src/lib/constants.js +60 -0
  162. package/src/lib/credentials-handler.d.ts +40 -0
  163. package/src/lib/credentials-handler.js +115 -0
  164. package/src/lib/index.d.ts +10 -0
  165. package/src/lib/index.js +47 -0
  166. package/src/lib/interfaces.d.ts +49 -0
  167. package/src/lib/interfaces.js +16 -0
  168. package/src/lib/util/executor-helpers.d.ts +97 -0
  169. package/src/lib/util/executor-helpers.js +574 -0
  170. package/src/lib/util/file-system.d.ts +8 -0
  171. package/src/lib/util/file-system.js +65 -0
  172. package/src/lib/util/sam-container-cleanup.d.ts +11 -0
  173. package/src/lib/util/sam-container-cleanup.js +55 -0
  174. package/src/lib/util/sam-template.d.ts +9 -0
  175. package/src/lib/util/sam-template.js +71 -0
  176. package/src/lib/util/system.d.ts +1 -0
  177. package/src/lib/util/system.js +30 -0
  178. package/src/migrations/add-botonic-update-bots-skill/add-botonic-update-bots-skill.migration.d.ts +2 -0
  179. package/src/migrations/add-botonic-update-bots-skill/add-botonic-update-bots-skill.migration.js +52 -0
  180. package/src/migrations/add-botonic-update-bots-skill/add-botonic-update-bots-skill.migration.md +23 -0
  181. package/src/migrations/add-botonic-update-bots-skill/files/.cursor/commands/update-bot.md +5 -0
  182. package/src/migrations/add-botonic-update-bots-skill/files/.cursor/commands/update-botonic.md +5 -0
  183. package/src/migrations/add-botonic-update-bots-skill/files/.cursor/scripts/update-bot/discover-bots.sh +67 -0
  184. package/src/migrations/add-botonic-update-bots-skill/files/.cursor/scripts/update-bot/find-migration-guides.sh +70 -0
  185. package/src/migrations/add-botonic-update-bots-skill/schema.json +5 -0
  186. package/src/migrations/add-lilara-registry/add-lilara-registry.migration.d.ts +2 -0
  187. package/src/migrations/add-lilara-registry/add-lilara-registry.migration.js +49 -0
  188. package/src/migrations/add-lilara-registry/schema.json +5 -0
  189. package/src/migrations/fix-css-code-split/fix-css-code-split.migration.md +45 -0
  190. package/src/migrations/remove-codeartifact-registry/remove-codeartifact-registry.migration.d.ts +2 -0
  191. package/src/migrations/remove-codeartifact-registry/remove-codeartifact-registry.migration.js +59 -0
  192. package/src/migrations/remove-codeartifact-registry/schema.json +5 -0
  193. package/src/migrations/sync-pending-bot-migrations/schema.json +5 -0
  194. package/src/migrations/sync-pending-bot-migrations/sync-pending-bot-migrations.migration.d.ts +2 -0
  195. package/src/migrations/sync-pending-bot-migrations/sync-pending-bot-migrations.migration.js +137 -0
  196. package/src/migrations/sync-pending-bot-migrations/sync-pending-bot-migrations.migration.md +19 -0
  197. package/src/migrations/update-cursor-commands-to-stubs/schema.json +5 -0
  198. package/src/migrations/update-cursor-commands-to-stubs/update-cursor-commands-to-stubs.migration.d.ts +2 -0
  199. package/src/migrations/update-cursor-commands-to-stubs/update-cursor-commands-to-stubs.migration.js +61 -0
  200. package/src/migrations/update-pnpm-workspace-scripts/schema.json +4 -0
  201. package/src/migrations/update-pnpm-workspace-scripts/update-pnpm-workspace-scripts.migration.d.ts +2 -0
  202. package/src/migrations/update-pnpm-workspace-scripts/update-pnpm-workspace-scripts.migration.js +47 -0
  203. package/src/migrations/utils/migration-utils.d.ts +109 -0
  204. package/src/migrations/utils/migration-utils.js +448 -0
  205. package/src/plugin.d.ts +15 -0
  206. package/src/plugin.js +246 -0
@@ -0,0 +1,148 @@
1
+ # <%= className %> Bot
2
+
3
+ A modern Botonic bot application built with TypeScript, Vite, and React.
4
+
5
+ ## 🚀 Getting Started
6
+
7
+ ### Development
8
+
9
+ ```bash
10
+ # Start webchat development server
11
+ pnpm run serve:webchat
12
+
13
+ # Start webviews development server
14
+ pnpm run serve:webviews
15
+
16
+ # Start Lambda development server
17
+ pnpm run serve:lambda
18
+
19
+ # Start all development servers
20
+ pnpm run serve
21
+
22
+ # Build for production
23
+ pnpm run build
24
+
25
+ # Build for Node.js (Lambda)
26
+ pnpm run build:node
27
+
28
+ # Run tests
29
+ pnpm run test
30
+
31
+ # Type checking
32
+ pnpm run typecheck
33
+ ```
34
+
35
+ ## 📁 Project Structure
36
+
37
+ ```
38
+ src/
39
+ ├── client/ # Client-side applications
40
+ │ ├── webchat/ # Webchat interface
41
+ │ └── webviews/ # Webview interfaces
42
+ ├── server/ # Server-side bot logic
43
+ │ ├── bot/ # Bot configuration and actions
44
+ │ └── lambda/ # AWS Lambda handler
45
+ └── shared/ # Shared utilities and config
46
+ ```
47
+
48
+ ## 🔧 Configuration
49
+
50
+ ### Bot Configuration
51
+
52
+ The main bot configuration is in `src/server/bot/index.ts`. This includes:
53
+
54
+ - **Routes**: Define conversation flows
55
+ - **Actions**: Handle user interactions
56
+ - **Locales**: Multi-language support
57
+ - **Plugins**: Extend bot functionality
58
+ - **Theme**: Customize appearance
59
+
60
+ ### Environment Variables
61
+
62
+ Copy the example environment file and customize for your setup:
63
+
64
+ ```bash
65
+ # Copy example environment file
66
+ cp .env.example .env.local
67
+
68
+ # Edit with your values
69
+ vim .env.local
70
+ ```
71
+
72
+ > **Note**: `.env.local` is gitignored and should contain your personal/local values. Never commit this file.
73
+
74
+ ## 🎯 Development Targets
75
+
76
+ ### Webchat (`serve:webchat`)
77
+ - Develops the webchat interface
78
+ - Hot reload enabled
79
+ - React-based UI
80
+
81
+ ### Webviews (`serve:webviews`)
82
+ - Develops custom webview interfaces
83
+ - Interactive forms and displays
84
+ - React-based UI
85
+
86
+ ### Lambda (`serve:lambda`)
87
+ - Local Lambda development with SAM
88
+ - Simulates AWS Lambda environment
89
+ - Automatic rebuild on changes
90
+
91
+ ## 🏗️ Build Process
92
+
93
+ The project uses **Vite** for fast building and development:
94
+
95
+ - **TypeScript**: Full type safety
96
+ - **Project References**: Optimized compilation
97
+ - **Tree Shaking**: Minimal bundle size
98
+ - **Hot Module Replacement**: Fast development
99
+
100
+ ## 🔌 Adding Features
101
+
102
+ ### New Action
103
+ 1. Create action in `src/server/bot/actions/`
104
+ 2. Add route in `src/server/bot/routes.ts`
105
+ 3. Update locales if needed
106
+
107
+ ### New Plugin
108
+ 1. Install plugin: `pnpm install @botonic/plugin-xyz`
109
+ 2. Add to `src/server/bot/plugins.ts`
110
+ 3. Configure in bot config
111
+
112
+ ### New Webview
113
+ 1. Create component in `src/client/webviews/`
114
+ 2. Add routing if needed
115
+ 3. Style with CSS modules
116
+
117
+ ## 📚 Learn More
118
+
119
+ - [Botonic Documentation](https://botonic.io/docs/)
120
+ - [Vite Documentation](https://vitejs.dev/)
121
+ - [TypeScript Project References](https://www.typescriptlang.org/docs/handbook/project-references.html)
122
+ - [Nx Documentation](https://nx.dev/)
123
+
124
+ ## 🚀 Deployment
125
+
126
+ ### AWS Lambda
127
+
128
+ ```bash
129
+ # Build for Lambda
130
+ pnpm run build:node
131
+
132
+ # Deploy with SAM
133
+ cd src/server/lambda
134
+ sam build
135
+ sam deploy --guided
136
+ ```
137
+
138
+ ### Production Build
139
+
140
+ ```bash
141
+ # Build all targets
142
+ pnpm run build
143
+
144
+ # The built files will be in:
145
+ # - dist/client/webchat/ (webchat interface)
146
+ # - dist/client/webviews/ (webview interfaces)
147
+ # - dist/server/ (Lambda function)
148
+ ```
@@ -0,0 +1,2 @@
1
+ export const customMessages = {}
2
+
@@ -0,0 +1,35 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title><%= className %> Webchat</title>
6
+ <base href="/" />
7
+
8
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
9
+ <link rel="icon" type="image/x-icon" href="/favicon.ico" />
10
+ </head>
11
+ <body>
12
+ <div id="webchat-root"></div>
13
+ <script type="module" src="./index.tsx"></script>
14
+ <script type="text/javascript">
15
+ document.addEventListener('DOMContentLoaded', function () {
16
+ var container = document.getElementById('webchat-root')
17
+
18
+ if (container) {
19
+ var params = new URLSearchParams(window.location.search)
20
+ var appId = params.get('appId') || '%VITE_HUBTYPE_APP_ID%'
21
+ var storageKey = params.get('storageKey')
22
+ var webchatConfig = { appId: appId }
23
+ if (storageKey) {
24
+ webchatConfig.storage = { keyPrefix: storageKey }
25
+ }
26
+
27
+ window.botonic.render(container, webchatConfig, {
28
+ title: '<%= className %>',
29
+ placeholder: 'Type your message...',
30
+ })
31
+ }
32
+ })
33
+ </script>
34
+ </body>
35
+ </html>
@@ -0,0 +1,107 @@
1
+ import './styles.css'
2
+
3
+ import type { WebchatConfig } from '@botonic/webchat-core'
4
+ import type { WebchatTriggerProps } from '@botonic/webchat-react/trigger'
5
+ import { WebchatTrigger } from '@botonic/webchat-react/trigger'
6
+ import React from 'react'
7
+ import { createRoot } from 'react-dom/client'
8
+
9
+ import { customMessages } from '../custom-messages'
10
+
11
+ interface WebchatOptions {
12
+ title: string
13
+ placeholder: string
14
+ }
15
+
16
+ declare global {
17
+ interface Window {
18
+ botonic: {
19
+ render: (
20
+ container: HTMLElement,
21
+ webchatConfig: WebchatConfig,
22
+ options: WebchatOptions
23
+ ) => void
24
+ // Ready state
25
+ ready: Promise<void>
26
+ isReady: () => boolean
27
+ // All other methods from PublicWebchatController will be available after ready
28
+ [key: string]: unknown
29
+ }
30
+ }
31
+ }
32
+
33
+ function App({
34
+ webchatConfig,
35
+ options,
36
+ }: {
37
+ webchatConfig: WebchatConfig
38
+ options: WebchatOptions
39
+ }) {
40
+ // Default avatar SVG
41
+ const defaultAvatarSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="17" height="18" viewBox="0 0 17 18" fill="none">
42
+ <circle cx="8.5" cy="9" r="8.5" fill="#24252C"/>
43
+ <path d="M5.9647 5.03898C5.9647 4.61514 5.80479 4.45386 5.36004 4.45386C4.90405 4.45386 4.74414 4.61639 4.74414 5.03898C4.74414 5.46281 4.90405 5.6241 5.36004 5.6241C5.80479 5.6241 5.9647 5.46281 5.9647 5.03898Z" fill="white"/>
44
+ <path d="M11.1872 4.45386C10.7312 4.45386 10.5713 4.61639 10.5713 5.03898C10.5713 5.46281 10.7312 5.6241 11.1872 5.6241C11.6307 5.6241 11.7919 5.46156 11.7919 5.03898C11.7906 4.61514 11.6307 4.45386 11.1872 4.45386Z" fill="white"/>
45
+ <path d="M10.99 6.47729H10.7063C10.4352 6.47729 10.3365 6.60233 10.2503 6.99995L9.32574 10.8498C9.15332 11.4975 8.95591 11.6726 8.40117 11.6726H8.13005C7.5878 11.6726 7.3779 11.4988 7.20548 10.8498L6.28092 6.99995C6.19471 6.60108 6.1085 6.47729 5.83737 6.47729H5.55376C5.30762 6.47729 5.19643 6.6636 5.29513 7.04996L6.37962 11.2112C6.56453 11.9339 6.93436 12.2953 7.56406 12.4315C7.72399 12.4691 7.8102 12.5566 7.8102 12.7304V14.5884C7.8102 14.7997 7.94638 14.9373 8.15504 14.9373H8.38993C8.58733 14.9373 8.73476 14.7997 8.73476 14.5884V12.7316C8.73476 12.5566 8.82097 12.4703 8.9809 12.4328C9.59686 12.2953 9.96793 11.9339 10.1641 11.2124L11.2486 7.05121C11.3473 6.66485 11.2361 6.47729 10.99 6.47729Z" fill="white"/>
46
+ </svg>`
47
+
48
+ const avatarConfig = {
49
+ bot: {
50
+ placement: 'bubble' as const,
51
+ svg: defaultAvatarSvg,
52
+ alt: options.title || '<%= className %>',
53
+ showName: true,
54
+ name: options.title || '<%= className %>',
55
+ },
56
+ }
57
+
58
+ // Handle webchat ready – full control over when/how to open
59
+ const handleReady = React.useCallback<
60
+ NonNullable<WebchatTriggerProps['onReady']>
61
+ >(controller => {
62
+ console.log('🚀 Webchat ready!')
63
+ // Developer decides: open, log, analytics, etc.
64
+ controller.open()
65
+ }, [])
66
+
67
+ return (
68
+ <WebchatTrigger
69
+ appId={webchatConfig.appId}
70
+ position='bottom-right'
71
+ onReady={handleReady}
72
+ webchatConfig={{
73
+ avatarConfig,
74
+ customMessages,
75
+ title: options.title || '<%= className %>',
76
+ placeholder: options.placeholder || 'Message...',
77
+ }}
78
+ />
79
+ )
80
+ }
81
+
82
+ // Higher-order render function that integrates with the existing botonic API
83
+ function renderWebchat(
84
+ container: HTMLElement,
85
+ webchatConfig: WebchatConfig,
86
+ options: WebchatOptions
87
+ ) {
88
+ if (!container) {
89
+ console.error('Webchat container not found:', container)
90
+ return
91
+ }
92
+ const root = createRoot(container)
93
+ root.render(<App webchatConfig={webchatConfig} options={options} />)
94
+ }
95
+
96
+ // Expose render; index.html inline script calls it with appId from URL or %VITE_HUBTYPE_APP_ID% (Vite replaces that in HTML)
97
+ if (typeof window !== 'undefined') {
98
+ if (!window.botonic) {
99
+ window.botonic = {} as Window['botonic']
100
+ }
101
+ window.botonic.render = renderWebchat
102
+
103
+ if (window.self !== window.top) {
104
+ document.documentElement.classList.add('embedded-in-frame')
105
+ document.body.classList.add('embedded-in-frame')
106
+ }
107
+ }
@@ -0,0 +1,17 @@
1
+ /* Import library styles (standard CSS import pattern) */
2
+ @import '@botonic/webchat-react/styles.css';
3
+
4
+ /* Import app-specific token overrides */
5
+ @import './webchat-tokens-overrides.css';
6
+
7
+ /* Global styles for the <%= fileName %> app */
8
+ body {
9
+ margin: 0;
10
+ padding: 0;
11
+ font-family: var(--font-family);
12
+ }
13
+
14
+ #webchat-root {
15
+ width: 100%;
16
+ height: 100vh;
17
+ }
@@ -0,0 +1,8 @@
1
+ export function App() {
2
+ return (
3
+ <div className='app'>
4
+ <h1>Welcome to <%= className %> Webviews</h1>
5
+ <p>This is a sample webview for your bot.</p>
6
+ </div>
7
+ )
8
+ }
@@ -0,0 +1,32 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title><%= className %> Webview</title>
6
+
7
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
8
+ <link rel="icon" type="image/x-icon" href="/favicon.ico" />
9
+ <style>
10
+ body {
11
+ margin: 0px;
12
+ }
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <script>
17
+ ;(function (d, s, id) {
18
+ var js,
19
+ fjs = d.getElementsByTagName(s)[0]
20
+ if (d.getElementById(id)) {
21
+ return
22
+ }
23
+ js = d.createElement(s)
24
+ js.id = id
25
+ js.src = 'https://connect.facebook.net/en_US/messenger.Extensions.js'
26
+ fjs.parentNode.insertBefore(js, fjs)
27
+ })(document, 'script', 'Messenger')
28
+ </script>
29
+ <div id="webviews-root"></div>
30
+ <script type="module" src="./index.tsx"></script>
31
+ </body>
32
+ </html>
@@ -0,0 +1,18 @@
1
+ import { WebviewApp, WebviewDefinition } from '@botonic/webviews'
2
+ import * as ReactDOM from 'react-dom/client'
3
+
4
+ import { WEBVIEWS } from '../../shared/constants'
5
+
6
+ export const webviews: WebviewDefinition[] = [
7
+ // Add your webviews here
8
+ // Example:
9
+ // {
10
+ // path: WEBVIEWS.EXAMPLE,
11
+ // component: ExampleWebview,
12
+ // },
13
+ ]
14
+
15
+ const root = ReactDOM.createRoot(
16
+ document.getElementById('webviews-root') as HTMLElement
17
+ )
18
+ root.render(<WebviewApp webviews={webviews} />)
@@ -0,0 +1,2 @@
1
+ export * from './welcome'
2
+ export * from './not-found'
@@ -0,0 +1,13 @@
1
+ import { BotContext, BotServerMessageFactory } from '@botonic/shared'
2
+
3
+ export async function NotFound({ sendMessage }: BotContext) {
4
+ const message = BotServerMessageFactory.createText({
5
+ text: 'Sorry, I didn\'t understand that.\n\nTry saying "hello" to get started!',
6
+ })
7
+ await sendMessage(message)
8
+
9
+ return {
10
+ status: 200,
11
+ response: 'OK',
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ import { BotContext, BotServerMessageFactory } from '@botonic/shared'
2
+
3
+ export async function Welcome({ sendMessage }: BotContext) {
4
+ const message = BotServerMessageFactory.createText({
5
+ text: `Hello! I'm <%= className %> 🤖\n\nWelcome to your new Botonic bot! You can start building your conversation flow by editing the routes and actions.`,
6
+ })
7
+ await sendMessage(message)
8
+
9
+ return {
10
+ status: 200,
11
+ response: 'OK',
12
+ }
13
+ }
@@ -0,0 +1,43 @@
1
+ // eslint-disable-next-line @nx/enforce-module-boundaries
2
+ import { CoreBot } from '@botonic/core'
3
+ import { BotContext, BotServerMessageFactory } from '@botonic/shared'
4
+
5
+ import { plugins } from './plugins'
6
+ import { routes } from './routes'
7
+
8
+ const DefaultFallbackAction = async ({ sendMessage }: BotContext) => {
9
+ const message = BotServerMessageFactory.createText({
10
+ text: "I don't understand you",
11
+ })
12
+ await sendMessage(message)
13
+
14
+ return {
15
+ status: 200,
16
+ response: 'OK',
17
+ }
18
+ }
19
+
20
+ const defaultRoutes = (botContext: BotContext) => [
21
+ {
22
+ path: '404',
23
+ action: async () => await DefaultFallbackAction(botContext),
24
+ },
25
+ ]
26
+
27
+ export class NodeApp {
28
+ readonly bot: CoreBot
29
+
30
+ constructor(options: any) {
31
+ const config = {
32
+ defaultRoutes,
33
+ ...options,
34
+ }
35
+ this.bot = new CoreBot(config)
36
+ }
37
+
38
+ input(args: any) {
39
+ return this.bot.input(args)
40
+ }
41
+ }
42
+
43
+ export const app = new NodeApp({ routes, plugins })
@@ -0,0 +1,30 @@
1
+ import { AiAgentArgs, BotonicPluginAiAgents } from '@botonic/plugin-ai-agents'
2
+ import { BotContext } from '@botonic/shared'
3
+
4
+ import { customTools } from '../../tools'
5
+ import { BotPlugins } from '../../types'
6
+
7
+ // Only initialize AI agents plugin if Azure OpenAI credentials are configured
8
+ const hasAiAgentsConfig = Boolean(
9
+ process.env.AZURE_OPENAI_API_KEY || process.env.OPENAI_API_KEY
10
+ )
11
+
12
+ export const aiAgentsPlugin = hasAiAgentsConfig
13
+ ? new BotonicPluginAiAgents({
14
+ customTools: customTools,
15
+ })
16
+ : null
17
+
18
+ export async function getAiAgentResponse(
19
+ botContext: BotContext<BotPlugins>,
20
+ aiAgentArgs: AiAgentArgs
21
+ ) {
22
+ const aiAgentPlugin = botContext.plugins.aiAgents
23
+ if (!aiAgentPlugin) {
24
+ throw new Error(
25
+ 'AI Agents plugin is not configured. Please set AZURE_OPENAI_API_KEY or OPENAI_API_KEY environment variable.'
26
+ )
27
+ }
28
+ const response = await aiAgentPlugin.getInference(botContext, aiAgentArgs)
29
+ return response
30
+ }
@@ -0,0 +1,28 @@
1
+ import { AiAgentArgs } from '@botonic/plugin-ai-agents'
2
+ import {
3
+ BotonicPluginFlowBuilder,
4
+ BotonicPluginFlowBuilderOptions,
5
+ FlowBuilderJSONVersion,
6
+ } from '@botonic/plugin-flow-builder'
7
+ import { BotContext } from '@botonic/shared'
8
+
9
+ import { trackEventToHubtypeAnalytics } from '../../tracking'
10
+ import { isLambdaLocal } from '../../utils'
11
+ import { getAiAgentResponse } from '../ai-agents'
12
+
13
+ export const flowBuilderConfig: BotonicPluginFlowBuilderOptions = {
14
+ flowVersion: isLambdaLocal()
15
+ ? FlowBuilderJSONVersion.DRAFT
16
+ : FlowBuilderJSONVersion.LATEST,
17
+ trackEvent: async (botContext: BotContext, eventAction, args) => {
18
+ await trackEventToHubtypeAnalytics(botContext, eventAction, args)
19
+ },
20
+ getAiAgentResponse: async (
21
+ botContext: BotContext,
22
+ aiAgentArgs: AiAgentArgs
23
+ ) => {
24
+ return getAiAgentResponse(botContext, aiAgentArgs)
25
+ },
26
+ }
27
+
28
+ export const flowBuilderPlugin = new BotonicPluginFlowBuilder(flowBuilderConfig)
@@ -0,0 +1,11 @@
1
+ import { BotonicPluginHubtypeAnalytics } from '@botonic/plugin-hubtype-analytics'
2
+
3
+ import { aiAgentsPlugin } from './ai-agents'
4
+ import { flowBuilderPlugin } from './flow-builder'
5
+
6
+ export const plugins = {
7
+ flowBuilder: flowBuilderPlugin,
8
+ // AI Agents plugin is only loaded if AZURE_OPENAI_API_KEY or OPENAI_API_KEY is set
9
+ ...(aiAgentsPlugin && { aiAgents: aiAgentsPlugin }),
10
+ hubtypeAnalytics: new BotonicPluginHubtypeAnalytics(),
11
+ }
@@ -0,0 +1,23 @@
1
+ import { FlowBuilderAction } from '@botonic/plugin-flow-builder'
2
+ import { BotContext } from '@botonic/shared'
3
+
4
+ import { Welcome, NotFound } from './actions'
5
+
6
+ export const routes = (botContext: BotContext) => {
7
+ return [
8
+ {
9
+ text: /^(hi|hello|start|hola)$/i,
10
+ action: async () => await Welcome(botContext),
11
+ },
12
+ {
13
+ path: 'flow-builder',
14
+ text: /.*/,
15
+ payload: /.*/,
16
+ action: async () => await FlowBuilderAction.botonicInit(botContext),
17
+ },
18
+ {
19
+ path: 'not-found',
20
+ action: async () => await NotFound(botContext),
21
+ },
22
+ ]
23
+ }
@@ -0,0 +1,5 @@
1
+ import { CustomTool } from '@botonic/plugin-ai-agents'
2
+
3
+ // Define custom AI agent tools here
4
+ export const customTools: CustomTool[] = []
5
+
@@ -0,0 +1,35 @@
1
+ import {
2
+ BotonicPluginHubtypeAnalytics,
3
+ EventAction,
4
+ HtEventProps,
5
+ } from '@botonic/plugin-hubtype-analytics'
6
+ import { BotContext } from '@botonic/shared'
7
+
8
+ import { BotPlugins } from './types'
9
+
10
+ export async function trackEventToHubtypeAnalytics(
11
+ botContext: BotContext<BotPlugins>,
12
+ eventName: EventAction,
13
+ args: Omit<HtEventProps, 'action'>
14
+ ): Promise<void> {
15
+ const hubtypeAnalyticsPlugin = botContext.plugins.hubtypeAnalytics
16
+ const htEventProps = {
17
+ action: eventName,
18
+ ...args,
19
+ } as HtEventProps
20
+
21
+ if (
22
+ !hubtypeAnalyticsPlugin ||
23
+ !(hubtypeAnalyticsPlugin instanceof BotonicPluginHubtypeAnalytics)
24
+ ) {
25
+ console.log('Hubtype Analytics Plugin not found')
26
+ return
27
+ }
28
+
29
+ const response = await hubtypeAnalyticsPlugin.trackEvent(
30
+ botContext,
31
+ htEventProps
32
+ )
33
+ console.log('TrackEvent Response', response, args)
34
+ return
35
+ }
@@ -0,0 +1,4 @@
1
+ import { plugins } from './plugins'
2
+
3
+ export type BotPlugins = typeof plugins
4
+
@@ -0,0 +1,9 @@
1
+ export function isLambdaLocal(): boolean {
2
+ // AWS SAM sets AWS_SAM_LOCAL when running locally
3
+ // Or if AWS_LAMBDA_FUNCTION_NAME doesn't exist (only exists in real AWS)
4
+ return !!process.env.AWS_SAM_LOCAL || !process.env.AWS_LAMBDA_FUNCTION_NAME
5
+ }
6
+
7
+ export const empty = (object: Record<string, any>): boolean =>
8
+ Object.keys(object).length === 0
9
+
@@ -0,0 +1,24 @@
1
+ 'use strict'
2
+
3
+ /*
4
+ In lambda functions, it only have access to all files the first time it's invoked,
5
+ and placed into memory, after that it only calls the function that have the information
6
+ loadded in memory. For this reason, we initialize the bot the first time, and then we
7
+ only execute the input function
8
+
9
+ https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
10
+ */
11
+ import { app } from './dist/index.js'
12
+
13
+ export const botonic = async (event, aws_context) => {
14
+ const { user_input, context } = event
15
+
16
+ await app.bot.input({
17
+ input: user_input || {},
18
+ session: context || {},
19
+ })
20
+
21
+ return {
22
+ statusCode: 200,
23
+ }
24
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "lambda",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "handler.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "description": "",
13
+ "dependencies": {
14
+ "uuid": "^11.1.0",
15
+ "@openai/agents": "^0.1.11",
16
+ "openai": "^5.23.2",
17
+ "tslib": "^2.3.0",
18
+ "zod": "^3.25.76"
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ AWSTemplateFormatVersion: 2010-09-09
2
+ Description: botonic-lambda
3
+
4
+ Transform:
5
+ - AWS::Serverless-2016-10-31
6
+
7
+ Resources:
8
+ BotonicV2LocalLambda:
9
+ Type: AWS::Serverless::Function
10
+ Properties:
11
+ Handler: handler.botonic
12
+ Runtime: nodejs20.x
13
+ Timeout: 30
14
+ Architectures:
15
+ - x86_64
16
+ Environment:
17
+ Variables:
18
+ STATIC_URL: http://localhost:4202/webviews.html # TODO: This will change in prod for our static assets hosting provider
19
+ AZURE_OPENAI_API_KEY: 'fake'
20
+ AZURE_OPENAI_ENDPOINT: 'fake'