$npx -y skills add forcedotcom/sf-skills --skill experience-ui-bundle-agentforce-client-generateUse this skill when the user asks to add, embed, integrate, configure, style, or remove an agent, chatbot, chat widget, conversation client, or AI assistant in a UI Bundle project. TRIGGER when: project contains a uiBundles/*/src/ directory and the task involves adding or modifyi
| 1 | # Managing Agentforce Conversation Client |
| 2 | |
| 3 | **HARD CONSTRAINT:** NEVER create a custom agent, chatbot, or chat widget component. ALL such requests MUST be fulfilled by importing and rendering the existing `<AgentforceConversationClient />` from `@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client` as documented below. If a requirement is unsupported by this component's props, state the limitation — do not improvise an alternative. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | 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. |
| 8 | |
| 9 | **Trusted domains (required only for local development):** |
| 10 | |
| 11 | - Setup → Session Settings → Trusted Domains for Inline Frames → Add your domain |
| 12 | - Local development: `localhost:5173` (default Vite dev server port) |
| 13 | - **Warning:** Remove this trusted domain entry before deploying to production. |
| 14 | |
| 15 | ## Instructions |
| 16 | |
| 17 | ### Step 1: Check if component already exists |
| 18 | |
| 19 | Search for existing usage across all app files (not implementation files): |
| 20 | |
| 21 | ```bash |
| 22 | grep -r "AgentforceConversationClient" --include="*.tsx" --include="*.jsx" --exclude-dir=node_modules |
| 23 | ``` |
| 24 | |
| 25 | **Important:** Look for React files that import and USE the component (for example, shared shells, route components, or feature pages). Do NOT open files named `AgentforceConversationClient.tsx` or `AgentforceConversationClient.jsx` - those are the component implementation. |
| 26 | |
| 27 | **If multiple files found:** Ask the user which component file they are referring to. Do not proceed until clarified. |
| 28 | |
| 29 | **If found:** Read the file and check the current `agentId` value. |
| 30 | |
| 31 | **Agent ID validation rule (deterministic):** |
| 32 | |
| 33 | - Valid only if it matches: `^0Xx[a-zA-Z0-9]{15}$` |
| 34 | - Meaning: starts with `0Xx` and total length is 18 characters |
| 35 | |
| 36 | **Decision:** |
| 37 | |
| 38 | - If `agentId` matches `^0Xx[a-zA-Z0-9]{15}$` and user wants to update other props → Go to Step 4 (update props) |
| 39 | - If `agentId` matches `^0Xx[a-zA-Z0-9]{15}$` and user asks to "embed" or "add" the chat client → Inform: "The Agentforce Conversation Client is already embedded in `<file>` with agent ID `<agentId>`. Would you like to change the agent or update other props?" |
| 40 | - Change agent → Step 2 |
| 41 | - Update props → Step 4b |
| 42 | - If `agentId` is missing, empty, or does NOT match `^0Xx[a-zA-Z0-9]{15}$` → Continue to Step 2 (need real ID) |
| 43 | - If not found → Continue to Step 2 (add new) |
| 44 | |
| 45 | **If user reports an error:** |
| 46 | |
| 47 | If the user says the component is "not working", "showing an error", or similar — ask them for the specific error message. Then proceed to Step 2 to cross-check the configured agentId against the org. |
| 48 | |
| 49 | ### Step 2: Resolve and Validate Agent ID |
| 50 | |
| 51 | #### Prerequisites |
| 52 | |
| 53 | 1. **Verify sf CLI is available:** |
| 54 | ```bash |
| 55 | sf --version |
| 56 | ``` |
| 57 | If fails: |
| 58 | - Inform: "The Salesforce CLI (`sf`) is not installed. It's needed to query available agents from your org." |
| 59 | - Ask: "Would you like me to install it?" |
| 60 | - Yes → Install via `npm install -g @salesforce/cli`, then continue. |
| 61 | - No → "You can find your agent ID manually in Setup → Agentforce Agents → click the agent name → copy the ID from the URL. Would you like to provide it now, or skip this step?" |
| 62 | - User provides ID → validate format (`^0Xx[a-zA-Z0-9]{15}$`), store it, proceed to Step 3. |
| 63 | - Skip → proceed to Step 4 with placeholder `<YOUR_AGENT_ID>`. |
| 64 | |
| 65 | 2. **Verify org connectivity:** |
| 66 | ```bash |
| 67 | sf org display --json |
| 68 | ``` |
| 69 | If fails: |
| 70 | - Inform: "No authenticated org found." |
| 71 | - Ask: "Would you like to connect to your org now? Run `sf org login web` to authenticate." |
| 72 | - User authenticates → retry the query, continue. |
| 73 | - User declines → "You can find your agent ID manually in Setup → Agentforce Agents → click the agent name → copy the ID from the URL. Would you like to provide it now, or skip this step?" |
| 74 | - User provides ID → validate format, store it, proceed to Step 3. |
| 75 | - Skip → proceed to Step 4 with placeholder `<YOUR_AGENT_ID>`. |
| 76 | |
| 77 | **Note:** Even if the user provides their own agentId, the org must be connected for the agent to function at runtime. An agentId without a c |