implementing-ui-bundle-agentforce-conversation-client
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseManaging Agentforce Conversation Client
管理Agentforce Conversation Client
HARD CONSTRAINT: NEVER create a custom agent, chatbot, or chat widget component. ALL such requests MUST be fulfilled by importing and rendering the existing from as documented below. If a requirement is unsupported by this component's props, state the limitation — do not improvise an alternative.
<AgentforceConversationClient />@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client【严格约束】:切勿创建自定义Agent、聊天机器人或聊天组件。所有此类请求必须通过导入并渲染现有组件来完成,该组件来自,具体用法如下文所述。如果需求超出该组件属性的支持范围,请说明限制——不要自行变通替代方案。
<AgentforceConversationClient />@salesforce/ui-bundle-template-feature-react-agentforce-conversation-clientPrerequisites
前提条件
Before the component will work, the following Salesforce settings must be configured by the user. ALWAYS call out the prequisites after successfully embedding the agent.
Cookie settings:
- Setup → My Domain → Disable "Require first party use of Salesforce cookies"
Trusted domains (required only for local development):
- Setup → Session Settings → Trusted Domains for Inline Frames → Add your domain
- Local development: (e.g.,
localhost:<PORT>)localhost:3000
- Local development:
在组件正常工作前,用户必须配置以下Salesforce设置。成功嵌入Agent后,务必告知用户这些前提条件。
Cookie设置:
- 设置 → 我的域名 → 禁用“要求仅使用Salesforce第一方Cookie”
可信域名(仅本地开发需要):
- 设置 → 会话设置 → 内联框架可信域名 → 添加你的域名
- 本地开发:(例如:
localhost:<PORT>)localhost:3000
- 本地开发:
Instructions
操作步骤
Step 1: Check if component already exists
步骤1:检查组件是否已存在
Search for existing usage across all app files (not implementation files):
bash
grep -r "AgentforceConversationClient" --include="*.tsx" --include="*.jsx" --exclude-dir=node_modulesImportant: Look for React files that import and USE the component (for example, shared shells, route components, or feature pages). Do NOT open files named or - those are the component implementation.
AgentforceConversationClient.tsxAgentforceConversationClient.jsxIf found: Read the file and check the current value.
agentIdAgent ID validation rule (deterministic):
- Valid only if it matches:
^0Xx[a-zA-Z0-9]{15}$ - Meaning: starts with and total length is 18 characters
0Xx
Decision:
- If matches
agentIdand user wants to update other props → Go to Step 4 (update props)^0Xx[a-zA-Z0-9]{15}$ - If is missing, empty, or does NOT match
agentId→ Continue to Step 2 (need real ID)^0Xx[a-zA-Z0-9]{15}$ - If not found → Continue to Step 2 (add new)
在所有应用文件(非实现文件)中搜索现有用法:
bash
grep -r "AgentforceConversationClient" --include="*.tsx" --include="*.jsx" --exclude-dir=node_modules**重要提示:**查找导入并使用该组件的React文件(例如共享外壳、路由组件或功能页面)。不要打开名为或的文件——这些是组件实现文件。
AgentforceConversationClient.tsxAgentforceConversationClient.jsx**如果找到:**读取文件并检查当前的值。
agentIdAgent ID验证规则(确定性):
- 仅当匹配时有效
^0Xx[a-zA-Z0-9]{15}$ - 含义:以开头,总长度为18个字符
0Xx
决策:
- 如果匹配
agentId,且用户希望更新其他属性 → 进入步骤4(更新属性)^0Xx[a-zA-Z0-9]{15}$ - 如果缺失、为空或不匹配
agentId→ 继续步骤2(需要真实ID)^0Xx[a-zA-Z0-9]{15}$ - 如果未找到 → 继续步骤2(添加新组件)
Step 2: Get agent ID
步骤2:获取Agent ID
If component doesn't exist or has an invalid placeholder value, ask user for their Salesforce agent ID.
Treat these as placeholder/invalid values:
"0Xx...""Placeholder""YOUR_AGENT_ID""<USER_AGENT_ID_18_CHAR_0Xx...>"- Any value that does not match
^0Xx[a-zA-Z0-9]{15}$
Skip this step if:
- Component exists with a real agent ID
- User only wants to update styling or dimensions
如果组件不存在或使用的是无效占位符值,请向用户索要其Salesforce Agent ID。
以下视为占位符/无效值:
"0Xx...""Placeholder""YOUR_AGENT_ID""<USER_AGENT_ID_18_CHAR_0Xx...>"- 任何不匹配的值
^0Xx[a-zA-Z0-9]{15}$
在以下情况跳过此步骤:
- 组件已存在且使用真实Agent ID
- 用户仅希望更新样式或尺寸
Step 3: Canonical import strategy
步骤3:标准导入策略
Use this import path by default in app code:
tsx
import { AgentforceConversationClient } from "@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client";If the package is not installed, install it:
bash
npm install @salesforce/ui-bundle-template-feature-react-agentforce-conversation-clientOnly use a local relative import (for example, ) when the user explicitly asks to use a patched/local component in that app.
./components/AgentforceConversationClientDo not infer import path from file discovery alone. Prefer one consistent package import across the codebase.
在应用代码中默认使用以下导入路径:
tsx
import { AgentforceConversationClient } from "@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client";如果未安装该包,请执行安装:
bash
npm install @salesforce/ui-bundle-template-feature-react-agentforce-conversation-client仅当用户明确要求在该应用中使用补丁/本地组件时,才使用本地相对导入(例如)。
./components/AgentforceConversationClient不要仅通过文件发现推断导入路径。优先在整个代码库中使用一致的包导入方式。
Step 4: Add or update component
步骤4:添加或更新组件
Determine which sub-step applies:
- Component NOT found in Step 1 → go to 4a (New installation)
- Component found in Step 1 → go to 4b (Update existing)
确定适用的子步骤:
- 步骤1中未找到组件 → 进入4a(全新安装)
- 步骤1中找到组件 → 进入4b(更新现有组件)
4a — New installation
4a — 全新安装
- If the user already specified a target file, use that file. Otherwise, ask the user: "Which file should I add the AgentforceConversationClient to?" Do NOT proceed until a target file is confirmed.
- Read the target file to understand its existing imports and TSX structure.
- Add the import at the top of the file, alongside existing imports. Use the canonical package import from Step 3:
tsx
import { AgentforceConversationClient } from "@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client";- Insert the TSX into the component's return block. Place it as a sibling of existing content — do NOT wrap or restructure existing TSX. Use the real
<AgentforceConversationClient />obtained in Step 2: Example:agentId
tsx
<AgentforceConversationClient agentId="0Xx8X00000001AbCDE" />- Do NOT add any other code (wrappers, layout components, new functions) unless the user explicitly requests it.
- 如果用户已指定目标文件,则使用该文件。否则,请询问用户:“我应该将AgentforceConversationClient添加到哪个文件中?”确认目标文件后再继续。
- 读取目标文件,了解其现有导入和TSX结构。
- 在文件顶部现有导入旁添加该组件的导入语句,使用步骤3中的标准包导入路径:
tsx
import { AgentforceConversationClient } from "@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client";- 将TSX元素插入组件的return块中。将其作为现有内容的同级元素放置——不要包裹或重构现有TSX。使用步骤2中获取的真实
<AgentforceConversationClient />: 示例:agentId
tsx
<AgentforceConversationClient agentId="0Xx8X00000001AbCDE" />- 除非用户明确要求,否则不要添加任何其他代码(包装器、布局组件、新函数)。
4b — Update existing
4b — 更新现有组件
- Read the file identified in Step 1.
- Locate the existing TSX element.
<AgentforceConversationClient ... /> - Apply only the changes the user requested. Rules:
- Add new props that the user asked for.
- Change prop values the user asked to update.
- Preserve every prop and value the user did NOT mention — do not remove, reorder, or reformat them.
- Never delete the component and recreate it.
- If the current is a placeholder (failed validation in Step 1) and a real agent ID was obtained in Step 2, replace the placeholder value:
agentId
tsx
// Before
<AgentforceConversationClient agentId="Placeholder" />
// After
<AgentforceConversationClient agentId="0Xx8X00000001AbCDE" />- If the current is already valid and the user did not ask to change it, leave it as-is.
agentId
- 读取步骤1中找到的文件。
- 找到现有的TSX元素。
<AgentforceConversationClient ... /> - 仅应用用户要求的更改。规则:
- 添加用户要求的新属性。
- 修改用户要求更新的属性值。
- 保留用户未提及的所有属性及其值——不要删除、重新排序或重新格式化它们。
- 切勿删除组件后重新创建。
- 如果当前是占位符(步骤1中验证失败),且已在步骤2中获取真实Agent ID,则替换占位符值:
agentId
tsx
// 之前
<AgentforceConversationClient agentId="Placeholder" />
// 之后
<AgentforceConversationClient agentId="0Xx8X00000001AbCDE" />- 如果当前已有效且用户未要求更改,则保持原样。
agentId
Step 5: Configure props
步骤5:配置属性
Available props (use directly on component):
- (string, required) - Salesforce agent ID
agentId - (boolean) -
inlinefor inline mode, omit for floatingtrue - (number | string) - e.g.,
widthor420"100%" - (number | string) - e.g.,
heightor600"80vh" - (boolean) - Show/hide header
headerEnabled - (object) - For all styling (colors, fonts, spacing)
styleTokens - (string) - Auto-resolved
salesforceOrigin - (string) - Auto-resolved
frontdoorUrl - (string) - header title for agent
agentLabel
Examples:
Floating mode (default):
tsx
<AgentforceConversationClient agentId="0Xx..." />Inline mode with dimensions:
tsx
<AgentforceConversationClient agentId="0Xx..." inline width="420px" height="600px" />Adding or updating agent label:
tsx
<AgentforceConversationClient agentId="0Xx..." agentLabel="<dummy-agent-label>" />Styling rules (mandatory):
- ALL visual customization (colors, fonts, spacing, borders, radii, shadows) MUST go through the prop. There are no exceptions.
styleTokens - ONLY use token names listed in the tables below. Do NOT invent custom token names.
- NEVER apply styling via CSS files, attributes,
style, or wrapper elements. These approaches will not work and will be ignored by the component.className - If the user requests a visual change that does not map to a token below, inform them that the change is not supported by the current token set.
可用属性(直接在组件上使用):
- (字符串,必填)- Salesforce Agent ID
agentId - (布尔值)-
inline表示内联模式,省略则为浮动模式true - (数字 | 字符串)- 例如:
width或420"100%" - (数字 | 字符串)- 例如:
height或600"80vh" - (布尔值)- 显示/隐藏头部
headerEnabled - (对象)- 用于所有样式设置(颜色、字体、间距)
styleTokens - (字符串)- 自动解析
salesforceOrigin - (字符串)- 自动解析
frontdoorUrl - (字符串)- Agent的头部标题
agentLabel
示例:
浮动模式(默认):
tsx
<AgentforceConversationClient agentId="0Xx..." />带尺寸的内联模式:
tsx
<AgentforceConversationClient agentId="0Xx..." inline width="420px" height="600px" />添加或更新Agent标签:
tsx
<AgentforceConversationClient agentId="0Xx..." agentLabel="<dummy-agent-label>" />样式设置规则(强制):
- 所有视觉自定义(颜色、字体、间距、边框、圆角、阴影)必须通过属性完成。无例外。
styleTokens - 仅使用下表中列出的令牌名称。不要自创自定义令牌名称。
- 切勿通过CSS文件、属性、
style或包装元素应用样式。这些方法无效,会被组件忽略。className - 如果用户请求的视觉更改无法映射到以下令牌,请告知用户当前令牌集不支持该更改。
Container
容器
| Token name | UI area themed |
|---|---|
| FAB button background color |
| Chat container background |
| Header background |
| Chat container width |
| Chat border radius |
| Layout max width |
| 令牌名称 | 主题化的UI区域 |
|---|---|
| FAB按钮背景色 |
| 聊天容器背景色 |
| 头部背景色 |
| 聊天容器宽度 |
| 聊天组件圆角 |
| 布局最大宽度 |
Agentforce Header
Agentforce头部
| Token name | UI area themed |
|---|---|
| Header block background |
| Header border bottom width |
| Header border bottom style |
| Header border bottom color |
| Header corner radius |
| Header block padding (vertical) |
| Header inline padding (horizontal) |
| Header minimum height |
| Header branding area gap |
| Header font family |
| Header title font weight |
| Header title font size |
| Header title line height |
| Header text color |
| Header icon display |
| Header icon margin |
| Header icon color |
| Header icon width |
| Header icon height |
| Header logo max height |
| Header logo max width |
| Header logo min width |
| Header action button height |
| Header action button width |
| Header action button padding |
| Header action button border radius |
| Header hover background |
| Header active background |
| Header focus border |
| 令牌名称 | 主题化的UI区域 |
|---|---|
| 头部区块背景色 |
| 头部底部边框宽度 |
| 头部底部边框样式 |
| 头部底部边框颜色 |
| 头部圆角 |
| 头部区块内边距(垂直) |
| 头部区块内边距(水平) |
| 头部最小高度 |
| 头部品牌区域间距 |
| 头部字体族 |
| 头部标题字体粗细 |
| 头部标题字体大小 |
| 头部标题行高 |
| 头部文字颜色 |
| 头部图标显示方式 |
| 头部图标外边距 |
| 头部图标颜色 |
| 头部图标宽度 |
| 头部图标高度 |
| 头部Logo最大高度 |
| 头部Logo最大宽度 |
| 头部Logo最小宽度 |
| 头部操作按钮高度 |
| 头部操作按钮宽度 |
| 头部操作按钮内边距 |
| 头部操作按钮圆角 |
| 头部悬停背景色 |
| 头部激活状态背景色 |
| 头部焦点边框 |
Agentforce Welcome Block
Agentforce欢迎区块
| Token name | UI area themed |
|---|---|
| Welcome text container width |
| Welcome block font family |
| Welcome block font size |
| Welcome block font weight |
| Welcome block line height |
| Welcome block letter spacing |
| Welcome block text color |
| Welcome block vertical padding |
| Welcome block horizontal padding |
| Welcome text animation duration |
| 令牌名称 | 主题化的UI区域 |
|---|---|
| 欢迎文字容器宽度 |
| 欢迎区块字体族 |
| 欢迎区块字体大小 |
| 欢迎区块字体粗细 |
| 欢迎区块行高 |
| 欢迎区块字间距 |
| 欢迎区块文字颜色 |
| 欢迎区块垂直内边距 |
| 欢迎区块水平内边距 |
| 欢迎文字动画时长 |
Agentforce Messages
Agentforce消息
| Token name | UI area themed |
|---|---|
| Message block border radius |
| Avatar display property (e.g. |
| Message actions display (e.g. |
| Copy action button display (e.g. |
| Message block container padding |
| Message block font size |
| Message block background (base) |
| Inbound message border |
| Outbound message border |
| Message block body width |
| Message block padding |
| Message block container top margin |
| Message block line height |
| 令牌名称 | 主题化的UI区域 |
|---|---|
| 消息区块圆角 |
| 头像显示属性(例如 |
| 消息操作显示(例如 |
| 复制操作按钮显示(例如 |
| 消息区块容器内边距 |
| 消息区块字体大小 |
| 消息区块背景色(基础) |
| 接收消息边框 |
| 发送消息边框 |
| 消息区块主体宽度 |
| 消息区块内边距 |
| 消息区块容器上边距 |
| 消息区块行高 |
Avatar visibility (behavioral config)
头像可见性(行为配置)
Use to control whether avatars are rendered in message rows.
renderingConfig.showAvatar- (default) renders avatars.
showAvatar: true - hides avatars by removing them from the DOM.
showAvatar: false
使用控制消息行中是否渲染头像。
renderingConfig.showAvatar- (默认)渲染头像。
showAvatar: true - 通过从DOM中移除头像来隐藏它们。
showAvatar: false
Inbound message (agent → customer)
接收消息(Agent → 客户)
| Token name | UI area themed |
|---|---|
| Inbound message text color (base) |
| Inbound message border radius |
| Inbound message background |
| Inbound message text color |
| Inbound message width |
| Inbound message text alignment |
| Inbound message hover background |
| 令牌名称 | 主题化的UI区域 |
|---|---|
| 接收消息文字颜色(基础) |
| 接收消息圆角 |
| 接收消息背景色 |
| 接收消息文字颜色 |
| 接收消息宽度 |
| 接收消息文字对齐方式 |
| 接收消息悬停背景色 |
Outbound message (customer → agent)
发送消息(客户 → Agent)
| Token name | UI area themed |
|---|---|
| Outbound message border radius |
| Outbound message background |
| Outbound message text color |
| Outbound message width |
| Outbound message left margin |
| Outbound message text alignment |
| 令牌名称 | 主题化的UI区域 |
|---|---|
| 发送消息圆角 |
| 发送消息背景色 |
| 发送消息文字颜色 |
| 发送消息宽度 |
| 发送消息左边距 |
| 发送消息文字对齐方式 |
Agentforce Input
Agentforce输入框
| Token name | UI area themed |
|---|---|
| Message input container padding |
| Message input footer border color |
| Message input border radius |
| Message input border transition duration |
| Message input border transition easing |
| Message input text color |
| Message input text background color |
| Message input footer focus border color |
| Message input focus shadow |
| Message input max height |
| Message input line height |
| Message input text padding |
| Message input font weight |
| Message input font size |
| Message input overflow Y |
| Message input scrollbar width |
| Message input scrollbar color |
| Message input actions width |
| Message input actions right padding |
| Message input placeholder text color |
| Placeholder font weight |
| Message input error text color |
| Message input actions gap |
| Message input actions padding |
| Message input action button size |
| Message input action button radius |
| Message input send button color |
| Message input send button disabled color |
| Message input action button focus border |
| Message input action button active icon color |
| Message input action button active background |
| Message input send button icon color |
| Message input send button hover color |
| Message input action button hover shadow |
| Message input file preview padding |
| Message input textarea max height |
| Message input textarea max height (with image) |
| 令牌名称 | 主题化的UI区域 |
|---|---|
| 消息输入容器内边距 |
| 消息输入底部边框颜色 |
| 消息输入框圆角 |
| 消息输入框边框过渡时长 |
| 消息输入框边框过渡缓动效果 |
| 消息输入文字颜色 |
| 消息输入文字背景色 |
| 消息输入底部焦点边框颜色 |
| 消息输入框焦点阴影 |
| 消息输入框最大高度 |
| 消息输入行高 |
| 消息输入文字内边距 |
| 消息输入字体粗细 |
| 消息输入字体大小 |
| 消息输入框垂直溢出方式 |
| 消息输入框滚动条宽度 |
| 消息输入框滚动条颜色 |
| 消息输入操作区宽度 |
| 消息输入操作区右边距 |
| 消息输入框占位符文字颜色 |
| 占位符字体粗细 |
| 消息输入框错误文字颜色 |
| 消息输入操作区间距 |
| 消息输入操作区内边距 |
| 消息输入操作按钮尺寸 |
| 消息输入操作按钮圆角 |
| 消息输入框发送按钮颜色 |
| 消息输入框发送按钮禁用状态颜色 |
| 消息输入操作按钮焦点边框 |
| 消息输入操作按钮激活状态图标颜色 |
| 消息输入操作按钮激活状态背景色 |
| 消息输入框发送按钮图标颜色 |
| 消息输入框发送按钮悬停颜色 |
| 消息输入操作按钮悬停阴影 |
| 消息输入文件预览内边距 |
| 消息输入文本域最大高度 |
| 消息输入文本域(带图片)最大高度 |
Agentforce Error Block
Agentforce错误区块
| Token name | UI area themed |
|---|---|
| Error block background color |
Styling with styleTokens:
tsx
<AgentforceConversationClient
agentId="0Xx..."
styleTokens={{
headerBlockBackground: "#0176d3",
headerBlockTextColor: "#ffffff",
messageBlockInboundBackgroundColor: "#4CAF50",
}}
/>For complex patterns, consult for:
references/examples.md- Sidebar containers and responsive sizing
- Dark theme and advanced theming combinations
- Inline without header, calculated dimensions
- Complete host component examples
Common mistakes to avoid: Consult for:
references/constraints.md- Invalid props (containerStyle, style, className)
- Invalid styling approaches (CSS files, style tags)
- What files NOT to edit (implementation files)
| 令牌名称 | 主题化的UI区域 |
|---|---|
| 错误区块背景色 |
使用styleTokens设置样式:
tsx
<AgentforceConversationClient
agentId="0Xx..."
styleTokens={{
headerBlockBackground: "#0176d3",
headerBlockTextColor: "#ffffff",
messageBlockInboundBackgroundColor: "#4CAF50",
}}
/>对于复杂模式,请查阅获取以下内容:
references/examples.md- 侧边栏容器和响应式尺寸
- 深色主题和高级主题组合
- 无头部内联模式、计算尺寸
- 完整宿主组件示例
需避免的常见错误:请查阅获取以下内容:
references/constraints.md- 无效属性(containerStyle、style、className)
- 无效样式设置方法(CSS文件、style标签)
- 不应编辑的文件(实现文件)
Common Issues
常见问题
If component doesn't appear or authentication fails, see for:
references/troubleshooting.md- Agent activation and deployment
- Localhost trusted domains
- Cookie restriction settings
如果组件未显示或验证失败,请查阅获取以下内容:
references/troubleshooting.md- Agent激活与部署
- Localhost可信域名
- Cookie限制设置