@botpress/adk 1.19.0-beta.9 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/agent-init/agent-project-generator.d.ts +5 -1
  2. package/dist/agent-init/agent-project-generator.d.ts.map +1 -1
  3. package/dist/agent-project/agent-project.d.ts +3 -3
  4. package/dist/agent-project/agent-project.d.ts.map +1 -1
  5. package/dist/agent-project/agent-resolver.d.ts.map +1 -1
  6. package/dist/agent-project/config-writer.d.ts +1 -1
  7. package/dist/agent-project/dependency-state-to-dependencies.d.ts +11 -0
  8. package/dist/agent-project/dependency-state-to-dependencies.d.ts.map +1 -0
  9. package/dist/agent-project/types.d.ts +9 -4
  10. package/dist/agent-project/types.d.ts.map +1 -1
  11. package/dist/agent0/capabilities/commands/adk-build.md +6 -5
  12. package/dist/agent0/capabilities/commands/adk-debug.md +1 -1
  13. package/dist/agent0/capabilities/commands/adk-dev-console.md +1 -1
  14. package/dist/agent0/capabilities/commands/adk-document.md +10 -2
  15. package/dist/agent0/capabilities/commands/adk-eval.md +1 -1
  16. package/dist/agent0/capabilities/commands/adk-explain.md +2 -2
  17. package/dist/agent0/capabilities/commands/adk-init.md +2 -2
  18. package/dist/agent0/capabilities/commands/adk-ship.md +1 -1
  19. package/dist/agent0/capabilities/commands/adk-test.md +3 -3
  20. package/dist/agent0/capabilities/commands/adk-validate.md +3 -3
  21. package/dist/agent0/capabilities/skills/adk/SKILL.md +21 -21
  22. package/dist/agent0/capabilities/skills/adk/references/actions.md +245 -239
  23. package/dist/agent0/capabilities/skills/adk/references/advanced-patterns.md +185 -218
  24. package/dist/agent0/capabilities/skills/adk/references/agent-config.md +74 -71
  25. package/dist/agent0/capabilities/skills/adk/references/assets.md +45 -48
  26. package/dist/agent0/capabilities/skills/adk/references/autonomous-execution.md +40 -46
  27. package/dist/agent0/capabilities/skills/adk/references/cli.md +17 -7
  28. package/dist/agent0/capabilities/skills/adk/references/context-api.md +98 -94
  29. package/dist/agent0/capabilities/skills/adk/references/conversation-lifecycle.md +65 -62
  30. package/dist/agent0/capabilities/skills/adk/references/conversations.md +395 -385
  31. package/dist/agent0/capabilities/skills/adk/references/custom-components.md +1 -1
  32. package/dist/agent0/capabilities/skills/adk/references/desk.md +236 -234
  33. package/dist/agent0/capabilities/skills/adk/references/explain-config.md +54 -37
  34. package/dist/agent0/capabilities/skills/adk/references/files.md +301 -306
  35. package/dist/agent0/capabilities/skills/adk/references/integration-actions.md +211 -214
  36. package/dist/agent0/capabilities/skills/adk/references/integrations.md +33 -31
  37. package/dist/agent0/capabilities/skills/adk/references/interfaces.md +13 -12
  38. package/dist/agent0/capabilities/skills/adk/references/knowledge-bases.md +98 -111
  39. package/dist/agent0/capabilities/skills/adk/references/mcp-server.md +6 -0
  40. package/dist/agent0/capabilities/skills/adk/references/messages.md +280 -256
  41. package/dist/agent0/capabilities/skills/adk/references/model-configuration.md +52 -49
  42. package/dist/agent0/capabilities/skills/adk/references/patterns-mistakes.md +102 -101
  43. package/dist/agent0/capabilities/skills/adk/references/plugins.md +15 -15
  44. package/dist/agent0/capabilities/skills/adk/references/tables.md +204 -210
  45. package/dist/agent0/capabilities/skills/adk/references/tags.md +141 -143
  46. package/dist/agent0/capabilities/skills/adk/references/tools.md +191 -199
  47. package/dist/agent0/capabilities/skills/adk/references/triggers.md +331 -336
  48. package/dist/agent0/capabilities/skills/adk/references/workflow-steps.md +132 -96
  49. package/dist/agent0/capabilities/skills/adk/references/workflows.md +479 -464
  50. package/dist/agent0/capabilities/skills/adk/references/zai-agent-reference.md +127 -129
  51. package/dist/agent0/capabilities/skills/adk/references/zai-complete-guide.md +255 -276
  52. package/dist/agent0/capabilities/skills/adk-debugger/SKILL.md +21 -17
  53. package/dist/agent0/capabilities/skills/adk-debugger/references/common-failures.md +25 -25
  54. package/dist/agent0/capabilities/skills/adk-debugger/references/conversation-analysis.md +49 -41
  55. package/dist/agent0/capabilities/skills/adk-debugger/references/debug-workflow.md +20 -14
  56. package/dist/agent0/capabilities/skills/adk-debugger/references/llm-debugging.md +13 -13
  57. package/dist/agent0/capabilities/skills/adk-debugger/references/trace-summarization.md +18 -18
  58. package/dist/agent0/capabilities/skills/adk-debugger/references/traces-and-logs.md +67 -67
  59. package/dist/agent0/capabilities/skills/adk-dev-console/SKILL.md +36 -36
  60. package/dist/agent0/capabilities/skills/adk-dev-console/references/agent-steps.md +14 -6
  61. package/dist/agent0/capabilities/skills/adk-dev-console/references/multi-agent-dashboard.md +13 -13
  62. package/dist/agent0/capabilities/skills/adk-dev-console/references/pages.md +18 -0
  63. package/dist/agent0/capabilities/skills/adk-docs/SKILL.md +13 -13
  64. package/dist/agent0/capabilities/skills/adk-docs/references/doc-standards.md +15 -0
  65. package/dist/agent0/capabilities/skills/adk-evals/SKILL.md +29 -23
  66. package/dist/agent0/capabilities/skills/adk-evals/references/eval-format.md +31 -23
  67. package/dist/agent0/capabilities/skills/adk-evals/references/test-patterns.md +25 -36
  68. package/dist/agent0/capabilities/skills/adk-evals/references/testing-workflow.md +6 -4
  69. package/dist/agent0/index.js +41 -19
  70. package/dist/agent0/index.js.map +7 -7
  71. package/dist/agent0/runtime/client.d.ts +2 -0
  72. package/dist/agent0/runtime/client.d.ts.map +1 -1
  73. package/dist/agent0/runtime/engine.d.ts +2 -1
  74. package/dist/agent0/runtime/engine.d.ts.map +1 -1
  75. package/dist/agent0/runtime/process.d.ts +1 -0
  76. package/dist/agent0/runtime/process.d.ts.map +1 -1
  77. package/dist/assets/manager.d.ts +3 -0
  78. package/dist/assets/manager.d.ts.map +1 -1
  79. package/dist/auth/credentials.d.ts +1 -1
  80. package/dist/bot-generator/generator.d.ts +22 -0
  81. package/dist/bot-generator/generator.d.ts.map +1 -1
  82. package/dist/bot-generator/plugin-sync.d.ts.map +1 -1
  83. package/dist/commands/base-command.d.ts +1 -0
  84. package/dist/commands/base-command.d.ts.map +1 -1
  85. package/dist/commands/bp-dev-command.d.ts +1 -1
  86. package/dist/commands/bp-dev-command.d.ts.map +1 -1
  87. package/dist/commands/bp-dev-stderr.d.ts +9 -0
  88. package/dist/commands/bp-dev-stderr.d.ts.map +1 -1
  89. package/dist/commands/index.d.ts +1 -0
  90. package/dist/commands/index.d.ts.map +1 -1
  91. package/dist/dependencies/catalog/catalog-service.d.ts +53 -0
  92. package/dist/dependencies/catalog/catalog-service.d.ts.map +1 -0
  93. package/dist/dependencies/catalog/client-factory.d.ts +33 -0
  94. package/dist/dependencies/catalog/client-factory.d.ts.map +1 -0
  95. package/dist/dependencies/catalog/integration-source.d.ts +34 -0
  96. package/dist/dependencies/catalog/integration-source.d.ts.map +1 -0
  97. package/dist/dependencies/catalog/interface-source.d.ts +23 -0
  98. package/dist/dependencies/catalog/interface-source.d.ts.map +1 -0
  99. package/dist/dependencies/catalog/plugin-source.d.ts +49 -0
  100. package/dist/dependencies/catalog/plugin-source.d.ts.map +1 -0
  101. package/dist/dependencies/catalog/resolution-cache.d.ts +76 -0
  102. package/dist/dependencies/catalog/resolution-cache.d.ts.map +1 -0
  103. package/dist/dependencies/dependency-manager.d.ts +31 -16
  104. package/dist/dependencies/dependency-manager.d.ts.map +1 -1
  105. package/dist/dependencies/errors.d.ts +2 -2
  106. package/dist/dependencies/errors.d.ts.map +1 -1
  107. package/dist/dependencies/index.d.ts +5 -4
  108. package/dist/dependencies/index.d.ts.map +1 -1
  109. package/dist/dependencies/index.js +2089 -1670
  110. package/dist/dependencies/index.js.map +37 -30
  111. package/dist/dependencies/legacy-lock-file.d.ts +15 -0
  112. package/dist/dependencies/legacy-lock-file.d.ts.map +1 -0
  113. package/dist/dependencies/migration.d.ts +19 -0
  114. package/dist/dependencies/migration.d.ts.map +1 -1
  115. package/dist/dependencies/resolvers/integration-resolver.d.ts +4 -3
  116. package/dist/dependencies/resolvers/integration-resolver.d.ts.map +1 -1
  117. package/dist/dependencies/resolvers/plugin-resolver.d.ts +4 -4
  118. package/dist/dependencies/resolvers/plugin-resolver.d.ts.map +1 -1
  119. package/dist/dependencies/snapshot-store.d.ts +59 -0
  120. package/dist/dependencies/snapshot-store.d.ts.map +1 -0
  121. package/dist/dependencies/status-resolver.d.ts +36 -0
  122. package/dist/dependencies/status-resolver.d.ts.map +1 -0
  123. package/dist/dependencies/status.d.ts +214 -0
  124. package/dist/dependencies/status.d.ts.map +1 -0
  125. package/dist/dependencies/types.d.ts +380 -29
  126. package/dist/dependencies/types.d.ts.map +1 -1
  127. package/dist/file-watcher/watcher.d.ts +21 -5
  128. package/dist/file-watcher/watcher.d.ts.map +1 -1
  129. package/dist/generators/action-types.d.ts.map +1 -1
  130. package/dist/generators/client-wrapper.d.ts.map +1 -1
  131. package/dist/index.d.ts +4 -5
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.js +3134 -2226
  134. package/dist/index.js.map +55 -48
  135. package/dist/integrations/config-utils.d.ts +11 -7
  136. package/dist/integrations/config-utils.d.ts.map +1 -1
  137. package/dist/integrations/hub-cache.d.ts +0 -58
  138. package/dist/integrations/hub-cache.d.ts.map +1 -1
  139. package/dist/integrations/index.d.ts +1 -3
  140. package/dist/integrations/index.d.ts.map +1 -1
  141. package/dist/integrations/manager.d.ts +19 -53
  142. package/dist/integrations/manager.d.ts.map +1 -1
  143. package/dist/interfaces/enhanced-cache.d.ts +7 -7
  144. package/dist/interfaces/enhanced-cache.d.ts.map +1 -1
  145. package/dist/interfaces/manager.d.ts +11 -17
  146. package/dist/interfaces/manager.d.ts.map +1 -1
  147. package/dist/knowledge/manager.d.ts +3 -0
  148. package/dist/knowledge/manager.d.ts.map +1 -1
  149. package/dist/plugins/index.d.ts +0 -1
  150. package/dist/plugins/index.d.ts.map +1 -1
  151. package/dist/plugins/manager.d.ts +16 -48
  152. package/dist/plugins/manager.d.ts.map +1 -1
  153. package/dist/preflight/checker.d.ts +6 -1
  154. package/dist/preflight/checker.d.ts.map +1 -1
  155. package/dist/preflight/dependency-gate.d.ts +37 -0
  156. package/dist/preflight/dependency-gate.d.ts.map +1 -0
  157. package/dist/preflight/index.d.ts +2 -1
  158. package/dist/preflight/index.d.ts.map +1 -1
  159. package/dist/preflight/types.d.ts +18 -0
  160. package/dist/preflight/types.d.ts.map +1 -1
  161. package/dist/runner/script-runner.d.ts.map +1 -1
  162. package/dist/tables/table-manager.d.ts +3 -0
  163. package/dist/tables/table-manager.d.ts.map +1 -1
  164. package/dist/templates/README.md +23 -13
  165. package/dist/templates/blank/agent.config.ts +3 -3
  166. package/dist/templates/blank/src/triggers/index.ts +1 -1
  167. package/dist/templates/botpress-desk/evals/index.eval.ts +1 -1
  168. package/dist/templates/botpress-desk/src/triggers/index.ts +1 -1
  169. package/dist/templates/crm-enrichment/README.md +3 -3
  170. package/dist/templates/crm-enrichment/agent.config.ts +2 -2
  171. package/dist/templates/crm-enrichment/src/conversations/index.ts +1 -1
  172. package/dist/templates/hello-world/agent.config.ts +3 -3
  173. package/dist/templates/hello-world/src/triggers/index.ts +1 -1
  174. package/dist/templates/knowledge-assistant/src/triggers/index.ts +1 -1
  175. package/dist/templates/template.config.json +3 -3
  176. package/dist/utils/ids.d.ts +10 -0
  177. package/dist/utils/ids.d.ts.map +1 -1
  178. package/dist/workspace/workspace-cache.d.ts +2 -1
  179. package/dist/workspace/workspace-cache.d.ts.map +1 -1
  180. package/package.json +3 -3
  181. package/dist/agent-project/lock-to-dependencies.d.ts +0 -11
  182. package/dist/agent-project/lock-to-dependencies.d.ts.map +0 -1
  183. package/dist/dependencies/lock-file.d.ts +0 -15
  184. package/dist/dependencies/lock-file.d.ts.map +0 -1
  185. package/dist/integrations/enhanced-cache.d.ts +0 -53
  186. package/dist/integrations/enhanced-cache.d.ts.map +0 -1
  187. package/dist/plugins/enhanced-cache.d.ts +0 -53
  188. package/dist/plugins/enhanced-cache.d.ts.map +0 -1
  189. package/dist/templates/blank/package.json +0 -17
  190. package/dist/templates/blank/tsconfig.json +0 -25
  191. package/dist/templates/botpress-desk/package.json +0 -17
  192. package/dist/templates/crm-enrichment/package.json +0 -18
  193. package/dist/templates/crm-enrichment/tsconfig.json +0 -25
  194. package/dist/templates/hello-world/package.json +0 -18
  195. package/dist/templates/hello-world/tsconfig.json +0 -25
  196. package/dist/templates/knowledge-assistant/package.json +0 -18
  197. package/dist/templates/knowledge-assistant/tsconfig.json +0 -25
  198. package/dist/templates/slack-triage/package.json +0 -18
  199. package/dist/templates/slack-triage/tsconfig.json +0 -25
