@botpress/adk 1.19.0-beta.7 → 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.
- package/dist/agent-init/agent-project-generator.d.ts +5 -1
- package/dist/agent-init/agent-project-generator.d.ts.map +1 -1
- package/dist/agent-project/agent-project.d.ts +3 -3
- package/dist/agent-project/agent-project.d.ts.map +1 -1
- package/dist/agent-project/agent-resolver.d.ts.map +1 -1
- package/dist/agent-project/config-writer.d.ts +1 -1
- package/dist/agent-project/config-writer.d.ts.map +1 -1
- package/dist/agent-project/dependencies-parser.d.ts.map +1 -1
- package/dist/agent-project/dependency-state-to-dependencies.d.ts +11 -0
- package/dist/agent-project/dependency-state-to-dependencies.d.ts.map +1 -0
- package/dist/agent-project/file-watcher.d.ts.map +1 -1
- package/dist/agent-project/types.d.ts +9 -4
- package/dist/agent-project/types.d.ts.map +1 -1
- package/dist/agent0/capabilities/commands/adk-build.md +6 -5
- package/dist/agent0/capabilities/commands/adk-debug.md +1 -1
- package/dist/agent0/capabilities/commands/adk-dev-console.md +1 -1
- package/dist/agent0/capabilities/commands/adk-document.md +10 -2
- package/dist/agent0/capabilities/commands/adk-eval.md +1 -1
- package/dist/agent0/capabilities/commands/adk-explain.md +2 -2
- package/dist/agent0/capabilities/commands/adk-init.md +2 -2
- package/dist/agent0/capabilities/commands/adk-ship.md +1 -1
- package/dist/agent0/capabilities/commands/adk-test.md +3 -3
- package/dist/agent0/capabilities/commands/adk-validate.md +3 -3
- package/dist/agent0/capabilities/skills/adk/SKILL.md +21 -21
- package/dist/agent0/capabilities/skills/adk/references/actions.md +245 -239
- package/dist/agent0/capabilities/skills/adk/references/advanced-patterns.md +185 -218
- package/dist/agent0/capabilities/skills/adk/references/agent-config.md +74 -71
- package/dist/agent0/capabilities/skills/adk/references/assets.md +45 -48
- package/dist/agent0/capabilities/skills/adk/references/autonomous-execution.md +40 -46
- package/dist/agent0/capabilities/skills/adk/references/cli.md +17 -7
- package/dist/agent0/capabilities/skills/adk/references/context-api.md +98 -94
- package/dist/agent0/capabilities/skills/adk/references/conversation-lifecycle.md +65 -62
- package/dist/agent0/capabilities/skills/adk/references/conversations.md +395 -385
- package/dist/agent0/capabilities/skills/adk/references/custom-components.md +1 -1
- package/dist/agent0/capabilities/skills/adk/references/desk.md +236 -234
- package/dist/agent0/capabilities/skills/adk/references/explain-config.md +54 -37
- package/dist/agent0/capabilities/skills/adk/references/files.md +301 -306
- package/dist/agent0/capabilities/skills/adk/references/integration-actions.md +211 -214
- package/dist/agent0/capabilities/skills/adk/references/integrations.md +33 -31
- package/dist/agent0/capabilities/skills/adk/references/interfaces.md +13 -12
- package/dist/agent0/capabilities/skills/adk/references/knowledge-bases.md +98 -111
- package/dist/agent0/capabilities/skills/adk/references/mcp-server.md +6 -0
- package/dist/agent0/capabilities/skills/adk/references/messages.md +280 -256
- package/dist/agent0/capabilities/skills/adk/references/model-configuration.md +52 -49
- package/dist/agent0/capabilities/skills/adk/references/patterns-mistakes.md +102 -101
- package/dist/agent0/capabilities/skills/adk/references/plugins.md +15 -15
- package/dist/agent0/capabilities/skills/adk/references/tables.md +204 -210
- package/dist/agent0/capabilities/skills/adk/references/tags.md +141 -143
- package/dist/agent0/capabilities/skills/adk/references/tools.md +191 -199
- package/dist/agent0/capabilities/skills/adk/references/triggers.md +331 -336
- package/dist/agent0/capabilities/skills/adk/references/workflow-steps.md +132 -96
- package/dist/agent0/capabilities/skills/adk/references/workflows.md +479 -464
- package/dist/agent0/capabilities/skills/adk/references/zai-agent-reference.md +127 -129
- package/dist/agent0/capabilities/skills/adk/references/zai-complete-guide.md +255 -276
- package/dist/agent0/capabilities/skills/adk-debugger/SKILL.md +21 -17
- package/dist/agent0/capabilities/skills/adk-debugger/references/common-failures.md +25 -25
- package/dist/agent0/capabilities/skills/adk-debugger/references/conversation-analysis.md +49 -41
- package/dist/agent0/capabilities/skills/adk-debugger/references/debug-workflow.md +20 -14
- package/dist/agent0/capabilities/skills/adk-debugger/references/llm-debugging.md +13 -13
- package/dist/agent0/capabilities/skills/adk-debugger/references/trace-summarization.md +18 -18
- package/dist/agent0/capabilities/skills/adk-debugger/references/traces-and-logs.md +67 -67
- package/dist/agent0/capabilities/skills/adk-dev-console/SKILL.md +36 -36
- package/dist/agent0/capabilities/skills/adk-dev-console/references/agent-steps.md +14 -6
- package/dist/agent0/capabilities/skills/adk-dev-console/references/multi-agent-dashboard.md +13 -13
- package/dist/agent0/capabilities/skills/adk-dev-console/references/pages.md +18 -0
- package/dist/agent0/capabilities/skills/adk-docs/SKILL.md +13 -13
- package/dist/agent0/capabilities/skills/adk-docs/references/doc-standards.md +15 -0
- package/dist/agent0/capabilities/skills/adk-evals/SKILL.md +29 -23
- package/dist/agent0/capabilities/skills/adk-evals/references/eval-format.md +31 -23
- package/dist/agent0/capabilities/skills/adk-evals/references/test-patterns.md +25 -36
- package/dist/agent0/capabilities/skills/adk-evals/references/testing-workflow.md +6 -4
- package/dist/agent0/config/schema.d.ts.map +1 -1
- package/dist/agent0/config/store.d.ts +8 -3
- package/dist/agent0/config/store.d.ts.map +1 -1
- package/dist/agent0/index.js +214 -59
- package/dist/agent0/index.js.map +17 -15
- package/dist/agent0/providers/catalog.d.ts.map +1 -1
- package/dist/agent0/providers/registry.d.ts.map +1 -1
- package/dist/agent0/providers/source.d.ts +8 -3
- package/dist/agent0/providers/source.d.ts.map +1 -1
- package/dist/agent0/runtime/client.d.ts +4 -3
- package/dist/agent0/runtime/client.d.ts.map +1 -1
- package/dist/agent0/runtime/engine.d.ts +7 -1
- package/dist/agent0/runtime/engine.d.ts.map +1 -1
- package/dist/agent0/runtime/manager.d.ts +2 -3
- package/dist/agent0/runtime/manager.d.ts.map +1 -1
- package/dist/agent0/runtime/process.d.ts +10 -0
- package/dist/agent0/runtime/process.d.ts.map +1 -1
- package/dist/assets/manager.d.ts +3 -0
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/auth/credentials.d.ts +1 -1
- package/dist/auth/credentials.d.ts.map +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/service.d.ts.map +1 -1
- package/dist/bot-generator/generator.d.ts +22 -0
- package/dist/bot-generator/generator.d.ts.map +1 -1
- package/dist/bot-generator/integration-sync.d.ts +2 -0
- package/dist/bot-generator/integration-sync.d.ts.map +1 -1
- package/dist/bot-generator/interface-sync.d.ts +2 -0
- package/dist/bot-generator/interface-sync.d.ts.map +1 -1
- package/dist/bot-generator/plugin-sync.d.ts +2 -0
- package/dist/bot-generator/plugin-sync.d.ts.map +1 -1
- package/dist/cognitive/models.d.ts.map +1 -1
- package/dist/commands/base-command.d.ts +1 -0
- package/dist/commands/base-command.d.ts.map +1 -1
- package/dist/commands/bp-cli.d.ts.map +1 -1
- package/dist/commands/bp-cli.js +147 -0
- package/dist/commands/bp-cli.js.map +12 -0
- package/dist/commands/bp-dev-command.d.ts +3 -1
- package/dist/commands/bp-dev-command.d.ts.map +1 -1
- package/dist/commands/bp-dev-stderr.d.ts +9 -0
- package/dist/commands/bp-dev-stderr.d.ts.map +1 -1
- package/dist/commands/bp-dev-worker-env.d.ts +7 -0
- package/dist/commands/bp-dev-worker-env.d.ts.map +1 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/config/manager.d.ts.map +1 -1
- package/dist/dependencies/catalog/catalog-service.d.ts +53 -0
- package/dist/dependencies/catalog/catalog-service.d.ts.map +1 -0
- package/dist/dependencies/catalog/client-factory.d.ts +33 -0
- package/dist/dependencies/catalog/client-factory.d.ts.map +1 -0
- package/dist/dependencies/catalog/integration-source.d.ts +34 -0
- package/dist/dependencies/catalog/integration-source.d.ts.map +1 -0
- package/dist/dependencies/catalog/interface-source.d.ts +23 -0
- package/dist/dependencies/catalog/interface-source.d.ts.map +1 -0
- package/dist/dependencies/catalog/plugin-source.d.ts +49 -0
- package/dist/dependencies/catalog/plugin-source.d.ts.map +1 -0
- package/dist/dependencies/catalog/resolution-cache.d.ts +76 -0
- package/dist/dependencies/catalog/resolution-cache.d.ts.map +1 -0
- package/dist/dependencies/dependency-manager.d.ts +31 -16
- package/dist/dependencies/dependency-manager.d.ts.map +1 -1
- package/dist/dependencies/errors.d.ts +9 -6
- package/dist/dependencies/errors.d.ts.map +1 -1
- package/dist/dependencies/index.d.ts +5 -4
- package/dist/dependencies/index.d.ts.map +1 -1
- package/dist/dependencies/index.js +2309 -1697
- package/dist/dependencies/index.js.map +41 -32
- package/dist/dependencies/legacy-lock-file.d.ts +15 -0
- package/dist/dependencies/legacy-lock-file.d.ts.map +1 -0
- package/dist/dependencies/migration.d.ts +19 -0
- package/dist/dependencies/migration.d.ts.map +1 -1
- package/dist/dependencies/resolvers/integration-resolver.d.ts +4 -3
- package/dist/dependencies/resolvers/integration-resolver.d.ts.map +1 -1
- package/dist/dependencies/resolvers/plugin-resolver.d.ts +4 -4
- package/dist/dependencies/resolvers/plugin-resolver.d.ts.map +1 -1
- package/dist/dependencies/snapshot-store.d.ts +59 -0
- package/dist/dependencies/snapshot-store.d.ts.map +1 -0
- package/dist/dependencies/status-resolver.d.ts +36 -0
- package/dist/dependencies/status-resolver.d.ts.map +1 -0
- package/dist/dependencies/status.d.ts +214 -0
- package/dist/dependencies/status.d.ts.map +1 -0
- package/dist/dependencies/types.d.ts +388 -37
- package/dist/dependencies/types.d.ts.map +1 -1
- package/dist/file-watcher/watcher.d.ts +21 -5
- package/dist/file-watcher/watcher.d.ts.map +1 -1
- package/dist/generators/action-types.d.ts.map +1 -1
- package/dist/generators/client-wrapper.d.ts.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3643 -2345
- package/dist/index.js.map +68 -58
- package/dist/integrations/config-utils.d.ts +11 -7
- package/dist/integrations/config-utils.d.ts.map +1 -1
- package/dist/integrations/hub-cache.d.ts +0 -58
- package/dist/integrations/hub-cache.d.ts.map +1 -1
- package/dist/integrations/index.d.ts +1 -3
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/manager.d.ts +19 -53
- package/dist/integrations/manager.d.ts.map +1 -1
- package/dist/interfaces/enhanced-cache.d.ts +7 -7
- package/dist/interfaces/enhanced-cache.d.ts.map +1 -1
- package/dist/interfaces/manager.d.ts +11 -17
- package/dist/interfaces/manager.d.ts.map +1 -1
- package/dist/interfaces/parser.d.ts.map +1 -1
- package/dist/knowledge/manager.d.ts +3 -0
- package/dist/knowledge/manager.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +0 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/manager.d.ts +16 -48
- package/dist/plugins/manager.d.ts.map +1 -1
- package/dist/preflight/checker.d.ts +6 -1
- package/dist/preflight/checker.d.ts.map +1 -1
- package/dist/preflight/dependency-gate.d.ts +37 -0
- package/dist/preflight/dependency-gate.d.ts.map +1 -0
- package/dist/preflight/index.d.ts +2 -1
- package/dist/preflight/index.d.ts.map +1 -1
- package/dist/preflight/types.d.ts +18 -0
- package/dist/preflight/types.d.ts.map +1 -1
- package/dist/runner/script-runner.d.ts.map +1 -1
- package/dist/secrets/manager.d.ts.map +1 -1
- package/dist/tables/table-manager.d.ts +3 -0
- package/dist/tables/table-manager.d.ts.map +1 -1
- package/dist/templates/README.md +23 -13
- package/dist/templates/blank/agent.config.ts +3 -3
- package/dist/templates/blank/src/triggers/index.ts +1 -1
- package/dist/templates/botpress-desk/evals/index.eval.ts +1 -1
- package/dist/templates/botpress-desk/src/triggers/index.ts +1 -1
- package/dist/templates/crm-enrichment/README.md +3 -3
- package/dist/templates/crm-enrichment/agent.config.ts +2 -2
- package/dist/templates/crm-enrichment/src/conversations/index.ts +1 -1
- package/dist/templates/hello-world/agent.config.ts +3 -3
- package/dist/templates/hello-world/src/triggers/index.ts +1 -1
- package/dist/templates/knowledge-assistant/src/triggers/index.ts +1 -1
- package/dist/templates/template.config.json +3 -3
- package/dist/test-utils/mock-module.d.ts +29 -0
- package/dist/test-utils/mock-module.d.ts.map +1 -0
- package/dist/utils/ids.d.ts +10 -0
- package/dist/utils/ids.d.ts.map +1 -1
- package/dist/utils/require-chat.d.ts.map +1 -1
- package/dist/utils/source-map-optimizer.d.ts +10 -11
- package/dist/utils/source-map-optimizer.d.ts.map +1 -1
- package/dist/workspace/workspace-cache.d.ts +2 -1
- package/dist/workspace/workspace-cache.d.ts.map +1 -1
- package/package.json +8 -4
- package/dist/agent-project/lock-to-dependencies.d.ts +0 -11
- package/dist/agent-project/lock-to-dependencies.d.ts.map +0 -1
- package/dist/dependencies/lock-file.d.ts +0 -15
- package/dist/dependencies/lock-file.d.ts.map +0 -1
- package/dist/integrations/enhanced-cache.d.ts +0 -53
- package/dist/integrations/enhanced-cache.d.ts.map +0 -1
- package/dist/plugins/enhanced-cache.d.ts +0 -53
- package/dist/plugins/enhanced-cache.d.ts.map +0 -1
- package/dist/templates/blank/package.json +0 -17
- package/dist/templates/blank/tsconfig.json +0 -25
- package/dist/templates/botpress-desk/package.json +0 -17
- package/dist/templates/crm-enrichment/package.json +0 -18
- package/dist/templates/crm-enrichment/tsconfig.json +0 -25
- package/dist/templates/hello-world/package.json +0 -18
- package/dist/templates/hello-world/tsconfig.json +0 -25
- package/dist/templates/knowledge-assistant/package.json +0 -18
- package/dist/templates/knowledge-assistant/tsconfig.json +0 -25
- package/dist/templates/slack-triage/package.json +0 -18
- 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
|
|
18
|
-
|
|
19
|
-
| **Custom** | `tier`, `region` | User-defined, read-write
|
|
20
|
-
| **System** | `webchat:owner`
|
|
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
|
|
29
|
+
import { defineConfig, z } from '@botpress/runtime'
|
|
30
30
|
|
|
31
31
|
export default defineConfig({
|
|
32
|
-
name:
|
|
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:
|
|
44
|
-
region: { title:
|
|
45
|
-
source: { title:
|
|
46
|
-
referralCode: { title:
|
|
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:
|
|
56
|
+
name: 'my-bot',
|
|
57
57
|
|
|
58
58
|
conversation: {
|
|
59
59
|
tags: {
|
|
60
|
-
category: { title:
|
|
61
|
-
priority: { title:
|
|
62
|
-
assignedTo: { title:
|
|
63
|
-
department: { title:
|
|
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:
|
|
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:
|
|
82
|
-
region: { title:
|
|
83
|
-
version: { title:
|
|
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:
|
|
93
|
+
name: 'my-bot',
|
|
94
94
|
|
|
95
95
|
workflow: {
|
|
96
96
|
tags: {
|
|
97
|
-
type: { title:
|
|
98
|
-
priority: { title:
|
|
99
|
-
createdBy: { title:
|
|
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
|
|
110
|
+
import { Conversation, user } from '@botpress/runtime'
|
|
111
111
|
|
|
112
112
|
export default new Conversation({
|
|
113
|
-
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 =
|
|
123
|
-
user.tags.source =
|
|
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 =
|
|
130
|
-
conversation.tags.department =
|
|
129
|
+
conversation.tags.priority = 'high'
|
|
130
|
+
conversation.tags.department = 'support'
|
|
131
131
|
|
|
132
132
|
// Conditional logic based on tags
|
|
133
|
-
if (user.tags.tier ===
|
|
133
|
+
if (user.tags.tier === 'enterprise') {
|
|
134
134
|
// Priority handling for enterprise users
|
|
135
|
-
conversation.tags.priority =
|
|
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
|
|
144
|
+
import { Workflow, z, bot } from '@botpress/runtime'
|
|
145
145
|
|
|
146
146
|
export const ProcessingWorkflow = new Workflow({
|
|
147
|
-
name:
|
|
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 =
|
|
153
|
-
workflow.tags.priority =
|
|
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(
|
|
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
|
|
170
|
+
import { Action, z, user, context } from '@botpress/runtime'
|
|
171
171
|
|
|
172
172
|
export default new Action({
|
|
173
|
-
name:
|
|
173
|
+
name: 'upgradeUser',
|
|
174
174
|
input: z.object({
|
|
175
|
-
newTier: z.enum([
|
|
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(
|
|
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 =
|
|
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
|
|
203
|
-
|
|
204
|
-
| **Structure** | Flat key-value pairs
|
|
205
|
-
| **Types**
|
|
206
|
-
| **Use case**
|
|
207
|
-
| **Queryable** | Yes (via API)
|
|
208
|
-
| **Size**
|
|
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 =
|
|
215
|
-
user.tags.region =
|
|
216
|
-
conversation.tags.priority =
|
|
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:
|
|
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:
|
|
227
|
+
theme: 'dark',
|
|
228
228
|
notifications: true,
|
|
229
|
-
language:
|
|
230
|
-
}
|
|
229
|
+
language: 'en',
|
|
230
|
+
}
|
|
231
231
|
|
|
232
232
|
user.state.history = [
|
|
233
|
-
{ action:
|
|
234
|
-
{ action:
|
|
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[
|
|
247
|
-
console.log(conversation.tags[
|
|
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[
|
|
251
|
-
console.log(conversation.tags[
|
|
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[
|
|
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 =
|
|
262
|
-
user.tags.customField =
|
|
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
|
|
270
|
+
import { Conversation, conversation, user } from '@botpress/runtime'
|
|
271
271
|
|
|
272
272
|
export default new Conversation({
|
|
273
|
-
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 ===
|
|
279
|
+
if (priority === 'urgent') {
|
|
280
280
|
// Fast-track urgent conversations
|
|
281
281
|
await execute({
|
|
282
|
-
instructions:
|
|
283
|
-
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:
|
|
288
|
-
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
|
|
299
|
-
import { AnalyticsTable } from
|
|
298
|
+
import { Trigger } from '@botpress/runtime'
|
|
299
|
+
import { AnalyticsTable } from '../tables/Analytics'
|
|
300
300
|
|
|
301
301
|
export default new Trigger({
|
|
302
|
-
name:
|
|
303
|
-
events: [
|
|
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 ||
|
|
314
|
-
priority: tags.priority ||
|
|
315
|
-
department: tags.department ||
|
|
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
|
|
327
|
+
import { Conversation, user, adk } from '@botpress/runtime'
|
|
328
328
|
|
|
329
329
|
export default new Conversation({
|
|
330
|
-
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 ===
|
|
335
|
-
const region = await adk.zai.extract(
|
|
336
|
-
|
|
337
|
-
|
|
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 =
|
|
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
|
|
355
|
+
import { Workflow, z, user } from '@botpress/runtime'
|
|
358
356
|
|
|
359
357
|
export const SupportWorkflow = new Workflow({
|
|
360
|
-
name:
|
|
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 ===
|
|
371
|
-
workflow.tags.priority =
|
|
372
|
-
} else if (tier ===
|
|
373
|
-
workflow.tags.priority =
|
|
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 =
|
|
373
|
+
workflow.tags.priority = 'low'
|
|
376
374
|
}
|
|
377
375
|
|
|
378
376
|
// Set workflow type
|
|
379
|
-
workflow.tags.type =
|
|
377
|
+
workflow.tags.type = 'support-ticket'
|
|
380
378
|
|
|
381
|
-
await step(
|
|
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:
|
|
432
|
-
region: { title:
|
|
433
|
-
acquisitionSource: { title:
|
|
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 =
|
|
457
|
-
conversation.tags.category =
|
|
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 })
|
|
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 =
|
|
471
|
+
user.tags.tier = 'pro' // String value
|
|
474
472
|
|
|
475
473
|
// ❌ Wrong - will be ignored or cause errors
|
|
476
|
-
user.tags.count = 5
|
|
477
|
-
user.tags.active = true
|
|
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[
|
|
487
|
-
conversation.tags[
|
|
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 =
|
|
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 =
|
|
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:
|
|
503
|
+
newTag: { title: 'New Tag' }, // Now it will persist
|
|
506
504
|
},
|
|
507
505
|
},
|
|
508
|
-
})
|
|
506
|
+
})
|
|
509
507
|
```
|
|
510
508
|
|
|
511
509
|
## See Also
|