@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.
Files changed (233) 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/config-writer.d.ts.map +1 -1
  8. package/dist/agent-project/dependencies-parser.d.ts.map +1 -1
  9. package/dist/agent-project/dependency-state-to-dependencies.d.ts +11 -0
  10. package/dist/agent-project/dependency-state-to-dependencies.d.ts.map +1 -0
  11. package/dist/agent-project/file-watcher.d.ts.map +1 -1
  12. package/dist/agent-project/types.d.ts +9 -4
  13. package/dist/agent-project/types.d.ts.map +1 -1
  14. package/dist/agent0/capabilities/commands/adk-build.md +6 -5
  15. package/dist/agent0/capabilities/commands/adk-debug.md +1 -1
  16. package/dist/agent0/capabilities/commands/adk-dev-console.md +1 -1
  17. package/dist/agent0/capabilities/commands/adk-document.md +10 -2
  18. package/dist/agent0/capabilities/commands/adk-eval.md +1 -1
  19. package/dist/agent0/capabilities/commands/adk-explain.md +2 -2
  20. package/dist/agent0/capabilities/commands/adk-init.md +2 -2
  21. package/dist/agent0/capabilities/commands/adk-ship.md +1 -1
  22. package/dist/agent0/capabilities/commands/adk-test.md +3 -3
  23. package/dist/agent0/capabilities/commands/adk-validate.md +3 -3
  24. package/dist/agent0/capabilities/skills/adk/SKILL.md +21 -21
  25. package/dist/agent0/capabilities/skills/adk/references/actions.md +245 -239
  26. package/dist/agent0/capabilities/skills/adk/references/advanced-patterns.md +185 -218
  27. package/dist/agent0/capabilities/skills/adk/references/agent-config.md +74 -71
  28. package/dist/agent0/capabilities/skills/adk/references/assets.md +45 -48
  29. package/dist/agent0/capabilities/skills/adk/references/autonomous-execution.md +40 -46
  30. package/dist/agent0/capabilities/skills/adk/references/cli.md +17 -7
  31. package/dist/agent0/capabilities/skills/adk/references/context-api.md +98 -94
  32. package/dist/agent0/capabilities/skills/adk/references/conversation-lifecycle.md +65 -62
  33. package/dist/agent0/capabilities/skills/adk/references/conversations.md +395 -385
  34. package/dist/agent0/capabilities/skills/adk/references/custom-components.md +1 -1
  35. package/dist/agent0/capabilities/skills/adk/references/desk.md +236 -234
  36. package/dist/agent0/capabilities/skills/adk/references/explain-config.md +54 -37
  37. package/dist/agent0/capabilities/skills/adk/references/files.md +301 -306
  38. package/dist/agent0/capabilities/skills/adk/references/integration-actions.md +211 -214
  39. package/dist/agent0/capabilities/skills/adk/references/integrations.md +33 -31
  40. package/dist/agent0/capabilities/skills/adk/references/interfaces.md +13 -12
  41. package/dist/agent0/capabilities/skills/adk/references/knowledge-bases.md +98 -111
  42. package/dist/agent0/capabilities/skills/adk/references/mcp-server.md +6 -0
  43. package/dist/agent0/capabilities/skills/adk/references/messages.md +280 -256
  44. package/dist/agent0/capabilities/skills/adk/references/model-configuration.md +52 -49
  45. package/dist/agent0/capabilities/skills/adk/references/patterns-mistakes.md +102 -101
  46. package/dist/agent0/capabilities/skills/adk/references/plugins.md +15 -15
  47. package/dist/agent0/capabilities/skills/adk/references/tables.md +204 -210
  48. package/dist/agent0/capabilities/skills/adk/references/tags.md +141 -143
  49. package/dist/agent0/capabilities/skills/adk/references/tools.md +191 -199
  50. package/dist/agent0/capabilities/skills/adk/references/triggers.md +331 -336
  51. package/dist/agent0/capabilities/skills/adk/references/workflow-steps.md +132 -96
  52. package/dist/agent0/capabilities/skills/adk/references/workflows.md +479 -464
  53. package/dist/agent0/capabilities/skills/adk/references/zai-agent-reference.md +127 -129
  54. package/dist/agent0/capabilities/skills/adk/references/zai-complete-guide.md +255 -276
  55. package/dist/agent0/capabilities/skills/adk-debugger/SKILL.md +21 -17
  56. package/dist/agent0/capabilities/skills/adk-debugger/references/common-failures.md +25 -25
  57. package/dist/agent0/capabilities/skills/adk-debugger/references/conversation-analysis.md +49 -41
  58. package/dist/agent0/capabilities/skills/adk-debugger/references/debug-workflow.md +20 -14
  59. package/dist/agent0/capabilities/skills/adk-debugger/references/llm-debugging.md +13 -13
  60. package/dist/agent0/capabilities/skills/adk-debugger/references/trace-summarization.md +18 -18
  61. package/dist/agent0/capabilities/skills/adk-debugger/references/traces-and-logs.md +67 -67
  62. package/dist/agent0/capabilities/skills/adk-dev-console/SKILL.md +36 -36
  63. package/dist/agent0/capabilities/skills/adk-dev-console/references/agent-steps.md +14 -6
  64. package/dist/agent0/capabilities/skills/adk-dev-console/references/multi-agent-dashboard.md +13 -13
  65. package/dist/agent0/capabilities/skills/adk-dev-console/references/pages.md +18 -0
  66. package/dist/agent0/capabilities/skills/adk-docs/SKILL.md +13 -13
  67. package/dist/agent0/capabilities/skills/adk-docs/references/doc-standards.md +15 -0
  68. package/dist/agent0/capabilities/skills/adk-evals/SKILL.md +29 -23
  69. package/dist/agent0/capabilities/skills/adk-evals/references/eval-format.md +31 -23
  70. package/dist/agent0/capabilities/skills/adk-evals/references/test-patterns.md +25 -36
  71. package/dist/agent0/capabilities/skills/adk-evals/references/testing-workflow.md +6 -4
  72. package/dist/agent0/config/schema.d.ts.map +1 -1
  73. package/dist/agent0/config/store.d.ts +8 -3
  74. package/dist/agent0/config/store.d.ts.map +1 -1
  75. package/dist/agent0/index.js +214 -59
  76. package/dist/agent0/index.js.map +17 -15
  77. package/dist/agent0/providers/catalog.d.ts.map +1 -1
  78. package/dist/agent0/providers/registry.d.ts.map +1 -1
  79. package/dist/agent0/providers/source.d.ts +8 -3
  80. package/dist/agent0/providers/source.d.ts.map +1 -1
  81. package/dist/agent0/runtime/client.d.ts +4 -3
  82. package/dist/agent0/runtime/client.d.ts.map +1 -1
  83. package/dist/agent0/runtime/engine.d.ts +7 -1
  84. package/dist/agent0/runtime/engine.d.ts.map +1 -1
  85. package/dist/agent0/runtime/manager.d.ts +2 -3
  86. package/dist/agent0/runtime/manager.d.ts.map +1 -1
  87. package/dist/agent0/runtime/process.d.ts +10 -0
  88. package/dist/agent0/runtime/process.d.ts.map +1 -1
  89. package/dist/assets/manager.d.ts +3 -0
  90. package/dist/assets/manager.d.ts.map +1 -1
  91. package/dist/auth/credentials.d.ts +1 -1
  92. package/dist/auth/credentials.d.ts.map +1 -1
  93. package/dist/auth/index.d.ts.map +1 -1
  94. package/dist/auth/service.d.ts.map +1 -1
  95. package/dist/bot-generator/generator.d.ts +22 -0
  96. package/dist/bot-generator/generator.d.ts.map +1 -1
  97. package/dist/bot-generator/integration-sync.d.ts +2 -0
  98. package/dist/bot-generator/integration-sync.d.ts.map +1 -1
  99. package/dist/bot-generator/interface-sync.d.ts +2 -0
  100. package/dist/bot-generator/interface-sync.d.ts.map +1 -1
  101. package/dist/bot-generator/plugin-sync.d.ts +2 -0
  102. package/dist/bot-generator/plugin-sync.d.ts.map +1 -1
  103. package/dist/cognitive/models.d.ts.map +1 -1
  104. package/dist/commands/base-command.d.ts +1 -0
  105. package/dist/commands/base-command.d.ts.map +1 -1
  106. package/dist/commands/bp-cli.d.ts.map +1 -1
  107. package/dist/commands/bp-cli.js +147 -0
  108. package/dist/commands/bp-cli.js.map +12 -0
  109. package/dist/commands/bp-dev-command.d.ts +3 -1
  110. package/dist/commands/bp-dev-command.d.ts.map +1 -1
  111. package/dist/commands/bp-dev-stderr.d.ts +9 -0
  112. package/dist/commands/bp-dev-stderr.d.ts.map +1 -1
  113. package/dist/commands/bp-dev-worker-env.d.ts +7 -0
  114. package/dist/commands/bp-dev-worker-env.d.ts.map +1 -0
  115. package/dist/commands/index.d.ts +1 -0
  116. package/dist/commands/index.d.ts.map +1 -1
  117. package/dist/config/manager.d.ts.map +1 -1
  118. package/dist/dependencies/catalog/catalog-service.d.ts +53 -0
  119. package/dist/dependencies/catalog/catalog-service.d.ts.map +1 -0
  120. package/dist/dependencies/catalog/client-factory.d.ts +33 -0
  121. package/dist/dependencies/catalog/client-factory.d.ts.map +1 -0
  122. package/dist/dependencies/catalog/integration-source.d.ts +34 -0
  123. package/dist/dependencies/catalog/integration-source.d.ts.map +1 -0
  124. package/dist/dependencies/catalog/interface-source.d.ts +23 -0
  125. package/dist/dependencies/catalog/interface-source.d.ts.map +1 -0
  126. package/dist/dependencies/catalog/plugin-source.d.ts +49 -0
  127. package/dist/dependencies/catalog/plugin-source.d.ts.map +1 -0
  128. package/dist/dependencies/catalog/resolution-cache.d.ts +76 -0
  129. package/dist/dependencies/catalog/resolution-cache.d.ts.map +1 -0
  130. package/dist/dependencies/dependency-manager.d.ts +31 -16
  131. package/dist/dependencies/dependency-manager.d.ts.map +1 -1
  132. package/dist/dependencies/errors.d.ts +9 -6
  133. package/dist/dependencies/errors.d.ts.map +1 -1
  134. package/dist/dependencies/index.d.ts +5 -4
  135. package/dist/dependencies/index.d.ts.map +1 -1
  136. package/dist/dependencies/index.js +2309 -1697
  137. package/dist/dependencies/index.js.map +41 -32
  138. package/dist/dependencies/legacy-lock-file.d.ts +15 -0
  139. package/dist/dependencies/legacy-lock-file.d.ts.map +1 -0
  140. package/dist/dependencies/migration.d.ts +19 -0
  141. package/dist/dependencies/migration.d.ts.map +1 -1
  142. package/dist/dependencies/resolvers/integration-resolver.d.ts +4 -3
  143. package/dist/dependencies/resolvers/integration-resolver.d.ts.map +1 -1
  144. package/dist/dependencies/resolvers/plugin-resolver.d.ts +4 -4
  145. package/dist/dependencies/resolvers/plugin-resolver.d.ts.map +1 -1
  146. package/dist/dependencies/snapshot-store.d.ts +59 -0
  147. package/dist/dependencies/snapshot-store.d.ts.map +1 -0
  148. package/dist/dependencies/status-resolver.d.ts +36 -0
  149. package/dist/dependencies/status-resolver.d.ts.map +1 -0
  150. package/dist/dependencies/status.d.ts +214 -0
  151. package/dist/dependencies/status.d.ts.map +1 -0
  152. package/dist/dependencies/types.d.ts +388 -37
  153. package/dist/dependencies/types.d.ts.map +1 -1
  154. package/dist/file-watcher/watcher.d.ts +21 -5
  155. package/dist/file-watcher/watcher.d.ts.map +1 -1
  156. package/dist/generators/action-types.d.ts.map +1 -1
  157. package/dist/generators/client-wrapper.d.ts.map +1 -1
  158. package/dist/index.d.ts +5 -5
  159. package/dist/index.d.ts.map +1 -1
  160. package/dist/index.js +3643 -2345
  161. package/dist/index.js.map +68 -58
  162. package/dist/integrations/config-utils.d.ts +11 -7
  163. package/dist/integrations/config-utils.d.ts.map +1 -1
  164. package/dist/integrations/hub-cache.d.ts +0 -58
  165. package/dist/integrations/hub-cache.d.ts.map +1 -1
  166. package/dist/integrations/index.d.ts +1 -3
  167. package/dist/integrations/index.d.ts.map +1 -1
  168. package/dist/integrations/manager.d.ts +19 -53
  169. package/dist/integrations/manager.d.ts.map +1 -1
  170. package/dist/interfaces/enhanced-cache.d.ts +7 -7
  171. package/dist/interfaces/enhanced-cache.d.ts.map +1 -1
  172. package/dist/interfaces/manager.d.ts +11 -17
  173. package/dist/interfaces/manager.d.ts.map +1 -1
  174. package/dist/interfaces/parser.d.ts.map +1 -1
  175. package/dist/knowledge/manager.d.ts +3 -0
  176. package/dist/knowledge/manager.d.ts.map +1 -1
  177. package/dist/plugins/index.d.ts +0 -1
  178. package/dist/plugins/index.d.ts.map +1 -1
  179. package/dist/plugins/manager.d.ts +16 -48
  180. package/dist/plugins/manager.d.ts.map +1 -1
  181. package/dist/preflight/checker.d.ts +6 -1
  182. package/dist/preflight/checker.d.ts.map +1 -1
  183. package/dist/preflight/dependency-gate.d.ts +37 -0
  184. package/dist/preflight/dependency-gate.d.ts.map +1 -0
  185. package/dist/preflight/index.d.ts +2 -1
  186. package/dist/preflight/index.d.ts.map +1 -1
  187. package/dist/preflight/types.d.ts +18 -0
  188. package/dist/preflight/types.d.ts.map +1 -1
  189. package/dist/runner/script-runner.d.ts.map +1 -1
  190. package/dist/secrets/manager.d.ts.map +1 -1
  191. package/dist/tables/table-manager.d.ts +3 -0
  192. package/dist/tables/table-manager.d.ts.map +1 -1
  193. package/dist/templates/README.md +23 -13
  194. package/dist/templates/blank/agent.config.ts +3 -3
  195. package/dist/templates/blank/src/triggers/index.ts +1 -1
  196. package/dist/templates/botpress-desk/evals/index.eval.ts +1 -1
  197. package/dist/templates/botpress-desk/src/triggers/index.ts +1 -1
  198. package/dist/templates/crm-enrichment/README.md +3 -3
  199. package/dist/templates/crm-enrichment/agent.config.ts +2 -2
  200. package/dist/templates/crm-enrichment/src/conversations/index.ts +1 -1
  201. package/dist/templates/hello-world/agent.config.ts +3 -3
  202. package/dist/templates/hello-world/src/triggers/index.ts +1 -1
  203. package/dist/templates/knowledge-assistant/src/triggers/index.ts +1 -1
  204. package/dist/templates/template.config.json +3 -3
  205. package/dist/test-utils/mock-module.d.ts +29 -0
  206. package/dist/test-utils/mock-module.d.ts.map +1 -0
  207. package/dist/utils/ids.d.ts +10 -0
  208. package/dist/utils/ids.d.ts.map +1 -1
  209. package/dist/utils/require-chat.d.ts.map +1 -1
  210. package/dist/utils/source-map-optimizer.d.ts +10 -11
  211. package/dist/utils/source-map-optimizer.d.ts.map +1 -1
  212. package/dist/workspace/workspace-cache.d.ts +2 -1
  213. package/dist/workspace/workspace-cache.d.ts.map +1 -1
  214. package/package.json +8 -4
  215. package/dist/agent-project/lock-to-dependencies.d.ts +0 -11
  216. package/dist/agent-project/lock-to-dependencies.d.ts.map +0 -1
  217. package/dist/dependencies/lock-file.d.ts +0 -15
  218. package/dist/dependencies/lock-file.d.ts.map +0 -1
  219. package/dist/integrations/enhanced-cache.d.ts +0 -53
  220. package/dist/integrations/enhanced-cache.d.ts.map +0 -1
  221. package/dist/plugins/enhanced-cache.d.ts +0 -53
  222. package/dist/plugins/enhanced-cache.d.ts.map +0 -1
  223. package/dist/templates/blank/package.json +0 -17
  224. package/dist/templates/blank/tsconfig.json +0 -25
  225. package/dist/templates/botpress-desk/package.json +0 -17
  226. package/dist/templates/crm-enrichment/package.json +0 -18
  227. package/dist/templates/crm-enrichment/tsconfig.json +0 -25
  228. package/dist/templates/hello-world/package.json +0 -18
  229. package/dist/templates/hello-world/tsconfig.json +0 -25
  230. package/dist/templates/knowledge-assistant/package.json +0 -18
  231. package/dist/templates/knowledge-assistant/tsconfig.json +0 -25
  232. package/dist/templates/slack-triage/package.json +0 -18
  233. 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 "@botpress/runtime";