@@ -5,6 +5,7 @@ Understanding how to send messages and events is critical for building conversat
5
5
  ## Table of Contents
6
6
 
7
7
  **Quick Links:**
8
+
8
9
  - [Core Concepts](#core-concepts) - Messages vs Events, Agnostic vs Channel-Specific
9
10
  - [Sending Messages in Conversations](#sending-messages-in-conversations) - Using `conversation.send()`
10
11
  - [Message Metadata](#message-metadata-chat-integration) - Adding custom data to messages
@@ -23,12 +24,14 @@ Understanding how to send messages and events is critical for building conversat
23
24
  ### Messages vs Events
24
25
 
25
26
  **Messages** are persistent conversation history items that users can see:
27
+
26
28
  - Appear in chat history
27
29
  - Survive page reloads
28
30
  - Part of conversation context
29
31
  - Sent using `conversation.send()` in conversations
30
32
 
31
33
  **Events** are ephemeral signals that don't persist:
34
+
32
35
  - NOT in conversation history
33
36
  - Lost on page reload
34
37
  - Used for real-time notifications
@@ -37,10 +40,12 @@ Understanding how to send messages and events is critical for building conversat
37
40
  ### Agnostic vs Channel-Specific
38
41
 
39
42
  **Agnostic Messages** work across multiple channels (defined in `@botpress/sdk`):
43
+
40
44
  - `text`, `image`, `audio`, `video`, `file`, `location`
41
45
  - `card`, `carousel`, `choice`, `dropdown`, `bloc`, `markdown`
42
46
 
43
47
  **Channel-Specific Messages** only work in specific integrations:
48
+
44
49
  - `customComponent` (webchat only)
45
50
  - Platform-specific fields (e.g., Slack threads)
46
51
 
@@ -51,19 +56,19 @@ Understanding how to send messages and events is critical for building conversat
51
56
  In conversation handlers, use `conversation.send()`:
52
57
 
53
58
  ```typescript
54
- import { Conversation } from "@botpress/runtime";
59
+ import { Conversation } from '@botpress/runtime'
55
60
 
56
61
  export const Chat = new Conversation({
57
- channel: "chat.channel",
62
+ channel: 'chat.channel',
58
63
 
59
64
  async handler({ message, conversation }) {
60
65
  // Send a message
61
66
  await conversation.send({
62
- type: "text",
63
- payload: { text: "Hello!" }
64
- });
65
- }
66
- });
67
+ type: 'text',
68
+ payload: { text: 'Hello!' },
69
+ })
70
+ },
71
+ })
67
72
  ```
68
73
 
69
74
  **CRITICAL**: Never use `client.createMessage()` directly in conversations. Always use `conversation.send()`.
@@ -72,15 +77,15 @@ export const Chat = new Conversation({
72
77
  // ❌ WRONG - Don't use client directly
73
78
  await client.createMessage({
74
79
  conversationId: conversation.id,
75
- type: "text",
76
- payload: { text: "Hello" }
77
- });
80
+ type: 'text',
81
+ payload: { text: 'Hello' },
82
+ })
78
83
 
79
84
  // ✅ CORRECT - Use conversation.send()
80
85
  await conversation.send({
81
- type: "text",
82
- payload: { text: "Hello" }
83
- });
86
+ type: 'text',
87
+ payload: { text: 'Hello' },
88
+ })
84
89
  ```
85
90
 
86
91
  ### Why Use `conversation.send()`?
@@ -96,27 +101,29 @@ The **chat** integration supports an optional `metadata` field on **all message
96
101
 
97
102
  ```typescript
98
103
  await conversation.send({
99
- type: "text",
104
+ type: 'text',
100
105
  payload: {
101
- text: "Your order has been confirmed",
106
+ text: 'Your order has been confirmed',
102
107
  metadata: {
103
- orderId: "order_123",
104
- customerId: "cust_456",
105
- trackingNumber: "TRACK789",
106
- internalRef: "ref_abc",
108
+ orderId: 'order_123',
109
+ customerId: 'cust_456',
110
+ trackingNumber: 'TRACK789',
111
+ internalRef: 'ref_abc',
107
112
  // Any custom data you need
108
- }
109
- }
110
- });
113
+ },
114
+ },
115
+ })
111
116
  ```
112
117
 
113
118
  **Metadata Schema**:
119
+
114
120
  - Type: `Record<string, any>` (key-value pairs)
115
121
  - Keys: strings
116
122
  - Values: any type (string, number, boolean, object, array)
117
123
  - Optional on all message types
118
124
 
119
125
  **Use Cases**:
126
+
120
127
  - File identifiers for tracking
121
128
  - Unique keys for deduplication
122
129
  - Custom display properties
@@ -124,6 +131,7 @@ await conversation.send({
124
131
  - Frontend state management
125
132
 
126
133
  **Channel Support**:
134
+
127
135
  - ✅ **chat**: Full metadata support on all message types
128
136
  - ❓ **webchat**: Check generated types after adding dependency
129
137
  - ❓ **Other channels**: Varies by integration
@@ -136,11 +144,11 @@ Basic text message - works everywhere.
136
144
 
137
145
  ```typescript
