@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
@@ -14,10 +14,10 @@ Tags are key-value pairs that can be attached to bots, users, conversations, and
14
14
 
15
15
  ### Tag Types
16
16
 
17
- | Type | Example Key | Description |
18
- |------|-------------|-------------|
19
- | **Custom** | `tier`, `region` | User-defined, read-write |
20
- | **System** | `webchat:owner` | Integration-managed, read-only |
17
+ | Type | Example Key | Description |
18
+ | ---------- | ---------------- | ------------------------------ |
19
+ | **Custom** | `tier`, `region` | User-defined, read-write |
20
+ | **System** | `webchat:owner` | Integration-managed, read-only |
21
21
 
22
22
  ## Defining Tags
23
23
 
@@ -26,10 +26,10 @@ Tags must be defined in your `agent.config.ts` to be persisted:
26
26
  ### User Tags
27
27
 
28
28
  ```typescript
29
- import { defineConfig, z } from "@botpress/runtime";
29
+ import { defineConfig, z } from '@botpress/runtime'
30
30
 
31
31
  export default defineConfig({
32
- name: "my-bot",
32
+ name: 'my-bot',
33
33
 
34
34
  user: {
35
35
  // User state (mutable object data)
@@ -40,37 +40,37 @@ export default defineConfig({
40
40
  // User tags (key-value pairs for categorization)
41
41
  // Tags are defined as { title: string, description?: string } objects, NOT Zod schemas
42
42
  tags: {
43
- tier: { title: "Subscription Tier", description: "User subscription level" },
44
- region: { title: "Region", description: "User geographic region" },
45
- source: { title: "Acquisition Source" },
46
- referralCode: { title: "Referral Code" },
43
+ tier: { title: 'Subscription Tier', description: 'User subscription level' },
44
+ region: { title: 'Region', description: 'User geographic region' },
45
+ source: { title: 'Acquisition Source' },
46
+ referralCode: { title: 'Referral Code' },
47
47
  },
48
48
  },
49
- });
49
+ })
50
50
  ```
51
51
 
52
52
  ### Conversation Tags
53
53
 
54
54
  ```typescript
55
55
  export default defineConfig({
56
- name: "my-bot",
56
+ name: 'my-bot',
57
57
 
58
58
  conversation: {
59
59
  tags: {
60
- category: { title: "Category" },
61
- priority: { title: "Priority", description: "Conversation priority level" },
62
- assignedTo: { title: "Assigned To" },
63
- department: { title: "Department" },
60
+ category: { title: 'Category' },
61
+ priority: { title: 'Priority', description: 'Conversation priority level' },
62
+ assignedTo: { title: 'Assigned To' },
63
+ department: { title: 'Department' },
64
64
  },
65
65
  },
66
- });
66
+ })
67
67
  ```
68
68
 
69
69
  ### Bot Tags
70
70
 
71
71
  ```typescript
72
72
  export default defineConfig({
73
- name: "my-bot",
73
+ name: 'my-bot',
74
74
 
75
75
  bot: {
76
76
  state: z.object({
@@ -78,28 +78,28 @@ export default defineConfig({
78
78
  }),
79
79
 
80
80
  tags: {
81
- environment: { title: "Environment", description: "Deployment environment" },
82
- region: { title: "Region" },
83
- version: { title: "Version" },
81
+ environment: { title: 'Environment', description: 'Deployment environment' },
82
+ region: { title: 'Region' },
83
+ version: { title: 'Version' },
84
84
  },
85
85
  },
86
- });
86
+ })
87
87
  ```
88
88
 
89
89
  ### Workflow Tags
90
90
 
91
91
  ```typescript
92
92
  export default defineConfig({
93
- name: "my-bot",
93
+ name: 'my-bot',
94
94
 
95
95
  workflow: {
96
96
  tags: {
97
- type: { title: "Workflow Type" },
98
- priority: { title: "Priority" },
99
- createdBy: { title: "Created By" },
97
+ type: { title: 'Workflow Type' },
98
+ priority: { title: 'Priority' },
99
+ createdBy: { title: 'Created By' },
100
100
  },
101
101
  },
102
- });
102
+ })
103
103
  ```
104
104
 
105
105
  ## Using Tags