12
- import { actions, joinMarkdownChildren } from "@botpress/runtime/runtime";
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: "desk.ticket",
15
+ channel: 'desk.ticket',
16
16
  state: z.object({
17
- lastSync: z.string().default(""),
17
+ lastSync: z.string().default(''),
18
18
  }),
19
- events: ["desk:ticketActivity"],
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["desk:dassignedself"] !== "true") {
23
- console.log("Ticket not assigned to bot, ignoring...");
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: "You are a helpful support agent...",
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 "@botpress/runtime";
38
+ import { defineConfig } from '@botpress/runtime'
39
39
 
40
40
  export default defineConfig({
41
- name: "support-bot",
41
+ name: 'support-bot',
42
42
 
43
43
  dependencies: {
44
44
  integrations: {
45
45
  desk: {
46
46
  enabled: true,
47
47
  configuration: {
48
- displayName: "Support Bot",
49
- botHandle: "SupportBot",
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 | `canBeAssigned` | Description |
73
- |------|-----------------|-------------|
74
- | **Assigned** | `true` | Bot owns tickets and replies directly to customers |
75
- | **Assisting** | `false` | Bot helps human agents with suggestions and automation |
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 "@botpress/runtime";
95
+ import { defineConfig } from '@botpress/runtime'
94
96
 
95
97
  export default defineConfig({
96
- name: "my-agent",
98
+ name: 'my-agent',
97
99
 
98
100
  dependencies: {
99
101
  integrations: {
100
102
  desk: {
101
103
  enabled: true,
102
104
  configuration: {
103
- displayName: "My Support Bot",
104
- botHandle: "MySupportBot",
105
- displayAvatarUrl: "https://example.com/bot-avatar.png",
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 | Type | Required | Description |
117
- |--------|------|----------|-------------|
118
- | `displayName` | string | Yes | Name shown in Desk UI |
119
- | `botHandle` | string | Yes | Handle for @mentions (3-20 chars, starts with letter, alphanumeric + underscores) |
120
- | `displayAvatarUrl` | string | No | URL of avatar image |
121
- | `canBeAssigned` | boolean | No | Whether bot can be assigned to tickets (default: `false`) |
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: "desk.ticket",
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: "desk.ticket",
156
- events: ["desk:ticketActivity"],
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 | Description | Example |
170
- |-----|-------------|---------|
171
- | `desk:did` | Desk ticket ID | `tkt_abc123` |
172
- | `desk:status` | Ticket status | `open`, `closed`, `snoozed` |
173
- | `desk:title` | Ticket title | `"Login issue"` |
174
- | `desk:system` | Source system | `intercom`, `zendesk`, `native` |
175
- | `desk:url` | URL to view in Desk | `https://desk.botpress.com/...` |
176
- | `desk:snoozeduntil` | Wake time if snoozed | ISO timestamp |
177
- | `desk:dtags` | Desk tags (comma-separated) | `urgent,billing` |
178
- | `desk:dcustomerid` | Customer ID | `cus_xyz789` |
179
- | `desk:dassignedid` | Assigned admin/bot ID | `adm_123`, `ibot_456` |
180
- | `desk:dassignedself` | **Is this bot assigned?** | `"true"` or `"false"` |
181
- | `desk:dsyncactivityid` | Last synced activity ID | `tka_abc123` |
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 | Description |
186
- |-----|-------------|
187
- | `desk:did` | Activity ID (`tka_...`) |
189
+ | Tag | Description |
190
+ | ------------------ | -------------------------- |
191
+ | `desk:did` | Activity ID (`tka_...`) |
188
192
  | `desk:dassignedid` | Who was assigned when sent |
189
- | `desk:dstatus` | Ticket status when sent |
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: "text",
207
+ type: 'text',
204
208
  payload: {
205
- format: "markdown",
206
- text: "Hello! How can I help you today?",
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: "note",
239
+ type: 'note',
235
240
  payload: {
236
- format: "markdown",
237
- text: "Internal note: Customer has billing issues in CRM",
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: "activity",
267
+ type: 'activity',
262
268
  payload: {
263
- type: "ticket.activity",
269
+ type: 'ticket.activity',
264
270
  private: true,
265
271
  activity: {
266
- type: "ticket.assigned",
272
+ type: 'ticket.assigned',
267
273
  assignedTo: {
268
- type: "bot",
269
- id: "ibot_abc123",
270
- reply_as: "SupportBot",
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 "@botpress/runtime";
287
- import { actions, joinMarkdownChildren, TranscriptItem } from "@botpress/runtime/runtime";
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: "desk.ticket",
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: ["desk:ticketActivity"],
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["desk:dassignedself"] !== "true") {
324
- console.log("Ticket not assigned to bot, ignoring...");
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("chat");
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((m) => ({
360
- id: m.id,
361
- content: JSON.stringify(m.payload),
362
- createdAt: m.createdAt,
363
- role: m.direction === "incoming" ? "user" : "assistant",
364
- attachments: [],
365
- name: m.userId,
366
- }) satisfies TranscriptItem),
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
- .filter((x) => x.role === "user" || x.role === "assistant")
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: "Reply",
390
- description: "Sends a reply to the customer, visible to them and via email.",
391
- type: "leaf",
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: "Reply",
397
- description: "Sends a reply to the customer",
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: "Note",
412
- description: "Adds an internal note to the ticket. Not visible to the customer.",
413
- type: "leaf",
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: "Note",
419
- description: "Adds an internal note to the ticket",
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("chat");
436
+ const chat = context.get('chat')
433
437
 
434
438
  // Remove default message components
435
- chat.removeComponent("MESSAGE");
436
- chat.removeComponent("Text");
437
- chat.removeComponent("TEXT");
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: "text",
445
- payload: { format: "markdown", text: joinMarkdownChildren(children) },
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: "note",
456
- payload: { format: "markdown", text: joinMarkdownChildren(children) },
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: "updatedAt",
482
- orderDirection: "desc",
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: "tkt_abc123" });
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: "tkt_abc123",
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: "tkt_abc123",
505
- assigneeId: "adm_xyz789", // or "ibot_..." for a bot
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: "tkt_abc123" });
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: "tkt_abc123" });
520
+ await actions.desk.closeTicket({ ticketId: 'tkt_abc123' })
517
521
 
518
522
  // reopenTicket
519
- await actions.desk.reopenTicket({ ticketId: "tkt_abc123" });
523
+ await actions.desk.reopenTicket({ ticketId: 'tkt_abc123' })
520
524
 
521
525
  // snoozeTicket
522
526
  await actions.desk.snoozeTicket({
523
- ticketId: "tkt_abc123",
524
- snoozedUntil: "2025-01-21T09:00:00Z",
525
- });
527
+ ticketId: 'tkt_abc123',
528
+ snoozedUntil: '2025-01-21T09:00:00Z',
529
+ })
526
530
 
527
531
  // unsnoozeTicket
528
- await actions.desk.unsnoozeTicket({ ticketId: "tkt_abc123" });
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: "tkt_abc123",
537
- title: "Updated: Login Issue with 2FA",
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: "tkt_abc123",
543
- tags: ["urgent", "billing", "enterprise"],
544
- });
546
+ ticketId: 'tkt_abc123',
547
+ tags: ['urgent', 'billing', 'enterprise'],
548
+ })
545
549
 
546
550
  // removeTags
547
551
  await actions.desk.removeTags({
548
- ticketId: "tkt_abc123",
549
- tags: ["low-priority"],
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["desk:did"];
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: "You are a helpful support agent...",
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["desk:dassignedself"] !== "true") return;
593
+ if (conversation.tags['desk:dassignedself'] !== 'true') return
590
594
 
591
- const ticketId = conversation.tags["desk:did"];
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: "anthropic:claude-sonnet-4-20250514",
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: "note",
649
+ type: 'note',
646
650
  payload: {
647
- format: "markdown",
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: "text",
658
+ type: 'text',
655
659
  payload: {
656
- format: "markdown",
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["desk:did"],
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["desk:dassignedself"] !== "true") return;
673
+ if (conversation.tags['desk:dassignedself'] !== 'true') return
670
674
 
671
675
  if (needsEscalation) {
672
- await escalateToHuman(conversation, "Complex billing issue");
673
- return; // Step 4: Stop processing
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; // "tkt_abc123"
695
- title: string;
696
- customer: Customer;
697
- priority: "low" | "medium" | "high" | "urgent";
698
- system: "native" | "intercom" | "zendesk";
699
- systemTicketId: string;
700
- assignedTo?: Admin | Bot;
701
- status: "open" | "closed" | "snoozed";
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; // "cus_xyz789"
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; // "adm_abc123"
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; // "ibot_def456"
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; // "tka_abc123"
751
- ticketId: string;
752
- activityType: "comment" | "note" | "system_public" | "system_internal";
753
- authorType: "admin" | "customer" | "bot" | "user";
754
- authorId: string;
755
- body: string;
756
- bodyFormat: "plain" | "html" | "markdown" | "json";
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: "ticket.snoozed"; author: Author }
768
- | { type: "ticket.unsnoozed"; author: Author }
769
- | { type: "ticket.assigned"; assignedTo: { type: "admin" | "bot"; id: string; reply_as?: string } }
770
- | { type: "ticket.unassigned"; author: Author }
771
- | { type: "ticket.closed"; author: Author }
772
- | { type: "ticket.reopened"; author: Author }
773
- | { type: "ticket.renamed"; title: string }
774
- | { type: "ticket.tags_updated"; author: Author; added: string[]; removed: string[] };
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: "text", payload: { text: "Customer has overdue invoices in CRM" } });
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: "note", payload: { text: "Customer has overdue invoices in CRM" } });
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["desk:did"];
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["deskId"]
824
- conversation.tags["desk:assignedSelf"] // wrong case
825
+ conversation.tags['deskId']
826
+ conversation.tags['desk:assignedSelf'] // wrong case
825
827
 
826
828
  // ✅ CORRECT
827
- conversation.tags["desk:did"]
828
- conversation.tags["desk:dassignedself"] // lowercase
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: "Always reply to every message from the customer"
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.