138
146
  await conversation.send({
139
- type: "text",
147
+ type: 'text',
140
148
  payload: {
141
- text: "Hello, world!"
142
- }
143
- });
149
+ text: 'Hello, world!',
150
+ },
151
+ })
144
152
  ```
145
153
 
146
154
  ### Markdown
@@ -149,11 +157,11 @@ Formatted text with markdown - **channel support varies**.
149
157
 
150
158
  ```typescript
151
159
  await conversation.send({
152
- type: "markdown",
160
+ type: 'markdown',
153
161
  payload: {
154
- markdown: "**Bold** _italic_ `code` [link](https://example.com)"
155
- }
156
- });
162
+ markdown: '**Bold** _italic_ `code` [link](https://example.com)',
163
+ },
164
+ })
157
165
  ```
158
166
 
159
167
  **Note**: Markdown support depends on the channel. Use `text` for guaranteed cross-channel compatibility.
@@ -164,11 +172,11 @@ Display an image from a URL.
164
172
 
165
173
  ```typescript
166
174
  await conversation.send({
167
- type: "image",
175
+ type: 'image',
168
176
  payload: {
169
- imageUrl: "https://example.com/image.png"
170
- }
171
- });
177
+ imageUrl: 'https://example.com/image.png',
178
+ },
179
+ })
172
180
  ```
173
181
 
174
182
  ### Audio
@@ -177,11 +185,11 @@ Play an audio file.
177
185
 
178
186
  ```typescript