@@ -107,116 +107,116 @@ export default defineConfig({
107
107
  ### In Conversations
108
108
 
109
109
  ```typescript
110
- import { Conversation, user } from "@botpress/runtime";
110
+ import { Conversation, user } from '@botpress/runtime'
111
111
 
112
112
  export default new Conversation({
113
- channel: "webchat.channel",
113
+ channel: 'webchat.channel',
114
114
 
115
115
  // conversation is provided as a handler parameter — no need for context.get()
116
116
  async handler({ message, conversation }) {
117
117
  // Read user tags
118
- console.log(`User tier: ${user.tags.tier}`);
119
- console.log(`User region: ${user.tags.region}`);
118
+ console.log(`User tier: ${user.tags.tier}`)
119
+ console.log(`User region: ${user.tags.region}`)
120
120
 
121
121
  // Set user tags
122
- user.tags.tier = "pro";
123
- user.tags.source = "website";
122
+ user.tags.tier = 'pro'
123
+ user.tags.source = 'website'
124
124
 
125
125
  // Read conversation tags
126
- console.log(`Category: ${conversation.tags.category}`);
126
+ console.log(`Category: ${conversation.tags.category}`)
127
127
 
128
128
  // Set conversation tags
129
- conversation.tags.priority = "high";
130
- conversation.tags.department = "support";
129
+ conversation.tags.priority = 'high'
130
+ conversation.tags.department = 'support'
131
131
 
132
132
  // Conditional logic based on tags
133
- if (user.tags.tier === "enterprise") {
133
+ if (user.tags.tier === 'enterprise') {
134
134
  // Priority handling for enterprise users
135
- conversation.tags.priority = "urgent";
135
+ conversation.tags.priority = 'urgent'
136
136
  }
137
137
  },
138
- });
138
+ })
139
139
  ```
140
140
 
141
141
  ### In Workflows
142
142
 
143
143
  ```typescript
144
- import { Workflow, z, bot } from "@botpress/runtime";
144
+ import { Workflow, z, bot } from '@botpress/runtime'
145
145
 
146
146
  export const ProcessingWorkflow = new Workflow({
147
- name: "processing",
147
+ name: 'processing',
148
148
  input: z.object({ userId: z.string() }),
149
149
 
150
150
  async handler({ input, workflow, step }) {
151
151
  // Set workflow tags
152
- workflow.tags.type = "data-processing";
153
- workflow.tags.priority = "high";
152
+ workflow.tags.type = 'data-processing'
153
+ workflow.tags.priority = 'high'
154
154
 
155
155
  // Access bot tags
156
- console.log(`Environment: ${bot.tags.environment}`);
156
+ console.log(`Environment: ${bot.tags.environment}`)
157
157
 
158
- await step("process", async () => {
158
+ await step('process', async () => {
159
159
  // Processing logic
160
- });
160
+ })
161
161
 
162
- return { success: true };
162
+ return { success: true }
163
163
  },
164
- });
164
+ })
165
165
  ```
166
166
 
167
167
  ### In Actions
168
168
 
169
169
  ```typescript
170
- import { Action, z, user, context } from "@botpress/runtime";
170
+ import { Action, z, user, context } from '@botpress/runtime'
171
171
 
172
172
  export default new Action({
173
- name: "upgradeUser",
173
+ name: 'upgradeUser',
174
174
  input: z.object({
175
- newTier: z.enum(["free", "pro", "enterprise"]),
175
+ newTier: z.enum(['free', 'pro', 'enterprise']),
176
176
  }),
177
177
  output: z.object({ success: z.boolean() }),
178
178
 
179
179
  async handler({ input }) {
180
- const oldTier = user.tags.tier;
181
- const conversation = context.get("conversation", { optional: true });
180
+ const oldTier = user.tags.tier
181
+ const conversation = context.get('conversation', { optional: true })
182
182
 
183
183
  // Update user tag
184
- user.tags.tier = input.newTier;
184
+ user.tags.tier = input.newTier
185
185
 
186
186
  // Log the upgrade in conversation
187
187
  if (conversation) {
188
- conversation.tags.category = "upgrade";
188
+ conversation.tags.category = 'upgrade'
189
189
  }
190
190
 
191
- console.log(`Upgraded user from ${oldTier} to ${input.newTier}`);
191
+ console.log(`Upgraded user from ${oldTier} to ${input.newTier}`)
192
192
 
193
- return { success: true };
193
+ return { success: true }
194
194
  },
195
- });
195
+ })
196
196
  ```
197
197
 
198
198
  ## Tags vs State
199
199
 
200
200
  Understanding when to use tags versus state:
201
201
 
202
- | Aspect | Tags | State |
203
- |--------|------|-------|
204
- | **Structure** | Flat key-value pairs | Nested objects |
205
- | **Types** | Strings only | Any type (objects, arrays, numbers) |
206
- | **Use case** | Categorization, filtering | Complex data storage |
207
- | **Queryable** | Yes (via API) | Limited |
208
- | **Size** | Small values | Larger structures |
202
+ | Aspect | Tags | State |
203
+ | ------------- | ------------------------- | ----------------------------------- |
204
+ | **Structure** | Flat key-value pairs | Nested objects |
205
+ | **Types** | Strings only | Any type (objects, arrays, numbers) |
206
+ | **Use case** | Categorization, filtering | Complex data storage |
207
+ | **Queryable** | Yes (via API) | Limited |
208
+ | **Size** | Small values | Larger structures |
209
209
 
210
210
  ### When to Use Tags
211
211
 
212
212
  ```typescript
213
213
  // ✅ Good for tags - simple categorization
214
- user.tags.tier = "pro";
215
- user.tags.region = "us-east";
216
- conversation.tags.priority = "high";
214
+ user.tags.tier = 'pro'
215
+ user.tags.region = 'us-east'
216
+ conversation.tags.priority = 'high'
217
217
 
218
218
  // ❌ Bad for tags - complex data belongs in state
219
- user.tags.preferences = JSON.stringify({ theme: "dark" }); // Don't do this!
219
+ user.tags.preferences = JSON.stringify({ theme: 'dark' }) // Don't do this!
220
220
  ```
221
221
 
222
222
  ### When to Use State
@@ -224,15 +224,15 @@ user.tags.preferences = JSON.stringify({ theme: "dark" }); // Don't do this!
224
224
  ```typescript
225
225
  // ✅ Good for state - complex structures
226
226
  user.state.preferences = {
227
- theme: "dark",
227
+ theme: 'dark',
228
228
  notifications: true,
229
- language: "en",
230
- };
229
+ language: 'en',
230
+ }
231
231
 
232
232
  user.state.history = [
233
- { action: "login", timestamp: new Date() },
234
- { action: "purchase", timestamp: new Date() },
235
- ];
233
+ { action: 'login', timestamp: new Date() },
234
+ { action: 'purchase', timestamp: new Date() },
235
+ ]
236
236
  ```
237
237
 
238
238
  ## System Tags
@@ -243,23 +243,23 @@ System tags are managed by integrations and are **read-only**. They contain a co
243
243
 
244
244
  ```typescript
245
245
  // Webchat system tags (read-only)
246
- console.log(user.tags["webchat:owner"]); // User who initiated webchat
247
- console.log(conversation.tags["webchat:sessionId"]); // Session identifier
246
+ console.log(user.tags['webchat:owner']) // User who initiated webchat
247
+ console.log(conversation.tags['webchat:sessionId']) // Session identifier
248
248
 
249
249
  // Integration-specific system tags
250
- console.log(user.tags["slack:userId"]); // Slack user ID
251
- console.log(conversation.tags["discord:channelId"]); // Discord channel
250
+ console.log(user.tags['slack:userId']) // Slack user ID
251
+ console.log(conversation.tags['discord:channelId']) // Discord channel
252
252
  ```
253
253
 
254
254
  ### System Tag Behavior
255
255
 
256
256
  ```typescript
257
257
  // System tags are silently ignored when you try to set them
258
- user.tags["webchat:owner"] = "new-value"; // No error, but no effect
258
+ user.tags['webchat:owner'] = 'new-value' // No error, but no effect
259
259
 
260
260
  // Only custom tags (without ':') can be modified
261
- user.tags.tier = "enterprise"; // ✅ Works
262
- user.tags.customField = "value"; // ✅ Works
261
+ user.tags.tier = 'enterprise' // ✅ Works
262
+ user.tags.customField = 'value' // ✅ Works
263
263
  ```
264
264
 
265
265
  ## Advanced Patterns
@@ -267,97 +267,95 @@ user.tags.customField = "value"; // ✅ Works
267
267
  ### Tag-Based Routing
268
268
 
269
269
  ```typescript
270
- import { Conversation, conversation, user } from "@botpress/runtime";
270
+ import { Conversation, conversation, user } from '@botpress/runtime'
271
271
 
272
272
  export default new Conversation({
273
- channel: "webchat.channel",
273
+ channel: 'webchat.channel',
274
274
 
275
275
  async handler({ message, execute }) {
276
276
  // Route based on conversation priority
277
- const priority = conversation.tags.priority;
277
+ const priority = conversation.tags.priority
278
278
 
279
- if (priority === "urgent") {
279
+ if (priority === 'urgent') {
280
280
  // Fast-track urgent conversations
281
281
  await execute({
282
- instructions: "This is an urgent request. Prioritize resolution.",
283
- model: "openai:gpt-4o", // Use best model
284
- });
282
+ instructions: 'This is an urgent request. Prioritize resolution.',
283
+ model: 'openai:gpt-4o', // Use best model
284
+ })
285
285
  } else {
286
286
  await execute({
287
- instructions: "Help the user with their request.",
288
- model: "openai:gpt-4o-mini", // Cost-efficient model
289
- });
287
+ instructions: 'Help the user with their request.',
288
+ model: 'openai:gpt-4o-mini', // Cost-efficient model
289
+ })
290
290
  }
291
291
  },
292
- });
292
+ })
293
293
  ```
294
294
 
295
295
  ### Tag-Based Analytics
296
296
 
297
297
  ```typescript
298
- import { Trigger } from "@botpress/runtime";
299
- import { AnalyticsTable } from "../tables/Analytics";
298
+ import { Trigger } from '@botpress/runtime'
299
+ import { AnalyticsTable } from '../tables/Analytics'
300
300
 
301
301
  export default new Trigger({
302
- name: "trackConversation",
303
- events: ["conversation.ended"],
302
+ name: 'trackConversation',
303
+ events: ['conversation.ended'],
304
304
 
305
305
  async handler({ event }) {
306
- const { conversationId, tags } = event.payload;
306
+ const { conversationId, tags } = event.payload
307
307
 
308
308
  // Store conversation metrics by tags
309
309
  await AnalyticsTable.createRows({
310
310
  rows: [
311
311
  {
312
312
  conversationId,
313
- category: tags.category || "uncategorized",
314
- priority: tags.priority || "normal",
315
- department: tags.department || "general",
313
+ category: tags.category || 'uncategorized',
314
+ priority: tags.priority || 'normal',
315
+ department: tags.department || 'general',
316
316
  timestamp: new Date(),
317
317
  },
318
318
  ],
319
- });
319
+ })
320
320
  },
321
- });
321
+ })
322
322
  ```
323
323
 
324
324
  ### Progressive Tag Collection
325
325
 
326
326
  ```typescript
327
- import { Conversation, user, adk } from "@botpress/runtime";
327
+ import { Conversation, user, adk } from '@botpress/runtime'
328
328
 
329
329
  export default new Conversation({
330
- channel: "webchat.channel",
330
+ channel: 'webchat.channel',
331
331
 
332
332
  async handler({ message }) {
333
333
  // Infer and set tags from conversation
334
- if (!user.tags.region && message?.type === "text") {
335
- const region = await adk.zai.extract(
336
- message.payload.text,
337
- z.string().optional(),
338
- { instructions: "Extract geographic region if mentioned" }
339
- );
334
+ if (!user.tags.region && message?.type === 'text') {
335
+ const region = await adk.zai.extract(message.payload.text, z.string().optional(), {
336
+ instructions: 'Extract geographic region if mentioned',
337
+ })
340
338
 
341
339
  if (region) {
342
- user.tags.region = region;
340
+ user.tags.region = region
343
341
  }
344
342
  }
345
343
 
346
344
  // Set source tag if not already set
347
345
  if (!user.tags.source) {
348
- user.tags.source = "webchat";
346
+ user.tags.source = 'webchat'
349
347
  }
350
348
  },
351
- });
349
+ })
352
350
  ```
353
351
 
354
352
  ### Tag Inheritance in Workflows
355
353
 
356
354
  ```typescript
357
- import { Workflow, z, user } from "@botpress/runtime";
355
+ import { Workflow, z, user } from '@botpress/runtime'
358
356
 
359
357
  export const SupportWorkflow = new Workflow({
360
- name: "support",
358
+ name: 'support',
361
359
  input: z.object({
362
360
  conversationId: z.string(),
363
361
  issue: z.string(),
@@ -365,26 +363,26 @@ export const SupportWorkflow = new Workflow({
365
363
 
366
364
  async handler({ input, workflow, step }) {
367
365
  // Inherit priority from user tier
368
- const tier = user.tags.tier;
366
+ const tier = user.tags.tier
369
367
 
370
- if (tier === "enterprise") {
371
- workflow.tags.priority = "high";
372
- } else if (tier === "pro") {
373
- workflow.tags.priority = "normal";
368
+ if (tier === 'enterprise') {
369
+ workflow.tags.priority = 'high'
370
+ } else if (tier === 'pro') {
371
+ workflow.tags.priority = 'normal'
374
372
  } else {
375
- workflow.tags.priority = "low";
373
+ workflow.tags.priority = 'low'
376
374
  }
377
375
 
378
376
  // Set workflow type
379
- workflow.tags.type = "support-ticket";
377
+ workflow.tags.type = 'support-ticket'
380
378
 
381
- await step("process", async () => {
379
+ await step('process', async () => {
382
380
  // Processing based on priority
383
- });
381
+ })
384
382
 
385
- return { processed: true };
383
+ return { processed: true }
386
384
  },
387
- });
385
+ })
388
386
  ```
389
387
 
390
388
  ## Best Practices
@@ -428,12 +426,12 @@ tags: {
428
426
  export default defineConfig({
429
427
  user: {
430
428
  tags: {
431
- tier: { title: "Subscription Tier", description: "Customer subscription level for feature gating" },
432
- region: { title: "Region", description: "Geographic region for compliance and routing" },
433
- acquisitionSource: { title: "Acquisition Source", description: "How the user discovered the bot" },
429
+ tier: { title: 'Subscription Tier', description: 'Customer subscription level for feature gating' },
430
+ region: { title: 'Region', description: 'Geographic region for compliance and routing' },
431
+ acquisitionSource: { title: 'Acquisition Source', description: 'How the user discovered the bot' },
434
432
  },
435
433
  },
436
- });
434
+ })
437
435
  ```
438
436
 
439
437
  ### 4. Set Tags Early
@@ -453,11 +451,11 @@ async handler({ message, type }) {
453
451
 
454
452
  ```typescript
455
453
  // ✅ Good - tags for filtering/categorization
456
- user.tags.tier = "enterprise";
457
- conversation.tags.category = "billing";
454
+ user.tags.tier = 'enterprise'
455
+ conversation.tags.category = 'billing'
458
456
 
459
457
  // ❌ Bad - storing complex data in tags
460
- user.tags.preferences = JSON.stringify({ notifications: true }); // Use state instead
458
+ user.tags.preferences = JSON.stringify({ notifications: true }) // Use state instead
461
459
  ```
462
460
 
463
461
  ## Troubleshooting
@@ -470,11 +468,11 @@ user.tags.preferences = JSON.stringify({ notifications: true }); // Use state in
470
468
 
471
469
  ```typescript
472
470
  // ✅ Correct
473
- user.tags.tier = "pro"; // String value
471
+ user.tags.tier = 'pro' // String value
474
472
 
475
473
  // ❌ Wrong - will be ignored or cause errors
476
- user.tags.count = 5; // Number (should be string)
477
- user.tags.active = true; // Boolean (should be string)
474
+ user.tags.count = 5 // Number (should be string)
475
+ user.tags.active = true // Boolean (should be string)
478
476
  ```
479
477
 
480
478
  ### System Tags Appearing Read-Only
@@ -483,11 +481,11 @@ System tags (containing `:`) are managed by integrations:
483
481
 
484
482
  ```typescript
485
483
  // These are read-only - modifications are silently ignored
486
- user.tags["webchat:owner"] = "new"; // No effect
487
- conversation.tags["slack:channel"] = "new"; // No effect
484
+ user.tags['webchat:owner'] = 'new' // No effect
485
+ conversation.tags['slack:channel'] = 'new' // No effect
488
486
 
489
487
  // Only custom tags can be modified
490
- user.tags.myCustomTag = "value"; // ✅ Works
488
+ user.tags.myCustomTag = 'value' // ✅ Works
491
489
  ```
492
490
 
493
491
  ### Tag Not in Schema Error
@@ -496,16 +494,16 @@ If you see errors about undefined tags, add them to your config:
496
494
 
497
495
  ```typescript
498
496
  // Before: Tag not in schema
499
- user.tags.newTag = "value"; // Warning: Tag not defined
497
+ user.tags.newTag = 'value' // Warning: Tag not defined
500
498
 
501
499
  // Fix: Add to agent.config.ts
502
500
  export default defineConfig({
503
501
  user: {
504
502
  tags: {
505
- newTag: { title: "New Tag" }, // Now it will persist
503
+ newTag: { title: 'New Tag' }, // Now it will persist
506
504
  },
507
505
  },
508
- });
506
+ })
509
507
  ```
510
508
 
511
509
  ## See Also