adk-frontend
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseADK Frontend Integration
ADK前端集成
Use this skill when users ask questions about building frontend applications that connect to Botpress ADK bots. This covers authentication patterns, type-safe API calls, client configuration, and integrating generated types.
当用户询问有关构建与Botpress ADK机器人连接的前端应用的问题时,可使用本技能。内容涵盖认证模式、类型安全API调用、客户端配置以及集成生成的类型。
What is ADK Frontend Integration?
什么是ADK前端集成?
When you build a bot with the Botpress ADK, you often need a frontend application that interacts with it. This skill provides production-tested patterns for:
- Authentication - Cookie-based PAT storage with OAuth flow
- Client Management - Zustand store pattern for client caching and reuse
- Type Generation - Using ADK-generated types for full type safety
- Action Calls - Calling bot actions with proper error handling and optimistic updates
当你使用Botpress ADK构建机器人时,通常需要一个与之交互的前端应用。本技能提供经过生产验证的模式,用于:
- 认证 - 基于Cookie的PAT存储及OAuth流程
- 客户端管理 - 使用Zustand存储模式实现客户端缓存与复用
- 类型生成 - 使用ADK生成的类型实现完全的类型安全
- 操作调用 - 调用机器人操作并进行适当的错误处理和乐观更新
Key Technologies
核心技术
- @botpress/client - Official TypeScript client for Botpress API
- Triple-slash references - TypeScript pattern for importing generated types
- React Query - For mutations and cache management (optional but recommended)
- Zustand - For client state management
- @botpress/client - Botpress API的官方TypeScript客户端
- Triple-slash references - TypeScript中用于导入生成类型的模式
- React Query - 用于变更和缓存管理(可选但推荐)
- Zustand - 用于客户端状态管理
When to Use This Skill
何时使用本技能
Activate this skill when users ask frontend-related questions like:
当用户提出以下前端相关问题时,启用本技能:
Authentication Questions
认证相关问题
- "How do I authenticate with Botpress from my frontend?"
- "What are Personal Access Tokens (PATs)?"
- "Should I use cookies or localStorage for tokens?"
- "How do I implement OAuth login flow?"
- "How do I protect routes based on authentication?"
- "How do I handle token expiration?"
- "如何从我的前端应用向Botpress进行认证?"
- "什么是个人访问令牌(PATs)?"
- "我应该使用Cookie还是localStorage存储令牌?"
- "如何实现OAuth登录流程?"
- "如何基于认证状态保护路由?"
- "如何处理令牌过期?"
Client Setup Questions
客户端设置相关问题
- "How do I initialize the Botpress client?"
- "What's the best way to manage multiple client instances?"
- "Why use a client store?"
- "How do I create workspace-scoped vs bot-scoped clients?"
- "What's the difference between regular client and Zai client?"
- "如何初始化Botpress客户端?"
- "管理多个客户端实例的最佳方式是什么?"
- "为什么要使用客户端存储?"
- "如何创建工作区范围和机器人范围的客户端?"
- "常规客户端与Zai客户端有什么区别?"
Type Generation Questions
类型生成相关问题
- "How do I get types for my bot's actions?"
- "What are triple-slash references?"
- "How do I import generated types?"
- "Where are the .adk type files?"
- "How do I keep types in sync between bot and frontend?"
- "Why can't TypeScript find my action types?"
- "如何获取我的机器人操作的类型?"
- "什么是Triple-slash references?"
- "如何导入生成的类型?"
- ".adk类型文件在哪里?"
- "如何保持机器人与前端之间的类型同步?"
- "为什么TypeScript找不到我的操作类型?"
Calling Actions Questions
操作调用相关问题
- "How do I call a bot action from my frontend?"
- "What's the syntax for client.callAction()?"
- "How do I handle errors when calling actions?"
- "How do I implement optimistic updates?"
- "How do I chain multiple action calls?"
- "How do I use React Query with bot actions?"
- "如何从我的前端应用调用机器人操作?"
- "client.callAction()的语法是什么?"
- "调用操作时如何处理错误?"
- "如何实现乐观更新?"
- "如何链式调用多个操作?"
- "如何将React Query与机器人操作结合使用?"
Available Documentation
可用文档
Documentation files in :
./references/./references/Core Integration Patterns
核心集成模式
- authentication.md - Complete authentication system with PATs, cookies, OAuth, route protection
- botpress-client.md - Client initialization, Zustand store pattern, Zai client setup
- calling-actions.md - Type-safe action calls, mutations, error handling, optimistic updates
- type-generation.md - Triple-slash references, generated types, maintaining type safety
- authentication.md - 完整的认证系统,包含PAT、Cookie、OAuth、路由保护
- botpress-client.md - 客户端初始化、Zustand存储模式、Zai客户端设置
- calling-actions.md - 类型安全的操作调用、变更、错误处理、乐观更新
- type-generation.md - Triple-slash引用、生成的类型、维护类型安全
Architecture & Setup
架构与设置
- overview.md - Architecture overview, when to use ADK frontends, project structure
- project-setup.md - Vite + React scaffolding, TypeScript config, environment setup
- recommended-stack.md - Recommended tech stack with rationale
- overview.md - 架构概述、何时使用ADK前端、项目结构
- project-setup.md - Vite + React脚手架、TypeScript配置、环境设置
- recommended-stack.md - 推荐技术栈及理由
Data & State Patterns
数据与状态模式
- service-layer.md - Service layer pattern for wrapping API calls with types
- data-fetching.md - TanStack Query patterns, mutations, optimistic updates
- state-management.md - Zustand vs TanStack Query, when to use each
- realtime-updates.md - Polling strategies, interval tiers, performance considerations
- service-layer.md - 服务层模式,为API调用添加类型包装
- data-fetching.md - TanStack Query模式、变更、乐观更新
- state-management.md - Zustand与TanStack Query对比、各自适用场景
- realtime-updates.md - 轮询策略、间隔层级、性能考量
How to Answer Frontend Questions
如何回答前端问题
Frontend questions typically fall into these categories:
前端问题通常分为以下类别:
1. Authentication Implementation
1. 认证实现
When users ask about authentication, reference the complete pattern from :
authentication.mdKey Concepts:
- PAT generation in Botpress Cloud
- Cookie-based storage (not localStorage)
- AuthContext with React Context API
- OAuth callback flow via cli-login
- Route protection with TanStack Router
- Profile fetching from both Botpress API and bot tables
Response Pattern:
- Explain the authentication strategy (cookies vs localStorage)
- Show the AuthProvider implementation
- Demonstrate the OAuth flow
- Provide route protection examples
- Highlight security best practices
当用户询问认证相关问题时,参考中的完整模式:
authentication.md核心概念:
- 在Botpress Cloud中生成PAT
- 基于Cookie的存储(而非localStorage)
- 使用React Context API的AuthContext
- 通过cli-login实现OAuth回调流程
- 使用TanStack Router进行路由保护
- 从Botpress API和机器人表中获取用户资料
响应模式:
- 解释认证策略(Cookie vs localStorage)
- 展示AuthProvider实现
- 演示OAuth流程
- 提供路由保护示例
- 强调安全最佳实践
2. Client Setup and Management
2. 客户端设置与管理
When users ask about client configuration, reference :
botpress-client.mdKey Concepts:
- Client initialization with apiUrl, workspaceId, token, botId
- Zustand store for client caching
- Dynamic client keys for reuse
- Workspace-scoped vs bot-scoped clients
- Extended timeouts for Zai operations
Response Pattern:
- Show the clientsStore.ts pattern
- Explain how client caching works
- Demonstrate getApiClient() usage
- Show when to use workspace vs bot-scoped clients
- Explain getZaiClient() for AI operations
当用户询问客户端配置相关问题时,参考:
botpress-client.md核心概念:
- 使用apiUrl、workspaceId、token、botId初始化客户端
- 使用Zustand存储实现客户端缓存
- 动态客户端键实现复用
- 工作区范围与机器人范围的客户端
- 为Zai操作设置延长超时时间
响应模式:
- 展示clientsStore.ts模式
- 解释客户端缓存的工作原理
- 演示getApiClient()的用法
- 展示何时使用工作区范围与机器人范围的客户端
- 解释用于AI操作的getZaiClient()
3. Type Generation and Import
3. 类型生成与导入
When users ask about types, reference :
type-generation.mdKey Concepts:
- ADK generates types in directory during dev/build
.adk/ - Triple-slash directives for referencing external types
- Generated files: action-types.d.ts, table-types.d.ts, workflow-types.d.ts
- Creating type aliases for cleaner code
- Keeping types in sync with adk dev
Response Pattern:
- Explain how ADK generates types
- Show triple-slash reference syntax
- Demonstrate importing generated types
- Provide examples of creating type aliases
- Show how types stay in sync automatically
当用户询问类型相关问题时,参考:
type-generation.md核心概念:
- ADK在开发/构建期间在目录生成类型
.adk/ - 使用Triple-slash指令引用外部类型
- 生成的文件:action-types.d.ts、table-types.d.ts、workflow-types.d.ts
- 创建类型别名以简化代码
- 通过adk dev保持类型同步
响应模式:
- 解释ADK生成类型的方式
- 展示Triple-slash引用语法
- 演示导入生成的类型
- 提供创建类型别名的示例
- 说明类型如何自动保持同步
4. Calling Bot Actions
4. 调用机器人操作
When users ask about calling actions, reference :
calling-actions.mdKey Concepts:
- client.callAction() signature
- Type-safe input/output with BotActionDefinitions
- Service layer pattern for reusable action calls
- Using useMutation for loading states and error handling
- Optimistic updates for instant UI feedback
- Chaining actions (sequential vs parallel)
Response Pattern:
- Show the basic callAction() syntax
- Demonstrate type-safe service functions
- Provide useMutation examples
- Show error handling patterns
- Explain optimistic updates when relevant
当用户询问调用操作相关问题时,参考:
calling-actions.md核心概念:
- client.callAction()签名
- 使用BotActionDefinitions实现类型安全的输入/输出
- 服务层模式实现可复用的操作调用
- 使用useMutation处理加载状态和错误
- 乐观更新实现即时UI反馈
- 链式调用操作(顺序 vs 并行)
响应模式:
- 展示基础的callAction()语法
- 演示类型安全的服务函数
- 提供useMutation示例
- 展示错误处理模式
- 相关时解释乐观更新
Common Patterns Reference
常见模式参考
Authentication Flow
认证流程
typescript
// 1. Cookie helpers
function setCookie(name: string, value: string, days = 365);
function getCookie(name: string): string | null;
function deleteCookie(name: string);
// 2. AuthContext
interface AuthContextType {
token: string | null;
isAuthenticated: boolean;
userProfile: UserProfile | null;
isLoadingProfile: boolean;
login: (token: string) => void;
logout: () => void;
}
// 3. OAuth Flow
// Redirect: https://app.botpress.cloud/cli-login?redirect=...
// Callback: /auth/callback?pat=bp_pat_...
// Store PAT in cookie and navigate to apptypescript
// 1. Cookie助手
function setCookie(name: string, value: string, days = 365);
function getCookie(name: string): string | null;
function deleteCookie(name: string);
// 2. AuthContext
interface AuthContextType {
token: string | null;
isAuthenticated: boolean;
userProfile: UserProfile | null;
isLoadingProfile: boolean;
login: (token: string) => void;
logout: () => void;
}
// 3. OAuth Flow
// 重定向:https://app.botpress.cloud/cli-login?redirect=...
// 回调:/auth/callback?pat=bp_pat_...
// 将PAT存储在Cookie中并导航到应用Client Store Pattern
客户端存储模式
typescript
// stores/clientsStore.ts
const useClientsStore = create<ClientsState>()((set, get) => ({
APIClients: {},
getAPIClient: (props) => {
const key = props?.botId
? `${props.workspaceId}-${props.botId}`
: (props?.workspaceId ?? DEFAULT_API_CLIENT_KEY);
const cached = get().APIClients[key];
if (cached) return cached;
const newClient = new APIClient({
apiUrl: API_BASE_URL,
workspaceId: props?.workspaceId,
token: getPat() ?? "",
botId: props?.botId,
});
set((state) => ({
APIClients: { ...state.APIClients, [key]: newClient },
}));
return newClient;
},
}));
export const getApiClient = (props?) =>
useClientsStore.getState().getAPIClient(props);typescript
// stores/clientsStore.ts
const useClientsStore = create<ClientsState>()((set, get) => ({
APIClients: {},
getAPIClient: (props) => {
const key = props?.botId
? `${props.workspaceId}-${props.botId}`
: (props?.workspaceId ?? DEFAULT_API_CLIENT_KEY);
const cached = get().APIClients[key];
if (cached) return cached;
const newClient = new APIClient({
apiUrl: API_BASE_URL,
workspaceId: props?.workspaceId,
token: getPat() ?? "",
botId: props?.botId,
});
set((state) => ({
APIClients: { ...state.APIClients, [key]: newClient },
}));
return newClient;
},
}));
export const getApiClient = (props?) =>
useClientsStore.getState().getAPIClient(props);Type Import Pattern
类型导入模式
typescript
// types/index.ts
/// <reference path="../../../bot/.adk/action-types.d.ts" />
/// <reference path="../../../bot/.adk/table-types.d.ts" />
import type { BotActionDefinitions } from "@botpress/runtime/_types/actions";
import type { TableDefinitions } from "@botpress/runtime/_types/tables";
// Create type aliases
export type SendMessageAction = BotActionDefinitions["sendMessage"];
export type TicketTableRow = TableDefinitions["TicketsTable"]["Output"];typescript
// types/index.ts
/// <reference path="../../../bot/.adk/action-types.d.ts" />
/// <reference path="../../../bot/.adk/table-types.d.ts" />
import type { BotActionDefinitions } from "@botpress/runtime/_types/actions";
import type { TableDefinitions } from "@botpress/runtime/_types/tables";
// 创建类型别名
export type SendMessageAction = BotActionDefinitions["sendMessage"];
export type TicketTableRow = TableDefinitions["TicketsTable"]["Output"];Action Call Pattern
操作调用模式
typescript
// services/bot-service.ts
export async function sendMessage(input: SendMessageAction["input"]) {
const client = getApiClient({ botId, workspaceId });
const result = await client.callAction({
type: "sendMessage",
input,
});
return result.output as SendMessageAction["output"];
}
// Component usage with useMutation
const { mutate: send, isPending } = useMutation({
mutationFn: sendMessage,
onSuccess: () => {
toast.success("Message sent");
queryClient.invalidateQueries({ queryKey: ["messages"] });
},
onError: (error) => {
toast.error("Failed to send message");
},
});typescript
// services/bot-service.ts
export async function sendMessage(input: SendMessageAction["input"]) {
const client = getApiClient({ botId, workspaceId });
const result = await client.callAction({
type: "sendMessage",
input,
});
return result.output as SendMessageAction["output"];
}
// 组件中结合useMutation使用
const { mutate: send, isPending } = useMutation({
mutationFn: sendMessage,
onSuccess: () => {
toast.success("消息已发送");
queryClient.invalidateQueries({ queryKey: ["messages"] });
},
onError: (error) => {
toast.error("消息发送失败");
},
});Examples of Questions This Skill Answers
本技能可回答的问题示例
Beginner Questions
入门级问题
- "How do I connect my React app to a Botpress bot?"
- "What is a Personal Access Token?"
- "Where do I find my workspace ID and bot ID?"
- "How do I install @botpress/client?"
- "如何将我的React应用连接到Botpress机器人?"
- "什么是个人访问令牌?"
- "在哪里可以找到我的工作区ID和机器人ID?"
- "如何安装@botpress/client?"
Authentication Questions
认证相关问题
- "How should I store authentication tokens?"
- "How do I implement login/logout?"
- "How do I protect authenticated routes?"
- "Should I use cookies or localStorage?"
- "How do I handle the OAuth callback?"
- "我应该如何存储认证令牌?"
- "如何实现登录/登出?"
- "如何保护已认证的路由?"
- "我应该使用Cookie还是localStorage?"
- "如何处理OAuth回调?"
Type Safety Questions
类型安全相关问题
- "How do I get TypeScript types for my bot?"
- "What are triple-slash references?"
- "Why can't TypeScript find my action types?"
- "How do I keep types in sync?"
- "Where are the generated type files?"
- "如何为我的机器人获取TypeScript类型?"
- "什么是Triple-slash references?"
- "为什么TypeScript找不到我的操作类型?"
- "如何保持类型同步?"
- "生成的类型文件在哪里?"
Implementation Questions
实现相关问题
- "How do I call a bot action?"
- "How do I query bot tables from my frontend?"
- "How do I handle loading states?"
- "How do I implement optimistic updates?"
- "How do I chain multiple action calls?"
- "如何调用机器人操作?"
- "如何从我的前端应用查询机器人表?"
- "如何处理加载状态?"
- "如何实现乐观更新?"
- "如何链式调用多个操作?"
Advanced Questions
进阶问题
- "How do I use Zai from my frontend?"
- "What's the difference between workspace and bot-scoped clients?"
- "How do I implement client caching?"
- "How do I handle token expiration?"
- "How do I implement retry logic?"
- "如何从我的前端应用使用Zai?"
- "工作区范围与机器人范围的客户端有什么区别?"
- "如何实现客户端缓存?"
- "如何处理令牌过期?"
- "如何实现重试逻辑?"
Response Format
响应格式
When answering:
- Start with a concise explanation (1-2 paragraphs)
- Provide working code examples from the references
- Include file references (e.g., "From authentication.md:60-85")
- Highlight security considerations when relevant
- Show common pitfalls and how to avoid them
- Link to related topics for deeper exploration
回答时:
- 以简洁的解释开头(1-2段)
- 提供来自参考文档的可运行代码示例
- 包含文件引用(例如:"来自authentication.md:60-85")
- 相关时强调安全注意事项
- 展示常见陷阱及避免方法
- 链接到相关主题以进行深入探索
Example Response Structure
示例响应结构
Question: "How do I authenticate users in my frontend?"
Answer:
The recommended pattern uses cookie-based PAT storage with OAuth flow.
Here's the complete implementation:
1. Cookie Helpers (authentication.md:89-111)
[code example]
2. AuthContext Setup (authentication.md:64-76)
[code example]
3. OAuth Flow (authentication.md:473-533)
[code example]
Key Security Considerations:
- Use SameSite=Lax for CSRF protection
- Always use HTTPS in production
- Never log PATs to console
- Implement token expiration handling
Related Topics:
- Route protection: authentication.md:369-467
- Profile fetching: authentication.md:304-347
- Client initialization: botpress-client.md:29-51问题:"如何在我的前端应用中对用户进行认证?"
回答:
推荐的模式是使用基于Cookie的PAT存储及OAuth流程。
以下是完整的实现:
1. Cookie助手(authentication.md:89-111)
[代码示例]
2. AuthContext设置(authentication.md:64-76)
[代码示例]
3. OAuth流程(authentication.md:473-533)
[代码示例]
核心安全注意事项:
- 使用SameSite=Lax以防止CSRF攻击
- 生产环境中始终使用HTTPS
- 切勿将PAT记录到控制台
- 实现令牌过期处理
相关主题:
- 路由保护:authentication.md:369-467
- 资料获取:authentication.md:304-347
- 客户端初始化:botpress-client.md:29-51Critical Patterns to Always Reference
必须参考的关键模式
When answering questions, always verify these patterns against the documentation:
回答问题时,始终对照文档验证以下模式:
1. Client Management
1. 客户端管理
typescript
// ✅ CORRECT - Use client store
const client = getApiClient({ workspaceId, botId });
// ❌ WRONG - Create new client every time
const client = new Client({ apiUrl, workspaceId, token, botId });typescript
// ✅ 正确 - 使用客户端存储
const client = getApiClient({ workspaceId, botId });
// ❌ 错误 - 每次创建新客户端
const client = new Client({ apiUrl, workspaceId, token, botId });2. Type Imports
2. 类型导入
typescript
// ✅ CORRECT - Triple-slash at top of file
/// <reference path="../../../bot/.adk/action-types.d.ts" />
import type { BotActionDefinitions } from "@botpress/runtime/_types/actions";
// ❌ WRONG - No triple-slash reference
import type { BotActionDefinitions } from "@botpress/runtime/_types/actions";typescript
// ✅ 正确 - 文件顶部使用Triple-slash
/// <reference path="../../../bot/.adk/action-types.d.ts" />
import type { BotActionDefinitions } from "@botpress/runtime/_types/actions";
// ❌ 错误 - 无Triple-slash引用
import type { BotActionDefinitions } from "@botpress/runtime/_types/actions";3. Action Calls
3. 操作调用
typescript
// ✅ CORRECT - Service layer with types
export async function sendMessage(input: SendMessageAction["input"]) {
const client = getApiClient({ botId, workspaceId });
const result = await client.callAction({ type: "sendMessage", input });
return result.output as SendMessageAction["output"];
}
// ❌ WRONG - Direct call in component
const result = await client.callAction({ type: "sendMessage", input: data });typescript
// ✅ 正确 - 带类型的服务层
export async function sendMessage(input: SendMessageAction["input"]) {
const client = getApiClient({ botId, workspaceId });
const result = await client.callAction({ type: "sendMessage", input });
return result.output as SendMessageAction["output"];
}
// ❌ 错误 - 在组件中直接调用
const result = await client.callAction({ type: "sendMessage", input: data });4. Authentication Storage
4. 认证存储
typescript
// ✅ CORRECT - Cookie with SameSite
document.cookie = `token=${value};expires=${expires};path=/;SameSite=Lax`;
// ❌ WRONG - localStorage without security
localStorage.setItem("token", value);typescript
// ✅ 正确 - 带SameSite的Cookie
document.cookie = `token=${value};expires=${expires};path=/;SameSite=Lax`;
// ❌ 错误 - 无安全措施的localStorage
localStorage.setItem("token", value);Best Practices to Emphasize
需要强调的最佳实践
When answering, always mention relevant best practices:
回答时,始终提及相关的最佳实践:
Security
安全
- Always use HTTPS in production
- Use cookies with SameSite protection
- Never log PATs or tokens
- Implement token expiration handling
- Use HttpOnly cookies when possible (SSR)
- 生产环境中始终使用HTTPS
- 使用带SameSite保护的Cookie
- 切勿记录PAT或令牌
- 实现令牌过期处理
- 可能时使用HttpOnly Cookie(SSR场景)
Type Safety
类型安全
- Always use generated types from ADK
- Create type aliases for cleaner code
- Use triple-slash references correctly
- Keep types in sync with adk dev
- Type all action inputs and outputs
- 始终使用ADK生成的类型
- 创建类型别名以简化代码
- 正确使用Triple-slash引用
- 通过adk dev保持类型同步
- 为所有操作输入和输出添加类型
Performance
性能
- Cache clients with Zustand store
- Use workspace-scoped clients when no bot operations needed
- Implement optimistic updates for better UX
- Use React Query for cache management
- Run independent actions in parallel
- 使用Zustand存储缓存客户端
- 无需机器人操作时使用工作区范围的客户端
- 实现乐观更新以提升用户体验
- 使用React Query进行缓存管理
- 并行执行独立操作
Error Handling
错误处理
- Always handle 401 (expired token) errors
- Provide user feedback on errors
- Implement retry logic for transient failures
- Log errors appropriately (never log tokens)
- Show loading states during async operations
- 始终处理401(令牌过期)错误
- 为用户提供错误反馈
- 为临时故障实现重试逻辑
- 适当记录错误(切勿记录令牌)
- 异步操作期间显示加载状态
Code Organization
代码组织
- Use service layer for action calls
- Centralize types in single file
- Keep authentication logic in context
- Separate client configuration from usage
- Reuse service functions across components
- 使用服务层处理操作调用
- 将类型集中到单个文件
- 将认证逻辑放在Context中
- 分离客户端配置与使用
- 在组件间复用服务函数
Troubleshooting Common Issues
常见问题排查
Be prepared to help with these common problems:
准备好帮助解决以下常见问题:
"Cannot find module '@botpress/runtime/_types/actions'"
"无法找到模块'@botpress/runtime/_types/actions'"
- Check triple-slash reference path
- Verify .adk/ directory exists
- Restart TypeScript server
- Ensure adk dev/build has run
- 检查Triple-slash引用路径
- 验证.adk/目录是否存在
- 重启TypeScript服务器
- 确保已运行adk dev/build
"Types not updating after bot changes"
"机器人变更后类型未更新"
- Restart adk dev
- Delete .adk/ and rebuild
- Restart TypeScript server
- Check for bot compilation errors
- 重启adk dev
- 删除.adk/并重新构建
- 重启TypeScript服务器
- 检查机器人编译错误
"Authentication fails after reload"
"重新加载后认证失败"
- Implement reload retry logic (authentication.md:191-220)
- Check cookie expiration
- Verify token is being retrieved correctly
- Check for CORS issues
- 实现重新加载重试逻辑(authentication.md:191-220)
- 检查Cookie过期时间
- 验证令牌是否被正确获取
- 检查CORS问题
"Client timeout on long operations"
"长操作时客户端超时"
- Use getZaiClient() with extended timeout for AI operations
- Don't use regular client for Zai operations
- Consider breaking into smaller operations
- 使用getZaiClient()并为AI操作设置延长超时时间
- 不要使用常规客户端执行Zai操作
- 考虑拆分为更小的操作
Summary
总结
This skill covers the complete frontend integration story for Botpress ADK:
Core Topics:
- Authentication with PATs and cookies
- Client management with Zustand
- Type generation and import with triple-slash references
- Calling bot actions with full type safety
When to Use:
- Any frontend integration question
- Authentication and security patterns
- Type safety and generated types
- Client setup and configuration
- Action calls and error handling
Key Principle:
Always provide production-ready patterns that emphasize type safety, security, and maintainability.
本技能涵盖了Botpress ADK前端集成的完整内容:
核心主题:
- 使用PAT和Cookie的认证
- 使用Zustand的客户端管理
- 使用Triple-slash引用的类型生成与导入
- 完全类型安全的机器人操作调用
适用场景:
- 任何前端集成问题
- 认证与安全模式
- 类型安全与生成的类型
- 客户端设置与配置
- 操作调用与错误处理
核心原则:
始终提供注重类型安全、安全性和可维护性的生产就绪模式。