179
187
  await conversation.send({
180
- type: "audio",
188
+ type: 'audio',
181
189
  payload: {
182
- audioUrl: "https://example.com/audio.mp3"
183
- }
184
- });
190
+ audioUrl: 'https://example.com/audio.mp3',
191
+ },
192
+ })
185
193
  ```
186
194
 
187
195
  ### Video
@@ -190,11 +198,11 @@ Display a video player.
190
198
 
191
199
  ```typescript
192
200
  await conversation.send({
193
- type: "video",
201
+ type: 'video',
194
202
  payload: {
195
- videoUrl: "https://example.com/video.mp4"
196
- }
197
- });
203
+ videoUrl: 'https://example.com/video.mp4',
204
+ },
205
+ })
198
206
  ```
199
207
 
200
208
  ### File
@@ -203,16 +211,17 @@ Share a downloadable file with optional metadata.
203
211
 
204
212
  ```typescript
205
213
  await conversation.send({
206
- type: "file",
214
+ type: 'file',
207
215
  payload: {
208
- fileUrl: "https://example.com/document.pdf",
209
- title: "Invoice", // optional
210
- metadata: { // optional - see Message Metadata section
211
- fileId: "file_123",
212
- uniqueKey: "invoice-2024-001"
213
- }
214
- }
215
- });
216
+ fileUrl: 'https://example.com/document.pdf',
217
+ title: 'Invoice', // optional
218
+ metadata: {
219
+ // optional - see Message Metadata section
220
+ fileId: 'file_123',
221
+ uniqueKey: 'invoice-2024-001',
222
+ },
223
+ },
224
+ })
216
225
  ```
217
226
 
218
227
  ### Location
@@ -221,14 +230,14 @@ Share a geographic location.
221
230
 
222
231
  ```typescript
223
232
  await conversation.send({
224
- type: "location",
233
+ type: 'location',
225
234
  payload: {
226
235
  latitude: 40.7128,
227
- longitude: -74.0060,
228
- address: "New York, NY", // optional
229
- title: "Meeting Location" // optional
230
- }
231
- });
236
+ longitude: -74.006,
237
+ address: 'New York, NY', // optional
238
+ title: 'Meeting Location', // optional
239
+ },
240
+ })
232
241
  ```
233
242
 
234
243
  ### Card
@@ -237,28 +246,29 @@ Rich card with image, title, and action buttons.
237
246
 
238
247
  ```typescript
