@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.
- 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/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/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/index.js +41 -19
- package/dist/agent0/index.js.map +7 -7
- package/dist/agent0/runtime/client.d.ts +2 -0
- package/dist/agent0/runtime/client.d.ts.map +1 -1
- package/dist/agent0/runtime/engine.d.ts +2 -1
- package/dist/agent0/runtime/engine.d.ts.map +1 -1
- package/dist/agent0/runtime/process.d.ts +1 -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/bot-generator/generator.d.ts +22 -0
- package/dist/bot-generator/generator.d.ts.map +1 -1
- package/dist/bot-generator/plugin-sync.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-dev-command.d.ts +1 -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/index.d.ts +1 -0
- package/dist/commands/index.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 +2 -2
- 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 +2089 -1670
- package/dist/dependencies/index.js.map +37 -30
- 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 +380 -29
- 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 +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3134 -2226
- package/dist/index.js.map +55 -48
- 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/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/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/utils/ids.d.ts +10 -0
- package/dist/utils/ids.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 +3 -3
- 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
|
@@ -8,51 +8,51 @@ Minimal working example for a Desk support bot:
|
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
10
|
// src/conversations/desk.ts
|
|
11
|
-
import { Autonomous, context, Conversation, z } from
|
|
12
|
-
import { actions, joinMarkdownChildren } from
|
|
11
|
+
import { Autonomous, context, Conversation, z } from '@botpress/runtime'
|
|
12
|
+
import { actions, joinMarkdownChildren } from '@botpress/runtime/runtime'
|
|
13
13
|
|
|
14
14
|
export default new Conversation({
|
|
15
|
-
channel:
|
|
15
|
+
channel: 'desk.ticket',
|
|
16
16
|
state: z.object({
|
|
17
|
-
lastSync: z.string().default(
|
|
17
|
+
lastSync: z.string().default(''),
|
|
18
18
|
}),
|
|
19
|
-
events: [
|
|
19
|
+
events: ['desk:ticketActivity'],
|
|
20
20
|
handler: async ({ conversation, execute, send }) => {
|
|
21
21
|
// CRITICAL: Only process tickets assigned to this bot
|
|
22
|
-
if (conversation.tags[
|
|
23
|
-
console.log(
|
|
24
|
-
return
|
|
22
|
+
if (conversation.tags['desk:dassignedself'] !== 'true') {
|
|
23
|
+
console.log('Ticket not assigned to bot, ignoring...')
|
|
24
|
+
return
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
await execute({
|
|
28
28
|
tools: [],
|
|
29
|
-
instructions:
|
|
30
|
-
})
|
|
29
|
+
instructions: 'You are a helpful support agent...',
|
|
30
|
+
})
|
|
31
31
|
},
|
|
32
|
-
})
|
|
32
|
+
})
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Configuration (agent.config.ts)
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
|
-
import { defineConfig } from
|
|
38
|
+
import { defineConfig } from '@botpress/runtime'
|
|
39
39
|
|
|
40
40
|
export default defineConfig({
|
|
41
|
-
name:
|
|
41
|
+
name: 'support-bot',
|
|
42
42
|
|
|
43
43
|
dependencies: {
|
|
44
44
|
integrations: {
|
|
45
45
|
desk: {
|
|
46
46
|
enabled: true,
|
|
47
47
|
configuration: {
|
|
48
|
-
displayName:
|
|
49
|
-
botHandle:
|
|
48
|
+
displayName: 'Support Bot',
|
|
49
|
+
botHandle: 'SupportBot',
|
|
50
50
|
canBeAssigned: true,
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
|
-
})
|
|
55
|
+
})
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
---
|
|
@@ -62,6 +62,7 @@ export default defineConfig({
|
|
|
62
62
|
### What is Desk?
|
|
63
63
|
|
|
64
64
|
Desk is a unified support workspace that:
|
|
65
|
+
|
|
65
66
|
- Aggregates tickets from multiple sources (Intercom, Zendesk, native)
|
|
66
67
|
- Enables human agents and AI bots to collaborate on customer tickets
|
|
67
68
|
- Provides real-time activity feeds and assignment management
|
|
@@ -69,14 +70,15 @@ Desk is a unified support workspace that:
|
|
|
69
70
|
|
|
70
71
|
### Bot Participation Modes
|
|
71
72
|
|
|
72
|
-
| Mode
|
|
73
|
-
|
|
74
|
-
| **Assigned**
|
|
75
|
-
| **Assisting** | `false`
|
|
73
|
+
| Mode | `canBeAssigned` | Description |
|
|
74
|
+
| ------------- | --------------- | ------------------------------------------------------ |
|
|
75
|
+
| **Assigned** | `true` | Bot owns tickets and replies directly to customers |
|
|
76
|
+
| **Assisting** | `false` | Bot helps human agents with suggestions and automation |
|
|
76
77
|
|
|
77
78
|
### Multi-Bot Teams
|
|
78
79
|
|
|
79
80
|
Multiple bots can be registered with Desk, each with different capabilities:
|
|
81
|
+
|
|
80
82
|
- A triage bot that classifies and routes tickets
|
|
81
83
|
- A knowledge bot that searches documentation
|
|
82
84
|
- A specialist bot for specific product areas
|
|
@@ -90,44 +92,46 @@ Each bot is identified by its `botHandle` (e.g., "@SupportBot", "@TriageBot").
|
|
|
90
92
|
All Desk configuration lives in `agent.config.ts` inside the `dependencies.integrations.desk` block:
|
|
91
93
|
|
|
92
94
|
```typescript
|
|
93
|
-
import { defineConfig } from
|
|
95
|
+
import { defineConfig } from '@botpress/runtime'
|
|
94
96
|
|
|
95
97
|
export default defineConfig({
|
|
96
|
-
name:
|
|
98
|
+
name: 'my-agent',
|
|
97
99
|
|
|
98
100
|
dependencies: {
|
|
99
101
|
integrations: {
|
|
100
102
|
desk: {
|
|
101
103
|
enabled: true,
|
|
102
104
|
configuration: {
|
|
103
|
-
displayName:
|
|
104
|
-
botHandle:
|
|
105
|
-
displayAvatarUrl:
|
|
105
|
+
displayName: 'My Support Bot',
|
|
106
|
+
botHandle: 'MySupportBot',
|
|
107
|
+
displayAvatarUrl: 'https://example.com/bot-avatar.png',
|
|
106
108
|
canBeAssigned: true,
|
|
107
109
|
},
|
|
108
110
|
},
|
|
109
111
|
},
|
|
110
112
|
},
|
|
111
|
-
})
|
|
113
|
+
})
|
|
112
114
|
```
|
|
113
115
|
|
|
114
116
|
### Configuration Options
|
|
115
117
|
|
|
116
|
-
| Option
|
|
117
|
-
|
|
118
|
-
| `displayName`
|
|
119
|
-
| `botHandle`
|
|
120
|
-
| `displayAvatarUrl` | string
|
|
121
|
-
| `canBeAssigned`
|
|
118
|
+
| Option | Type | Required | Description |
|
|
119
|
+
| ------------------ | ------- | -------- | --------------------------------------------------------------------------------- |
|
|
120
|
+
| `displayName` | string | Yes | Name shown in Desk UI |
|
|
121
|
+
| `botHandle` | string | Yes | Handle for @mentions (3-20 chars, starts with letter, alphanumeric + underscores) |
|
|
122
|
+
| `displayAvatarUrl` | string | No | URL of avatar image |
|
|
123
|
+
| `canBeAssigned` | boolean | No | Whether bot can be assigned to tickets (default: `false`) |
|
|
122
124
|
|
|
123
125
|
### Handle Rules
|
|
124
126
|
|
|
125
127
|
The `botHandle` must:
|
|
128
|
+
|
|
126
129
|
- Be 3-20 characters
|
|
127
130
|
- Start with a letter
|
|
128
131
|
- Contain only letters, numbers, and underscores
|
|
129
132
|
|
|
130
133
|
Examples:
|
|
134
|
+
|
|
131
135
|
- `SupportBot`, `Triage_Bot`, `KB123`
|
|
132
136
|
- ❌ `Bot`, `123Bot`, `support-bot`
|
|
133
137
|
|
|
@@ -141,9 +145,9 @@ The Desk integration exposes a single channel: `desk.ticket`. All ticket interac
|
|
|
141
145
|
|
|
142
146
|
```typescript
|
|
143
147
|
export default new Conversation({
|
|
144
|
-
channel:
|
|
148
|
+
channel: 'desk.ticket',
|
|
145
149
|
// ...
|
|
146
|
-
})
|
|
150
|
+
})
|
|
147
151
|
```
|
|
148
152
|
|
|
149
153
|
### Event: desk:ticketActivity
|
|
@@ -152,41 +156,41 @@ Emitted when new activities (comments, notes, or system activities) are added to
|
|
|
152
156
|
|
|
153
157
|
```typescript
|
|
154
158
|
export default new Conversation({
|
|
155
|
-
channel:
|
|
156
|
-
events: [
|
|
159
|
+
channel: 'desk.ticket',
|
|
160
|
+
events: ['desk:ticketActivity'],
|
|
157
161
|
handler: async ({ event }) => {
|
|
158
162
|
// event.payload contains:
|
|
159
163
|
// - ticketId: string
|
|
160
164
|
// - activityCount: number
|
|
161
165
|
},
|
|
162
|
-
})
|
|
166
|
+
})
|
|
163
167
|
```
|
|
164
168
|
|
|
165
169
|
**Important:** The event does NOT include activities created by the bot itself (prevents infinite loops).
|
|
166
170
|
|
|
167
171
|
### Conversation Tags
|
|
168
172
|
|
|
169
|
-
| Tag
|
|
170
|
-
|
|
171
|
-
| `desk:did`
|
|
172
|
-
| `desk:status`
|
|
173
|
-
| `desk:title`
|
|
174
|
-
| `desk:system`
|
|
175
|
-
| `desk:url`
|
|
176
|
-
| `desk:snoozeduntil`
|
|
177
|
-
| `desk:dtags`
|
|
178
|
-
| `desk:dcustomerid`
|
|
179
|
-
| `desk:dassignedid`
|
|
180
|
-
| `desk:dassignedself`
|
|
181
|
-
| `desk:dsyncactivityid` | Last synced activity ID
|
|
173
|
+
| Tag | Description | Example |
|
|
174
|
+
| ---------------------- | --------------------------- | ------------------------------- |
|
|
175
|
+
| `desk:did` | Desk ticket ID | `tkt_abc123` |
|
|
176
|
+
| `desk:status` | Ticket status | `open`, `closed`, `snoozed` |
|
|
177
|
+
| `desk:title` | Ticket title | `"Login issue"` |
|
|
178
|
+
| `desk:system` | Source system | `intercom`, `zendesk`, `native` |
|
|
179
|
+
| `desk:url` | URL to view in Desk | `https://desk.botpress.com/...` |
|
|
180
|
+
| `desk:snoozeduntil` | Wake time if snoozed | ISO timestamp |
|
|
181
|
+
| `desk:dtags` | Desk tags (comma-separated) | `urgent,billing` |
|
|
182
|
+
| `desk:dcustomerid` | Customer ID | `cus_xyz789` |
|
|
183
|
+
| `desk:dassignedid` | Assigned admin/bot ID | `adm_123`, `ibot_456` |
|
|
184
|
+
| `desk:dassignedself` | **Is this bot assigned?** | `"true"` or `"false"` |
|
|
185
|
+
| `desk:dsyncactivityid` | Last synced activity ID | `tka_abc123` |
|
|
182
186
|
|
|
183
187
|
### Message Tags
|
|
184
188
|
|
|
185
|
-
| Tag
|
|
186
|
-
|
|
187
|
-
| `desk:did`
|
|
189
|
+
| Tag | Description |
|
|
190
|
+
| ------------------ | -------------------------- |
|
|
191
|
+
| `desk:did` | Activity ID (`tka_...`) |
|
|
188
192
|
| `desk:dassignedid` | Who was assigned when sent |
|
|
189
|
-
| `desk:dstatus`
|
|
193
|
+
| `desk:dstatus` | Ticket status when sent |
|
|
190
194
|
|
|
191
195
|
---
|
|
192
196
|
|
|
@@ -200,15 +204,16 @@ Replies are visible to the customer and may be sent via email.
|
|
|
200
204
|
|
|
201
205
|
```typescript
|
|
202
206
|
await send({
|
|
203
|
-
type:
|
|
207
|
+
type: 'text',
|
|
204
208
|
payload: {
|
|
205
|
-
format:
|
|
206
|
-
text:
|
|
209
|
+
format: 'markdown',
|
|
210
|
+
text: 'Hello! How can I help you today?',
|
|
207
211
|
},
|
|
208
|
-
})
|
|
212
|
+
})
|
|
209
213
|
```
|
|
210
214
|
|
|
211
215
|
**Schema:**
|
|
216
|
+
|
|
212
217
|
```typescript
|
|
213
218
|
{
|
|
214
219
|
format: "plain" | "html" | "markdown",
|
|
@@ -231,15 +236,16 @@ Notes are only visible to support staff (admins and bots), never to customers.
|
|
|
231
236
|
|
|
232
237
|
```typescript
|
|
233
238
|
await send({
|
|
234
|
-
type:
|
|
239
|
+
type: 'note',
|
|
235
240
|
payload: {
|
|
236
|
-
format:
|
|
237
|
-
text:
|
|
241
|
+
format: 'markdown',
|
|
242
|
+
text: 'Internal note: Customer has billing issues in CRM',
|
|
238
243
|
},
|
|
239
|
-
})
|
|
244
|
+
})
|
|
240
245
|
```
|
|
241
246
|
|
|
242
247
|
**Schema:**
|
|
248
|
+
|
|
243
249
|
```typescript
|
|
244
250
|
{
|
|
245
251
|
format: "plain" | "html" | "markdown",
|
|
@@ -258,20 +264,20 @@ Activities represent system events like assignment changes, status changes, etc.
|
|
|
258
264
|
|
|
259
265
|
```typescript
|
|
260
266
|
await send({
|
|
261
|
-
type:
|
|
267
|
+
type: 'activity',
|
|
262
268
|
payload: {
|
|
263
|
-
type:
|
|
269
|
+
type: 'ticket.activity',
|
|
264
270
|
private: true,
|
|
265
271
|
activity: {
|
|
266
|
-
type:
|
|
272
|
+
type: 'ticket.assigned',
|
|
267
273
|
assignedTo: {
|
|
268
|
-
type:
|
|
269
|
-
id:
|
|
270
|
-
reply_as:
|
|
274
|
+
type: 'bot',
|
|
275
|
+
id: 'ibot_abc123',
|
|
276
|
+
reply_as: 'SupportBot',
|
|
271
277
|
},
|
|
272
278
|
},
|
|
273
279
|
},
|
|
274
|
-
})
|
|
280
|
+
})
|
|
275
281
|
```
|
|
276
282
|
|
|
277
283
|
**Activity Types:** `ticket.snoozed`, `ticket.unsnoozed`, `ticket.assigned`, `ticket.unassigned`, `ticket.closed`, `ticket.reopened`, `ticket.renamed`, `ticket.tags_updated`
|
|
@@ -283,20 +289,18 @@ await send({
|
|
|
283
289
|
### Complete Handler Structure
|
|
284
290
|
|
|
285
291
|
```typescript
|
|
286
|
-
import { Autonomous, context, Conversation, z } from
|
|
287
|
-
import { actions, joinMarkdownChildren, TranscriptItem } from
|
|
292
|
+
import { Autonomous, context, Conversation, z } from '@botpress/runtime'
|
|
293
|
+
import { actions, joinMarkdownChildren, TranscriptItem } from '@botpress/runtime/runtime'
|
|
288
294
|
|
|
289
295
|
export default new Conversation({
|
|
290
|
-
channel:
|
|
296
|
+
channel: 'desk.ticket',
|
|
291
297
|
state: z.object({
|
|
292
298
|
customer: z.object({
|
|
293
299
|
id: z.string(),
|
|
294
300
|
name: z.string(),
|
|
295
301
|
email: z.string().optional(),
|
|
296
302
|
}),
|
|
297
|
-
admins: z.array(
|
|
298
|
-
z.object({ id: z.string(), name: z.string(), email: z.string().optional() })
|
|
299
|
-
),
|
|
303
|
+
admins: z.array(z.object({ id: z.string(), name: z.string(), email: z.string().optional() })),
|
|
300
304
|
ticket: z.object({
|
|
301
305
|
id: z.string(),
|
|
302
306
|
title: z.string(),
|
|
@@ -305,13 +309,13 @@ export default new Conversation({
|
|
|
305
309
|
assignedTo: z.string().optional(),
|
|
306
310
|
createdAt: z.string(),
|
|
307
311
|
}),
|
|
308
|
-
lastSync: z.string().default(
|
|
312
|
+
lastSync: z.string().default(''),
|
|
309
313
|
}),
|
|
310
|
-
events: [
|
|
314
|
+
events: ['desk:ticketActivity'],
|
|
311
315
|
handler: async ({ type, conversation, message, state, event, execute, client }) => {
|
|
312
316
|
// ... handler logic
|
|
313
317
|
},
|
|
314
|
-
})
|
|
318
|
+
})
|
|
315
319
|
```
|
|
316
320
|
|
|
317
321
|
### Assignment Check Pattern (CRITICAL)
|
|
@@ -320,15 +324,16 @@ export default new Conversation({
|
|
|
320
324
|
|
|
321
325
|
```typescript
|
|
322
326
|
handler: async ({ conversation }) => {
|
|
323
|
-
if (conversation.tags[
|
|
324
|
-
console.log(
|
|
325
|
-
return
|
|
327
|
+
if (conversation.tags['desk:dassignedself'] !== 'true') {
|
|
328
|
+
console.log('Ticket not assigned to bot, ignoring...')
|
|
329
|
+
return
|
|
326
330
|
}
|
|
327
331
|
// Only process assigned tickets below this line
|
|
328
332
|
}
|
|
329
333
|
```
|
|
330
334
|
|
|
331
335
|
**Why?** The Desk integration fires events for ALL ticket activity. Without the assignment check:
|
|
336
|
+
|
|
332
337
|
- Your bot processes every ticket in the workspace
|
|
333
338
|
- Customers receive confusing or duplicate responses
|
|
334
339
|
- Unnecessary resource and API consumption
|
|
@@ -341,8 +346,8 @@ Sync messages to maintain conversation context:
|
|
|
341
346
|
handler: async ({ conversation, state, client }) => {
|
|
342
347
|
// Check assignment first...
|
|
343
348
|
|
|
344
|
-
const chat = context.get(
|
|
345
|
-
const transcript = await chat.fetchTranscript()
|
|
349
|
+
const chat = context.get('chat')
|
|
350
|
+
const transcript = await chat.fetchTranscript()
|
|
346
351
|
|
|
347
352
|
const messages = await client._inner.list
|
|
348
353
|
.messages({
|
|
@@ -350,28 +355,27 @@ handler: async ({ conversation, state, client }) => {
|
|
|
350
355
|
afterDate: state.lastSync,
|
|
351
356
|
})
|
|
352
357
|
.collect({})
|
|
353
|
-
.then((messages) =>
|
|
354
|
-
messages.sort((a, b) => (a.createdAt < b.createdAt ? -1 : 1))
|
|
355
|
-
);
|
|
358
|
+
.then((messages) => messages.sort((a, b) => (a.createdAt < b.createdAt ? -1 : 1)))
|
|
356
359
|
|
|
357
360
|
const newMessages = [
|
|
358
361
|
...transcript,
|
|
359
|
-
...messages.map(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
362
|
+
...messages.map(
|
|
363
|
+
(m) =>
|
|
364
|
+
({
|
|
365
|
+
id: m.id,
|
|
366
|
+
content: JSON.stringify(m.payload),
|
|
367
|
+
createdAt: m.createdAt,
|
|
368
|
+
role: m.direction === 'incoming' ? 'user' : 'assistant',
|
|
369
|
+
attachments: [],
|
|
370
|
+
name: m.userId,
|
|
371
|
+
}) satisfies TranscriptItem
|
|
372
|
+
),
|
|
373
|
+
]
|
|
368
374
|
|
|
369
|
-
chat.setTranscript(newMessages)
|
|
375
|
+
chat.setTranscript(newMessages)
|
|
370
376
|
|
|
371
|
-
state.lastSync = newMessages
|
|
372
|
-
|
|
373
|
-
.slice(-1)[0]?.createdAt;
|
|
374
|
-
};
|
|
377
|
+
state.lastSync = newMessages.filter((x) => x.role === 'user' || x.role === 'assistant').slice(-1)[0]?.createdAt
|
|
378
|
+
}
|
|
375
379
|
```
|
|
376
380
|
|
|
377
381
|
> **Note:** Use `context.enterWith()` when reassigning context in async operations. Do not use `context.set("chat", ...)` for full context reassignment.
|
|
@@ -386,41 +390,41 @@ For AI-driven responses, register custom components that map to Desk message typ
|
|
|
386
390
|
|
|
387
391
|
```typescript
|
|
388
392
|
const Reply = new Autonomous.Component({
|
|
389
|
-
name:
|
|
390
|
-
description:
|
|
391
|
-
type:
|
|
393
|
+
name: 'Reply',
|
|
394
|
+
description: 'Sends a reply to the customer, visible to them and via email.',
|
|
395
|
+
type: 'leaf',
|
|
392
396
|
leaf: { props: z.object({}) },
|
|
393
397
|
aliases: [],
|
|
394
398
|
examples: [
|
|
395
399
|
{
|
|
396
|
-
name:
|
|
397
|
-
description:
|
|
400
|
+
name: 'Reply',
|
|
401
|
+
description: 'Sends a reply to the customer',
|
|
398
402
|
code: `
|
|
399
403
|
yield <Message><Reply>
|
|
400
404
|
Some **markdown** reply to the customer!
|
|
401
405
|
</Reply></Message>`,
|
|
402
406
|
},
|
|
403
407
|
],
|
|
404
|
-
})
|
|
408
|
+
})
|
|
405
409
|
```
|
|
406
410
|
|
|
407
411
|
### Note Component
|
|
408
412
|
|
|
409
413
|
```typescript
|
|
410
414
|
const Note = new Autonomous.Component({
|
|
411
|
-
name:
|
|
412
|
-
description:
|
|
413
|
-
type:
|
|
415
|
+
name: 'Note',
|
|
416
|
+
description: 'Adds an internal note to the ticket. Not visible to the customer.',
|
|
417
|
+
type: 'leaf',
|
|
414
418
|
leaf: { props: z.object({}) },
|
|
415
419
|
aliases: [],
|
|
416
420
|
examples: [
|
|
417
421
|
{
|
|
418
|
-
name:
|
|
419
|
-
description:
|
|
422
|
+
name: 'Note',
|
|
423
|
+
description: 'Adds an internal note to the ticket',
|
|
420
424
|
code: `yield <Message><Note>This is a **note** with markdown!</Note></Message>`,
|
|
421
425
|
},
|
|
422
426
|
],
|
|
423
|
-
})
|
|
427
|
+
})
|
|
424
428
|
```
|
|
425
429
|
|
|
426
430
|
### Component Registration
|
|
@@ -429,42 +433,42 @@ const Note = new Autonomous.Component({
|
|
|
429
433
|
handler: async ({ conversation }) => {
|
|
430
434
|
// ... assignment check ...
|
|
431
435
|
|
|
432
|
-
const chat = context.get(
|
|
436
|
+
const chat = context.get('chat')
|
|
433
437
|
|
|
434
438
|
// Remove default message components
|
|
435
|
-
chat.removeComponent(
|
|
436
|
-
chat.removeComponent(
|
|
437
|
-
chat.removeComponent(
|
|
439
|
+
chat.removeComponent('MESSAGE')
|
|
440
|
+
chat.removeComponent('Text')
|
|
441
|
+
chat.removeComponent('TEXT')
|
|
438
442
|
|
|
439
443
|
// Register Reply component
|
|
440
444
|
chat.registerComponent({
|
|
441
445
|
component: Reply as any,
|
|
442
446
|
handler: async ({ props, children }) => {
|
|
443
447
|
await conversation.send({
|
|
444
|
-
type:
|
|
445
|
-
payload: { format:
|
|
446
|
-
})
|
|
448
|
+
type: 'text',
|
|
449
|
+
payload: { format: 'markdown', text: joinMarkdownChildren(children) },
|
|
450
|
+
})
|
|
447
451
|
},
|
|
448
|
-
})
|
|
452
|
+
})
|
|
449
453
|
|
|
450
454
|
// Register Note component
|
|
451
455
|
chat.registerComponent({
|
|
452
456
|
component: Note as any,
|
|
453
457
|
handler: async ({ props, children }) => {
|
|
454
458
|
await conversation.send({
|
|
455
|
-
type:
|
|
456
|
-
payload: { format:
|
|
457
|
-
})
|
|
459
|
+
type: 'note',
|
|
460
|
+
payload: { format: 'markdown', text: joinMarkdownChildren(children) },
|
|
461
|
+
})
|
|
458
462
|
},
|
|
459
|
-
})
|
|
463
|
+
})
|
|
460
464
|
|
|
461
465
|
// Update chat context with new components
|
|
462
466
|
const newChat = Object.assign(chat, {
|
|
463
467
|
getComponents: async () => [Reply, Note],
|
|
464
|
-
} satisfies Partial<typeof chat>)
|
|
468
|
+
} satisfies Partial<typeof chat>)
|
|
465
469
|
|
|
466
|
-
context.enterWith({ ...context.getAll(), chat: newChat })
|
|
467
|
-
}
|
|
470
|
+
context.enterWith({ ...context.getAll(), chat: newChat })
|
|
471
|
+
}
|
|
468
472
|
```
|
|
469
473
|
|
|
470
474
|
---
|
|
@@ -478,22 +482,22 @@ The Desk integration provides 11 actions for ticket management.
|
|
|
478
482
|
```typescript
|
|
479
483
|
// listTickets - List tickets with pagination
|
|
480
484
|
const result = await actions.desk.listTickets({
|
|
481
|
-
orderBy:
|
|
482
|
-
orderDirection:
|
|
485
|
+
orderBy: 'updatedAt',
|
|
486
|
+
orderDirection: 'desc',
|
|
483
487
|
limit: 50,
|
|
484
488
|
cursor: undefined,
|
|
485
|
-
})
|
|
489
|
+
})
|
|
486
490
|
// Returns: { tickets: Ticket[], hasMore: boolean, nextCursor?: string }
|
|
487
491
|
|
|
488
492
|
// getTicket - Get a single ticket by ID
|
|
489
|
-
const result = await actions.desk.getTicket({ id:
|
|
493
|
+
const result = await actions.desk.getTicket({ id: 'tkt_abc123' })
|
|
490
494
|
|
|
491
495
|
// listTicketActivities - List activities for a ticket
|
|
492
496
|
const result = await actions.desk.listTicketActivities({
|
|
493
|
-
ticketId:
|
|
497
|
+
ticketId: 'tkt_abc123',
|
|
494
498
|
limit: 50,
|
|
495
499
|
cursor: undefined,
|
|
496
|
-
})
|
|
500
|
+
})
|
|
497
501
|
```
|
|
498
502
|
|
|
499
503
|
### Assignment Actions
|
|
@@ -501,31 +505,31 @@ const result = await actions.desk.listTicketActivities({
|
|
|
501
505
|
```typescript
|
|
502
506
|
// assignTicket - Assign to admin or bot
|
|
503
507
|
await actions.desk.assignTicket({
|
|
504
|
-
ticketId:
|
|
505
|
-
assigneeId:
|
|
506
|
-
})
|
|
508
|
+
ticketId: 'tkt_abc123',
|
|
509
|
+
assigneeId: 'adm_xyz789', // or "ibot_..." for a bot
|
|
510
|
+
})
|
|
507
511
|
|
|
508
512
|
// unassignTicket - Remove assignment
|
|
509
|
-
await actions.desk.unassignTicket({ ticketId:
|
|
513
|
+
await actions.desk.unassignTicket({ ticketId: 'tkt_abc123' })
|
|
510
514
|
```
|
|
511
515
|
|
|
512
516
|
### Lifecycle Actions
|
|
513
517
|
|
|
514
518
|
```typescript
|
|
515
519
|
// closeTicket
|
|
516
|
-
await actions.desk.closeTicket({ ticketId:
|
|
520
|
+
await actions.desk.closeTicket({ ticketId: 'tkt_abc123' })
|
|
517
521
|
|
|
518
522
|
// reopenTicket
|
|
519
|
-
await actions.desk.reopenTicket({ ticketId:
|
|
523
|
+
await actions.desk.reopenTicket({ ticketId: 'tkt_abc123' })
|
|
520
524
|
|
|
521
525
|
// snoozeTicket
|
|
522
526
|
await actions.desk.snoozeTicket({
|
|
523
|
-
ticketId:
|
|
524
|
-
snoozedUntil:
|
|
525
|
-
})
|
|
527
|
+
ticketId: 'tkt_abc123',
|
|
528
|
+
snoozedUntil: '2025-01-21T09:00:00Z',
|
|
529
|
+
})
|
|
526
530
|
|
|
527
531
|
// unsnoozeTicket
|
|
528
|
-
await actions.desk.unsnoozeTicket({ ticketId:
|
|
532
|
+
await actions.desk.unsnoozeTicket({ ticketId: 'tkt_abc123' })
|
|
529
533
|
```
|
|
530
534
|
|
|
531
535
|
### Metadata Actions
|
|
@@ -533,21 +537,21 @@ await actions.desk.unsnoozeTicket({ ticketId: "tkt_abc123" });
|
|
|
533
537
|
```typescript
|
|
534
538
|
// renameTicket
|
|
535
539
|
await actions.desk.renameTicket({
|
|
536
|
-
ticketId:
|
|
537
|
-
title:
|
|
538
|
-
})
|
|
540
|
+
ticketId: 'tkt_abc123',
|
|
541
|
+
title: 'Updated: Login Issue with 2FA',
|
|
542
|
+
})
|
|
539
543
|
|
|
540
544
|
// addTags
|
|
541
545
|
await actions.desk.addTags({
|
|
542
|
-
ticketId:
|
|
543
|
-
tags: [
|
|
544
|
-
})
|
|
546
|
+
ticketId: 'tkt_abc123',
|
|
547
|
+
tags: ['urgent', 'billing', 'enterprise'],
|
|
548
|
+
})
|
|
545
549
|
|
|
546
550
|
// removeTags
|
|
547
551
|
await actions.desk.removeTags({
|
|
548
|
-
ticketId:
|
|
549
|
-
tags: [
|
|
550
|
-
})
|
|
552
|
+
ticketId: 'tkt_abc123',
|
|
553
|
+
tags: ['low-priority'],
|
|
554
|
+
})
|
|
551
555
|
```
|
|
552
556
|
|
|
553
557
|
---
|
|
@@ -560,7 +564,7 @@ Convert Desk actions to AI-callable tools using `asTool()` and `setStaticInputVa
|
|
|
560
564
|
handler: async ({ conversation, execute }) => {
|
|
561
565
|
// Check assignment...
|
|
562
566
|
|
|
563
|
-
const ticketId = conversation.tags[
|
|
567
|
+
const ticketId = conversation.tags['desk:did']
|
|
564
568
|
|
|
565
569
|
// Create tools with bound ticketId
|
|
566
570
|
const tools = [
|
|
@@ -569,13 +573,13 @@ handler: async ({ conversation, execute }) => {
|
|
|
569
573
|
actions.desk.snoozeTicket.asTool().setStaticInputValues({ ticketId }),
|
|
570
574
|
actions.desk.addTags.asTool().setStaticInputValues({ ticketId }),
|
|
571
575
|
actions.desk.removeTags.asTool().setStaticInputValues({ ticketId }),
|
|
572
|
-
]
|
|
576
|
+
]
|
|
573
577
|
|
|
574
578
|
await execute({
|
|
575
579
|
tools,
|
|
576
|
-
instructions:
|
|
577
|
-
})
|
|
578
|
-
}
|
|
580
|
+
instructions: 'You are a helpful support agent...',
|
|
581
|
+
})
|
|
582
|
+
}
|
|
579
583
|
```
|
|
580
584
|
|
|
581
585
|
---
|
|
@@ -586,18 +590,16 @@ handler: async ({ conversation, execute }) => {
|
|
|
586
590
|
|
|
587
591
|
```typescript
|
|
588
592
|
handler: async ({ conversation, execute }) => {
|
|
589
|
-
if (conversation.tags[
|
|
593
|
+
if (conversation.tags['desk:dassignedself'] !== 'true') return
|
|
590
594
|
|
|
591
|
-
const ticketId = conversation.tags[
|
|
595
|
+
const ticketId = conversation.tags['desk:did']
|
|
592
596
|
|
|
593
|
-
const UnassignTool = actions.desk.unassignTicket
|
|
594
|
-
.asTool()
|
|
595
|
-
.setStaticInputValues({ ticketId });
|
|
597
|
+
const UnassignTool = actions.desk.unassignTicket.asTool().setStaticInputValues({ ticketId })
|
|
596
598
|
|
|
597
599
|
await execute({
|
|
598
600
|
iterations: 5,
|
|
599
601
|
tools: [UnassignTool],
|
|
600
|
-
model:
|
|
602
|
+
model: 'anthropic:claude-sonnet-4-20250514',
|
|
601
603
|
instructions: `You are a helpful assistant for customer support tickets.
|
|
602
604
|
|
|
603
605
|
You can choose to:
|
|
@@ -614,19 +616,21 @@ You can choose to:
|
|
|
614
616
|
## Current Ticket
|
|
615
617
|
${JSON.stringify(conversation.tags, null, 2)}
|
|
616
618
|
`,
|
|
617
|
-
})
|
|
618
|
-
}
|
|
619
|
+
})
|
|
620
|
+
}
|
|
619
621
|
```
|
|
620
622
|
|
|
621
623
|
### System Prompt Guidelines
|
|
622
624
|
|
|
623
625
|
**DO:**
|
|
626
|
+
|
|
624
627
|
- Explain when to use Reply vs Note
|
|
625
628
|
- Set clear escalation criteria
|
|
626
629
|
- Include ticket context via tags
|
|
627
630
|
- Define what "taking no action" means
|
|
628
631
|
|
|
629
632
|
**DON'T:**
|
|
633
|
+
|
|
630
634
|
- Allow direct customer replies without components
|
|
631
635
|
- Let the bot make up information
|
|
632
636
|
- Process messages the bot sent itself
|
|
@@ -642,35 +646,35 @@ When a bot needs to hand off to a human agent, follow this 4-step pattern:
|
|
|
642
646
|
async function escalateToHuman(conversation: any, reason: string): Promise<void> {
|
|
643
647
|
// Step 1: Internal note explaining why
|
|
644
648
|
await conversation.send({
|
|
645
|
-
type:
|
|
649
|
+
type: 'note',
|
|
646
650
|
payload: {
|
|
647
|
-
format:
|
|
651
|
+
format: 'markdown',
|
|
648
652
|
text: `Escalating to human: ${reason}`,
|
|
649
653
|
},
|
|
650
|
-
})
|
|
654
|
+
})
|
|
651
655
|
|
|
652
656
|
// Step 2: Customer reply
|
|
653
657
|
await conversation.send({
|
|
654
|
-
type:
|
|
658
|
+
type: 'text',
|
|
655
659
|
payload: {
|
|
656
|
-
format:
|
|
660
|
+
format: 'markdown',
|
|
657
661
|
text: "I've connected you with a member of our team who can help. They'll be with you shortly!",
|
|
658
662
|
},
|
|
659
|
-
})
|
|
663
|
+
})
|
|
660
664
|
|
|
661
665
|
// Step 3: Unassign bot
|
|
662
666
|
await actions.desk.unassignTicket({
|
|
663
|
-
ticketId: conversation.tags[
|
|
664
|
-
})
|
|
667
|
+
ticketId: conversation.tags['desk:did'],
|
|
668
|
+
})
|
|
665
669
|
}
|
|
666
670
|
|
|
667
671
|
// In handler:
|
|
668
672
|
handler: async ({ conversation }) => {
|
|
669
|
-
if (conversation.tags[
|
|
673
|
+
if (conversation.tags['desk:dassignedself'] !== 'true') return
|
|
670
674
|
|
|
671
675
|
if (needsEscalation) {
|
|
672
|
-
await escalateToHuman(conversation,
|
|
673
|
-
return
|
|
676
|
+
await escalateToHuman(conversation, 'Complex billing issue')
|
|
677
|
+
return // Step 4: Stop processing
|
|
674
678
|
}
|
|
675
679
|
// ... continue normal processing
|
|
676
680
|
}
|
|
@@ -691,20 +695,20 @@ handler: async ({ conversation }) => {
|
|
|
691
695
|
|
|
692
696
|
```typescript
|
|
693
697
|
interface Ticket {
|
|
694
|
-
id: string
|
|
695
|
-
title: string
|
|
696
|
-
customer: Customer
|
|
697
|
-
priority:
|
|
698
|
-
system:
|
|
699
|
-
systemTicketId: string
|
|
700
|
-
assignedTo?: Admin | Bot
|
|
701
|
-
status:
|
|
702
|
-
createdAt: string
|
|
703
|
-
updatedAt: string
|
|
704
|
-
closedAt?: string
|
|
705
|
-
snoozedUntil?: string
|
|
706
|
-
tags: string[]
|
|
707
|
-
metadata?: Record<string, any
|
|
698
|
+
id: string // "tkt_abc123"
|
|
699
|
+
title: string
|
|
700
|
+
customer: Customer
|
|
701
|
+
priority: 'low' | 'medium' | 'high' | 'urgent'
|
|
702
|
+
system: 'native' | 'intercom' | 'zendesk'
|
|
703
|
+
systemTicketId: string
|
|
704
|
+
assignedTo?: Admin | Bot
|
|
705
|
+
status: 'open' | 'closed' | 'snoozed'
|
|
706
|
+
createdAt: string
|
|
707
|
+
updatedAt: string
|
|
708
|
+
closedAt?: string
|
|
709
|
+
snoozedUntil?: string
|
|
710
|
+
tags: string[]
|
|
711
|
+
metadata?: Record<string, any>
|
|
708
712
|
}
|
|
709
713
|
```
|
|
710
714
|
|
|
@@ -712,11 +716,11 @@ interface Ticket {
|
|
|
712
716
|
|
|
713
717
|
```typescript
|
|
714
718
|
interface Customer {
|
|
715
|
-
id: string
|
|
716
|
-
name?: string
|
|
717
|
-
email?: string
|
|
718
|
-
phone?: string
|
|
719
|
-
avatarUrl?: string
|
|
719
|
+
id: string // "cus_xyz789"
|
|
720
|
+
name?: string
|
|
721
|
+
email?: string
|
|
722
|
+
phone?: string
|
|
723
|
+
avatarUrl?: string
|
|
720
724
|
}
|
|
721
725
|
```
|
|
722
726
|
|
|
@@ -724,10 +728,10 @@ interface Customer {
|
|
|
724
728
|
|
|
725
729
|
```typescript
|
|
726
730
|
interface Admin {
|
|
727
|
-
id: string
|
|
728
|
-
name: string
|
|
729
|
-
email: string
|
|
730
|
-
avatarUrl?: string
|
|
731
|
+
id: string // "adm_abc123"
|
|
732
|
+
name: string
|
|
733
|
+
email: string
|
|
734
|
+
avatarUrl?: string
|
|
731
735
|
}
|
|
732
736
|
```
|
|
733
737
|
|
|
@@ -735,11 +739,11 @@ interface Admin {
|
|
|
735
739
|
|
|
736
740
|
```typescript
|
|
737
741
|
interface Bot {
|
|
738
|
-
id: string
|
|
739
|
-
displayName: string
|
|
740
|
-
displayAvatarUrl?: string
|
|
741
|
-
botHandle: string
|
|
742
|
-
canBeAssigned: boolean
|
|
742
|
+
id: string // "ibot_def456"
|
|
743
|
+
displayName: string
|
|
744
|
+
displayAvatarUrl?: string
|
|
745
|
+
botHandle: string
|
|
746
|
+
canBeAssigned: boolean
|
|
743
747
|
}
|
|
744
748
|
```
|
|
745
749
|
|
|
@@ -747,16 +751,16 @@ interface Bot {
|
|
|
747
751
|
|
|
748
752
|
```typescript
|
|
749
753
|
interface Activity {
|
|
750
|
-
id: string
|
|
751
|
-
ticketId: string
|
|
752
|
-
activityType:
|
|
753
|
-
authorType:
|
|
754
|
-
authorId: string
|
|
755
|
-
body: string
|
|
756
|
-
bodyFormat:
|
|
757
|
-
isRedacted: boolean
|
|
758
|
-
createdAt: string
|
|
759
|
-
updatedAt: string
|
|
754
|
+
id: string // "tka_abc123"
|
|
755
|
+
ticketId: string
|
|
756
|
+
activityType: 'comment' | 'note' | 'system_public' | 'system_internal'
|
|
757
|
+
authorType: 'admin' | 'customer' | 'bot' | 'user'
|
|
758
|
+
authorId: string
|
|
759
|
+
body: string
|
|
760
|
+
bodyFormat: 'plain' | 'html' | 'markdown' | 'json'
|
|
761
|
+
isRedacted: boolean
|
|
762
|
+
createdAt: string
|
|
763
|
+
updatedAt: string
|
|
760
764
|
}
|
|
761
765
|
```
|
|
762
766
|
|
|
@@ -764,14 +768,14 @@ interface Activity {
|
|
|
764
768
|
|
|
765
769
|
```typescript
|
|
766
770
|
type TicketActivityType =
|
|
767
|
-
| { type:
|
|
768
|
-
| { type:
|
|
769
|
-
| { type:
|
|
770
|
-
| { type:
|
|
771
|
-
| { type:
|
|
772
|
-
| { type:
|
|
773
|
-
| { type:
|
|
774
|
-
| { type:
|
|
771
|
+
| { type: 'ticket.snoozed'; author: Author }
|
|
772
|
+
| { type: 'ticket.unsnoozed'; author: Author }
|
|
773
|
+
| { type: 'ticket.assigned'; assignedTo: { type: 'admin' | 'bot'; id: string; reply_as?: string } }
|
|
774
|
+
| { type: 'ticket.unassigned'; author: Author }
|
|
775
|
+
| { type: 'ticket.closed'; author: Author }
|
|
776
|
+
| { type: 'ticket.reopened'; author: Author }
|
|
777
|
+
| { type: 'ticket.renamed'; title: string }
|
|
778
|
+
| { type: 'ticket.tags_updated'; author: Author; added: string[]; removed: string[] }
|
|
775
779
|
```
|
|
776
780
|
|
|
777
781
|
---
|
|
@@ -797,42 +801,40 @@ handler: async ({ conversation, execute }) => {
|
|
|
797
801
|
|
|
798
802
|
```typescript
|
|
799
803
|
// ❌ WRONG - Customer sees internal info
|
|
800
|
-
await send({ type:
|
|
804
|
+
await send({ type: 'text', payload: { text: 'Customer has overdue invoices in CRM' } })
|
|
801
805
|
|
|
802
806
|
// ✅ CORRECT - Note for internal communication
|
|
803
|
-
await send({ type:
|
|
807
|
+
await send({ type: 'note', payload: { text: 'Customer has overdue invoices in CRM' } })
|
|
804
808
|
```
|
|
805
809
|
|
|
806
810
|
### Not Extracting ticketId for Tools
|
|
807
811
|
|
|
808
812
|
```typescript
|
|
809
813
|
// ❌ WRONG - Tool has no ticketId
|
|
810
|
-
const UnassignTool = actions.desk.unassignTicket.asTool()
|
|
814
|
+
const UnassignTool = actions.desk.unassignTicket.asTool()
|
|
811
815
|
|
|
812
816
|
// ✅ CORRECT - Bind ticketId
|
|
813
|
-
const ticketId = conversation.tags[
|
|
814
|
-
const UnassignTool = actions.desk.unassignTicket
|
|
815
|
-
.asTool()
|
|
816
|
-
.setStaticInputValues({ ticketId });
|
|
817
|
+
const ticketId = conversation.tags['desk:did']
|
|
818
|
+
const UnassignTool = actions.desk.unassignTicket.asTool().setStaticInputValues({ ticketId })
|
|
817
819
|
```
|
|
818
820
|
|
|
819
821
|
### Using Wrong Tag Names
|
|
820
822
|
|
|
821
823
|
```typescript
|
|
822
824
|
// ❌ WRONG
|
|
823
|
-
conversation.tags[
|
|
824
|
-
conversation.tags[
|
|
825
|
+
conversation.tags['deskId']
|
|
826
|
+
conversation.tags['desk:assignedSelf'] // wrong case
|
|
825
827
|
|
|
826
828
|
// ✅ CORRECT
|
|
827
|
-
conversation.tags[
|
|
828
|
-
conversation.tags[
|
|
829
|
+
conversation.tags['desk:did']
|
|
830
|
+
conversation.tags['desk:dassignedself'] // lowercase
|
|
829
831
|
```
|
|
830
832
|
|
|
831
833
|
### Replying to Every Message
|
|
832
834
|
|
|
833
835
|
```typescript
|
|
834
836
|
// ❌ WRONG
|
|
835
|
-
instructions:
|
|
837
|
+
instructions: 'Always reply to every message from the customer'
|
|
836
838
|
|
|
837
839
|
// ✅ CORRECT
|
|
838
840
|
instructions: `You DON'T have to reply to every message.
|