239
248
  await conversation.send({
240
- type: "card",
249
+ type: 'card',
241
250
  payload: {
242
- title: "Product Name",
243
- subtitle: "Product description", // optional
244
- imageUrl: "https://example.com/product.jpg", // optional
251
+ title: 'Product Name',
252
+ subtitle: 'Product description', // optional
253
+ imageUrl: 'https://example.com/product.jpg', // optional
245
254
  actions: [
246
255
  {
247
- action: "postback", // or "url" or "say"
248
- label: "Buy Now",
249
- value: "buy_product_123"
256
+ action: 'postback', // or "url" or "say"
257
+ label: 'Buy Now',
258
+ value: 'buy_product_123',
250
259
  },
251
260
  {
252
- action: "url",
253
- label: "Learn More",
254
- value: "https://example.com/product"
255
- }
256
- ]
257
- }
258
- });
261
+ action: 'url',
262
+ label: 'Learn More',
263
+ value: 'https://example.com/product',
264
+ },
265
+ ],
266
+ },
267
+ })
259
268
  ```
260
269
 
261
270
  **Action Types**:
271
+
262
272
  - `postback`: Sends a value back to the bot (triggers new message)
263
273
  - `url`: Opens a URL in browser
264
274
  - `say`: Makes user "say" text (sends as user message)
@@ -269,28 +279,24 @@ Multiple cards in a scrollable carousel.
269
279
 
270
280
  ```typescript
271
281
  await conversation.send({
272
- type: "carousel",
282
+ type: 'carousel',
273
283
  payload: {
274
284
  items: [
275
285
  {
276
- title: "Product 1",
277
- subtitle: "Description 1",
278
- imageUrl: "https://example.com/product1.jpg",
279
- actions: [
280
- { action: "postback", label: "Select", value: "product_1" }
281
- ]
286
+ title: 'Product 1',
287
+ subtitle: 'Description 1',
288
+ imageUrl: 'https://example.com/product1.jpg',
289
+ actions: [{ action: 'postback', label: 'Select', value: 'product_1' }],
282
290
  },
283
291
  {
284
- title: "Product 2",
285
- subtitle: "Description 2",
286
- imageUrl: "https://example.com/product2.jpg",
287
- actions: [
288
- { action: "postback", label: "Select", value: "product_2" }
289
- ]
290
- }
291
- ]
292
- }
293
- });
292
+ title: 'Product 2',
293
+ subtitle: 'Description 2',
294
+ imageUrl: 'https://example.com/product2.jpg',
295
+ actions: [{ action: 'postback', label: 'Select', value: 'product_2' }],
296
+ },
297
+ ],
298
+ },
299
+ })
294
300
  ```
295
301
 
296
302
  ### Choice (Buttons)
@@ -299,17 +305,17 @@ Quick reply buttons for user selection.
299
305
 
300
306
  ```typescript
301
307
  await conversation.send({
302
- type: "choice",
308
+ type: 'choice',
303
309
  payload: {
304
- text: "What would you like to do?",
310
+ text: 'What would you like to do?',
305
311
  options: [
306
- { label: "Option 1", value: "opt1" },
307
- { label: "Option 2", value: "opt2" },
308
- { label: "Option 3", value: "opt3" }
312
+ { label: 'Option 1', value: 'opt1' },
313
+ { label: 'Option 2', value: 'opt2' },
314
+ { label: 'Option 3', value: 'opt3' },
309
315
  ],
310
- disableFreeText: false // optional - prevent typing
311
- }
312
- });
316
+ disableFreeText: false, // optional - prevent typing
317
+ },
318
+ })
313
319
  ```
314
320
 
315
321
  ### Dropdown
@@ -318,17 +324,17 @@ Dropdown/select menu for user selection.
318
324
 
319
325
  ```typescript
320
326
  await conversation.send({
321
- type: "dropdown",
327
+ type: 'dropdown',
322
328
  payload: {
323
- text: "Select your country:",
329
+ text: 'Select your country:',
324
330
  options: [
325
- { label: "United States", value: "us" },
326
- { label: "Canada", value: "ca" },
327
- { label: "United Kingdom", value: "uk" }
331
+ { label: 'United States', value: 'us' },
332
+ { label: 'Canada', value: 'ca' },
333
+ { label: 'United Kingdom', value: 'uk' },
328
334
  ],
329
- disableFreeText: true // optional
330
- }
331
- });
335
+ disableFreeText: true, // optional
336
+ },
337
+ })
332
338
  ```
333
339
 
334
340
  ### Bloc
@@ -337,27 +343,28 @@ Multiple messages grouped together (composite message).
337
343
 
338
344
  ```typescript
339
345
  await conversation.send({
340
- type: "bloc",
346
+ type: 'bloc',
341
347
  payload: {
342
348
  items: [
343
349
  {
344
- type: "text",
345
- payload: { text: "Here's your order summary:" }
350
+ type: 'text',
351
+ payload: { text: "Here's your order summary:" },
346
352
  },
347
353
  {
348
- type: "image",
349
- payload: { imageUrl: "https://example.com/product.jpg" }
354
+ type: 'image',
355
+ payload: { imageUrl: 'https://example.com/product.jpg' },
350
356
  },
351
357
  {
352
- type: "text",
353
- payload: { text: "Total: $99.99" }
354
- }
355
- ]
356
- }
357
- });
358
+ type: 'text',
359
+ payload: { text: 'Total: $99.99' },
360
+ },
361
+ ],
362
+ },
363
+ })
358
364
  ```
359
365
 
360
366
  **Allowed item types in bloc**:
367
+
361
368
  - `text`, `markdown`, `image`, `audio`, `video`, `file`, `location`
362
369
 
363
370
  ### Custom Component (Webchat)
@@ -368,12 +375,12 @@ Send a custom React component in webchat conversations using the `customComponen
368
375
  import { WelcomeBannerComponent } from '../components'
369
376
 
370
377
  await conversation.send({
371
- type: "customComponent",
378
+ type: 'customComponent',
372
379
  payload: {
373
380
  component: WelcomeBannerComponent,
374
381
  props: {},
375
- }
376
- });
382
+ },
383
+ })
377
384
  ```
378
385
 
379
386
  Components are `.bp.tsx` files registered in `src/components/index.ts` with `new CustomComponent()`. See the component registry reference for the full creation flow.
@@ -391,24 +398,24 @@ Messages (including metadata) are available to frontend clients via the webchat
391
398
  ```javascript
392
399
  // React to new messages as they arrive
393
400
  window.botpressWebChat.onMessage((message) => {
394
- console.log('New message:', message);
401
+ console.log('New message:', message)
395
402
 
396
403
  if (message.type === 'file') {
397
- console.log('File URL:', message.payload.fileUrl);
398
- console.log('File title:', message.payload.title);
399
- console.log('Metadata:', message.payload.metadata);
404
+ console.log('File URL:', message.payload.fileUrl)
405
+ console.log('File title:', message.payload.title)
406
+ console.log('Metadata:', message.payload.metadata)
400
407
 
401
408
  // Access custom metadata
402
- const { fileId, uniqueKey, customData } = message.payload.metadata || {};
409
+ const { fileId, uniqueKey, customData } = message.payload.metadata || {}
403
410
 
404
411
  // Fetch file contents if needed
405
412
  fetch(message.payload.fileUrl)
406
- .then(response => response.text())
407
- .then(content => {
408
- console.log('File content:', content);
409
- });
413
+ .then((response) => response.text())
414
+ .then((content) => {
415
+ console.log('File content:', content)
416
+ })
410
417
  }
411
- });
418
+ })
412
419
  ```
413
420
 
414
421
  ### Reconstructing State from Message History
@@ -417,34 +424,33 @@ On page reload, iterate through conversation history to reconstruct application
417
424
 
418
425
  ```javascript
419
426
  // Get all messages from conversation history
420
- window.botpressWebChat.getMessages().then(messages => {
427
+ window.botpressWebChat.getMessages().then((messages) => {
421
428
  // Filter for file messages with specific metadata
422
- const componentFiles = messages.filter(msg =>
423
- msg.type === 'file' &&
424
- msg.payload.metadata?.fileType === 'component'
425
- );
429
+ const componentFiles = messages.filter((msg) => msg.type === 'file' && msg.payload.metadata?.fileType === 'component')
426
430
 
427
431
  // Reconstruct state from persisted messages
428
432
  componentFiles.forEach(async (msg) => {
429
- const { fileUrl, metadata } = msg.payload;
430
- const { componentId, stepId } = metadata;
433
+ const { fileUrl, metadata } = msg.payload
434
+ const { componentId, stepId } = metadata
431
435
 
432
436
  // Fetch and restore component
433
- const content = await fetch(fileUrl).then(r => r.text());
434
- restoreComponent(componentId, stepId, content);
435
- });
436
- });
437
+ const content = await fetch(fileUrl).then((r) => r.text())
438
+ restoreComponent(componentId, stepId, content)
439
+ })
440
+ })
437
441
  ```
438
442
 
439
443
  ### Message Persistence Benefits
440
444
 
441
445
  Messages (unlike events) are:
446
+
442
447
  - ✅ Persisted in conversation history
443
448
  - ✅ Replayed on page reload
444
449
  - ✅ Available via `getMessages()` API
445
450
  - ✅ Include all metadata
446
451
 
447
452
  This makes messages ideal for:
453
+
448
454
  - State reconstruction after page reload
449
455
  - File tracking and retrieval
450
456
  - Workflow progress indicators
@@ -455,25 +461,25 @@ This makes messages ideal for:
455
461
  Workflows can't use `conversation.send()` - they must use `client.createMessage()`:
456
462
 
457
463
  ```typescript
458
- import { Workflow } from "@botpress/runtime";
464
+ import { Workflow } from '@botpress/runtime'
459
465
 
460
466
  export const NotifyWorkflow = new Workflow({
461
- name: "notify",
467
+ name: 'notify',
462
468
  input: z.object({
463
469
  conversationId: z.string(), // REQUIRED for messaging!
464
- message: z.string()
470
+ message: z.string(),
465
471
  }),
466
472
 
467
473
  handler: async ({ input, client, step }) => {
468
- await step("send-notification", async () => {
474
+ await step('send-notification', async () => {
469
475
  await client.createMessage({
470
476
  conversationId: input.conversationId,
471
- type: "text",
472
- payload: { text: input.message }
473
- });
474
- });
475
- }
476
- });
477
+ type: 'text',
478
+ payload: { text: input.message },
479
+ })
480
+ })
481
+ },
482
+ })
477
483
  ```
478
484
 
479
485
  **CRITICAL**: Always pass `conversationId` to workflows that need to send messages (see Common Mistakes section for details).
@@ -485,12 +491,14 @@ Events are **NOT messages** - they don't persist in conversation history. Use in
485
491
  ### When to Use Events vs Messages
486
492
 
487
493
  **Use Messages** (persistent) when:
494
+
488
495
  - User needs to see it in history
489
496
  - It's part of the conversation flow
490
497
  - You want it to survive page reloads
491
498
  - Examples: chat responses, confirmations, results
492
499
 
493
500
  **Use Events** (ephemeral) when:
501
+
494
502
  - Real-time notifications (typing indicators, progress)
495
503
  - UI state changes (show/hide widget, config updates)
496
504
  - Temporary feedback (loading, processing)
@@ -503,68 +511,71 @@ Some integrations provide actions for special message types and events:
503
511
  ```typescript
504
512
  // Webchat - Send custom event (ephemeral, not persisted)
505
513
  await client.callAction({
506
- type: "webchat:customEvent",
514
+ type: 'webchat:customEvent',
507
515
  input: {
508
516
  conversationId: conversation.id,
509
517
  event: JSON.stringify({
510
- type: "notification",
511
- message: "Processing..."
512
- })
513
- }
514
- });
518
+ type: 'notification',
519
+ message: 'Processing...',
520
+ }),
521
+ },
522
+ })
515
523
 
516
524
  // Webchat - Show/hide widget
517
525
  await client.callAction({
518
- type: "webchat:showWebchat",
519
- input: { conversationId: conversation.id }
520
- });
526
+ type: 'webchat:showWebchat',
527
+ input: { conversationId: conversation.id },
528
+ })
521
529
 
522
530
  await client.callAction({
523
- type: "webchat:hideWebchat",
524
- input: { conversationId: conversation.id }
525
- });
531
+ type: 'webchat:hideWebchat',
532
+ input: { conversationId: conversation.id },
533
+ })
526
534
 
527
535
  // Webchat - Update configuration
528
536
  await client.callAction({
529
- type: "webchat:configWebchat",
537
+ type: 'webchat:configWebchat',
530
538
  input: {
531
539
  conversationId: conversation.id,
532
540
  config: JSON.stringify({
533
- theme: { primaryColor: "#ff0000" }
534
- })
535
- }
536
- });
541
+ theme: { primaryColor: '#ff0000' },
542
+ }),
543
+ },
544
+ })
537
545
  ```
538
546
 
539
547
  **Frontend event handling**:
540
548
 
541
549
  ```javascript
542
- window.botpressWebChat.onEvent((event) => {
543
- if (event.type === 'notification') {
544
- showToast(event.message);
545
- }
546
- }, ['TRIGGER']);
550
+ window.botpressWebChat.onEvent(
551
+ (event) => {
552
+ if (event.type === 'notification') {
553
+ showToast(event.message)
554
+ }
555
+ },
556
+ ['TRIGGER']
557
+ )
547
558
  ```
548
559
 
549
560
  ## Channel Compatibility
550
561
 
551
562
  Not all message types work in all channels:
552
563
 
553
- | Message Type | Chat | Webchat | Slack | WhatsApp | Teams |
554
- |-------------|------|---------|-------|----------|-------|
555
- | text | ✅ | ✅ | ✅ | ✅ | ✅ |
556
- | markdown | ✅ | ✅ | ✅ | ❌ | ✅ |
557
- | image | ✅ | ✅ | ✅ | ✅ | ✅ |
558
- | audio | ✅ | ✅ | ❌ | ✅ | ❌ |
559
- | video | ✅ | ✅ | ❌ | ✅ | ❌ |
560
- | file | ✅ | ✅ | ✅ | ✅ | ✅ |
561
- | location | ✅ | ✅ | ❌ | ✅ | ❌ |
562
- | card | ✅ | ✅ | ✅ | ❌ | ✅ |
563
- | carousel | ✅ | ✅ | ❌ | ❌ | ❌ |
564
- | choice | ✅ | ✅ | ✅ | ✅ | ✅ |
565
- | dropdown | ✅ | ✅ | ❌ | ✅ | ❌ |
566
- | bloc | ✅ | ✅ | ❌ | ❌ | ❌ |
567
- | customComponent | ❌ | ✅ (webchat only) | ❌ | ❌ | ❌ |
564
+ | Message Type | Chat | Webchat | Slack | WhatsApp | Teams |
565
+ | --------------- | ---- | ----------------- | ----- | -------- | ----- |
566
+ | text | ✅ | ✅ | ✅ | ✅ | ✅ |
567
+ | markdown | ✅ | ✅ | ✅ | ❌ | ✅ |
568
+ | image | ✅ | ✅ | ✅ | ✅ | ✅ |
569
+ | audio | ✅ | ✅ | ❌ | ✅ | ❌ |
570
+ | video | ✅ | ✅ | ❌ | ✅ | ❌ |
571
+ | file | ✅ | ✅ | ✅ | ✅ | ✅ |
572
+ | location | ✅ | ✅ | ❌ | ✅ | ❌ |
573
+ | card | ✅ | ✅ | ✅ | ❌ | ✅ |
574
+ | carousel | ✅ | ✅ | ❌ | ❌ | ❌ |
575
+ | choice | ✅ | ✅ | ✅ | ✅ | ✅ |
576
+ | dropdown | ✅ | ✅ | ❌ | ✅ | ❌ |
577
+ | bloc | ✅ | ✅ | ❌ | ❌ | ❌ |
578
+ | customComponent | ❌ | ✅ (webchat only) | ❌ | ❌ | ❌ |
568
579
 
569
580
  **Tip**: Use `text` and `image` for maximum compatibility across channels.
570
581
 
@@ -576,16 +587,20 @@ Not all message types work in all channels:
576
587
  // ❌ WRONG
577
588
  export const Chat = new Conversation({
578
589
  async handler({ client }) {
579
- await client.createMessage({ /* ... */ });
580
- }
581
- });
590
+ await client.createMessage({
591
+ /* ... */
592
+ })
593
+ },
594
+ })
582
595
 
583
596
  // ✅ CORRECT
584
597
  export const Chat = new Conversation({
585
598
  async handler({ conversation }) {
586
- await conversation.send({ /* ... */ });
587
- }
588
- });
599
+ await conversation.send({
600
+ /* ... */
601
+ })
602
+ },
603
+ })
589
604
  ```
590
605
 
591
606
  ### 2. Using client.createEvent() for Messages
@@ -594,15 +609,15 @@ export const Chat = new Conversation({
594
609
  // ❌ WRONG - Events don't persist!
595
610
  await client.createEvent({
596
611
  conversationId: conversation.id,
597
- type: "text",
598
- payload: { text: "Hello" }
599
- });
612
+ type: 'text',
613
+ payload: { text: 'Hello' },
614
+ })
600
615
 
601
616
  // ✅ CORRECT - Use messages
602
617
  await conversation.send({
603
- type: "text",
604
- payload: { text: "Hello" }
605
- });
618
+ type: 'text',
619
+ payload: { text: 'Hello' },
620
+ })
606
621
  ```
607
622
 
608
623
  ### 3. Missing conversationId in Workflows
@@ -613,25 +628,25 @@ export const MyWorkflow = new Workflow({
613
628
  handler: async ({ input, client }) => {
614
629
  await client.createMessage({
615
630
  // Where's conversationId? This will fail!
616
- type: "text",
617
- payload: { text: "Hello" }
618
- });
619
- }
620
- });
631
+ type: 'text',
632
+ payload: { text: 'Hello' },
633
+ })
634
+ },
635
+ })
621
636
 
622
637
  // ✅ CORRECT - Pass conversationId in input
623
638
  export const MyWorkflow = new Workflow({
624
639
  input: z.object({
625
- conversationId: z.string()
640
+ conversationId: z.string(),
626
641
  }),
627
642
  handler: async ({ input, client }) => {
628
643
  await client.createMessage({
629
644
  conversationId: input.conversationId,
630
- type: "text",
631
- payload: { text: "Hello" }
632
- });
633
- }
634
- });
645
+ type: 'text',
646
+ payload: { text: 'Hello' },
647
+ })
648
+ },
649
+ })
635
650
  ```
636
651
 
637
652
  ### 4. Using Custom Components in Non-Webchat Channels
@@ -639,25 +654,30 @@ export const MyWorkflow = new Workflow({
639
654
  ```typescript
640
655
  // ❌ WRONG - customComponent only works in webchat
641
656
  export const SlackChat = new Conversation({
642
- channel: "slack.dm",
657
+ channel: 'slack.dm',
643
658
  async handler({ conversation }) {
644
659
  await conversation.send({
645
- type: "customComponent", // Will fail in Slack!
646
- payload: { component: TicketCardComponent, props: { /* ... */ } }
647
- });
648
- }
649
- });
660
+ type: 'customComponent', // Will fail in Slack!
661
+ payload: {
662
+ component: TicketCardComponent,
663
+ props: {
664
+ /* ... */
665
+ },
666
+ },
667
+ })
668
+ },
669
+ })
650
670
 
651
671
  // ✅ CORRECT - Use agnostic message types for non-webchat channels
652
672
  export const SlackChat = new Conversation({
653
- channel: "slack.dm",
673
+ channel: 'slack.dm',
654
674
  async handler({ conversation }) {
655
675
  await conversation.send({
656
- type: "card", // Works in Slack
657
- payload: { title: "Ticket", subtitle: "Details here", actions: [] }
658
- });
659
- }
660
- });
676
+ type: 'card', // Works in Slack
677
+ payload: { title: 'Ticket', subtitle: 'Details here', actions: [] },
678
+ })
679
+ },
680
+ })
661
681
  ```
662
682
 
663
683
  ## Best Practices
@@ -669,13 +689,13 @@ TypeScript will help you with type-safe payloads:
669
689
  ```typescript
670
690
  // TypeScript knows the payload structure based on type
671
691
  await conversation.send({
672
- type: "card",
692
+ type: 'card',
673
693
  payload: {
674
- title: "Required",
675
- subtitle: "Optional",
694
+ title: 'Required',
695
+ subtitle: 'Optional',
676
696
  // IntelliSense will suggest all valid fields!
677
- }
678
- });
697
+ },
698
+ })
679
699
  ```
680
700
 
681
701
  ### 2. Graceful Degradation
@@ -683,29 +703,32 @@ await conversation.send({
683
703
  When supporting multiple channels:
684
704
 
685
705
  ```typescript
686
- import { TicketCardComponent } from "../components";
706
+ import { TicketCardComponent } from '../components'
687
707
 
688
708
  export const Chat = new Conversation({
689
709
  async handler({ conversation }) {
690
- if (conversation.channel === "webchat.channel") {
710
+ if (conversation.channel === 'webchat.channel') {
691
711
  // Webchat supports custom components
692
712
  await conversation.send({
693
- type: "customComponent",
694
- payload: { component: TicketCardComponent, props: { ticketId: "TKT-001", title: "VPN issue", priority: "high", status: "open" } }
695
- });
713
+ type: 'customComponent',
714
+ payload: {
715
+ component: TicketCardComponent,
716
+ props: { ticketId: 'TKT-001', title: 'VPN issue', priority: 'high', status: 'open' },
717
+ },
718
+ })
696
719
  } else {
697
720
  // Fall back to card for other channels
698
721
  await conversation.send({
699
- type: "card",
722
+ type: 'card',
700
723
  payload: {
701
- title: "TKT-001: VPN issue",
702
- subtitle: "Priority: high · Status: open",
703
- actions: []
704
- }
705
- });
724
+ title: 'TKT-001: VPN issue',
725
+ subtitle: 'Priority: high · Status: open',
726
+ actions: [],
727
+ },
728
+ })
706
729
  }
707
- }
708
- });
730
+ },
731
+ })
709
732
  ```
710
733
 
711
734
  ### 3. Error Handling
@@ -715,16 +738,16 @@ Always wrap message sending in try-catch:
715
738
  ```typescript
716
739
  try {
717
740
  await conversation.send({
718
- type: "image",
719
- payload: { imageUrl: maybeInvalidUrl }
720
- });
741
+ type: 'image',
742
+ payload: { imageUrl: maybeInvalidUrl },
743
+ })
721
744
  } catch (error) {
722
- console.error("Failed to send image:", error);
745
+ console.error('Failed to send image:', error)
723
746
  // Fall back to text
724
747
  await conversation.send({
725
- type: "text",
726
- payload: { text: "Image unavailable" }
727
- });
748
+ type: 'text',
749
+ payload: { text: 'Image unavailable' },
750
+ })
728
751
  }
729
752
  ```
730
753
 
@@ -735,21 +758,21 @@ Break complex messages into parts:
735
758
  ```typescript
736
759
  // Instead of one giant text
737
760
  await conversation.send({
738
- type: "text",
739
- payload: { text: "Title\n\nBody text here\n\nFooter" }
740
- });
761
+ type: 'text',
762
+ payload: { text: 'Title\n\nBody text here\n\nFooter' },
763
+ })
741
764
 
742
765
  // Use bloc for better structure
743
766
  await conversation.send({
744
- type: "bloc",
767
+ type: 'bloc',
745
768
  payload: {
746
769
  items: [
747
- { type: "markdown", payload: { markdown: "**Title**" } },
748
- { type: "text", payload: { text: "Body text here" } },
749
- { type: "text", payload: { text: "Footer" } }
750
- ]
751
- }
752
- });
770
+ { type: 'markdown', payload: { markdown: '**Title**' } },
771
+ { type: 'text', payload: { text: 'Body text here' } },
772
+ { type: 'text', payload: { text: 'Footer' } },
773
+ ],
774
+ },
775
+ })
753
776
  ```
754
777
 
755
778
  ## Summary
@@ -761,6 +784,7 @@ await conversation.send({
761
784
  **Events**: Use integration actions for ephemeral notifications (don't persist)
762
785
 
763
786
  **Key Rules**:
787
+
764
788
  1. ✅ Use `conversation.send()` in conversations, `client.createMessage()` in workflows
765
789
  2. ✅ Always pass `conversationId` to workflows that send messages
766
790
  3. ✅ Use messages for persistent content, events for ephemeral notifications