@salesforce/agentforce-conversation-client 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,6 +13,8 @@ This library embeds the Agentforce Conversation Client for employee agents using
13
13
  - **One of `salesforceOrigin` or `frontdoorUrl` is required.**
14
14
  - Use `salesforceOrigin` when your app is hosted inside a Salesforce org and already has an authenticated session.
15
15
  - Use `frontdoorUrl` when embedding the chat client outside Salesforce (for example, a localhost or external app).
16
+
17
+ - Use `sitePrefix` so LO 2.0 can correctly resolve asset URLs and route requests through the right site context. `site-prefix` is the path segment of the Experience Site URL after the host. For example, if your site URL is https://mydomain.my.site.com/sample, the site prefix is /sample
16
18
  - Lightning Out 2.0 uses an existing session to initialize; without it, the embed will fail to start.
17
19
 
18
20
  ## Installation
@@ -341,6 +343,18 @@ const { loApp } = embedAgentforceClient({
341
343
  });
342
344
  ```
343
345
 
346
+ ### With Experience Cloud `sitePrefix`
347
+
348
+ ```typescript
349
+ import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";
350
+
351
+ const { loApp } = embedAgentforceClient({
352
+ container: "#agentforce-container",
353
+ frontdoorUrl: "https://myorg.my.salesforce.com/secur/frontdoor.jsp?otp=...",
354
+ sitePrefix: "/my-site",
355
+ });
356
+ ```
357
+
344
358
  ### Listening for Events
345
359
 
346
360
  ```typescript
@@ -378,6 +392,7 @@ Embeds the Agentforce Conversation Client by creating a Lightning Out 2.0 app an
378
392
  | `options.salesforceOrigin` | `string` | No | Salesforce org origin URL (use when hosted in a Salesforce org). At least one of `salesforceOrigin` or `frontdoorUrl` is required |
379
393
  | `options.appId` | `string` | No | 18-digit Lightning Out 2.0 app ID (`app-id`); find it in Lightning Out 2.0 App Manager in Setup; not required for apps created before Spring '26 |
380
394
  | `options.frontdoorUrl` | `string` | No | Frontdoor URL for authentication (use when embedding outside Salesforce). At least one of `salesforceOrigin` or `frontdoorUrl` is required |
395
+ | `options.sitePrefix` | `string` | No | Experience Cloud site prefix used by Lightning Out (for example, `"/my-site"`). Set as `site-prefix` on the LO app |
381
396
  | `options.agentforceClientConfig` | `AgentforceClientConfig` | No | Configuration for the Agentforce client (see sub-properties below) |
382
397
  | `agentforceClientConfig.agentId` | `string` | Yes\* | The agent to load — required in practice, will not work without it |
383
398
  | `agentforceClientConfig.agentLabel` | `string` | No | Display name shown in the chat header. Falls back to the agent's configured name if omitted |
@@ -424,6 +439,7 @@ interface EmbedAgentforceClientOptions {
424
439
  salesforceOrigin?: string;
425
440
  appId?: string;
426
441
  frontdoorUrl?: string;
442
+ sitePrefix?: string;
427
443
  agentforceClientConfig?: AgentforceClientConfig;
428
444
  }
429
445
 
package/dist/index.d.ts CHANGED
@@ -32,6 +32,7 @@ export interface EmbedAgentforceClientOptions {
32
32
  salesforceOrigin?: string;
33
33
  appId?: string;
34
34
  frontdoorUrl?: string;
35
+ sitePrefix?: string;
35
36
  agentforceClientConfig?: AgentforceClientConfig;
36
37
  }
37
38
  export interface EmbedAgentforceClientResult {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAMrE,eAAO,MAAM,6BAA6B,oCAAoC,CAAC;AAC/E,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAC7D,eAAO,MAAM,gCAAgC,kBAAkB,CAAC;AAChE,eAAO,MAAM,2BAA2B,YAAY,CAAC;AAErD,eAAO,MAAM,aAAa;;;EAGf,CAAC;AAEZ,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAMpF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD,MAAM,WAAW,sBAAsB;IACtC,WAAW,CAAC,EAAE,WAAW,CA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;AAMpF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD,MAAM,WAAW,sBAAsB;IACtC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE;QACjB,IAAI,CAAC,EAAE,kBAAkB,CAAC;QAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACzB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,UAAU,CAAC,EAAE,OAAO,CAAC;KACrB,CAAC;CACF;AAED,MAAM,WAAW,4BAA4B;IAC5C,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CAChD;AAED,MAAM,WAAW,2BAA2B;IAC3C,KAAK,EAAE,uBAAuB,CAAC;IAC/B,mBAAmB,EAAE,WAAW,CAAC;CACjC;AAgVD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,CAAC,EAAE,4BAA4B,GAAG,IAAI,GAC3C,2BAA2B,CAyB7B"}
package/dist/index.js CHANGED
@@ -210,7 +210,7 @@ function createAndMountFrame(container, clientConfig, loApp) {
210
210
  // ═══════════════════════════════════════════════════════════════════════════════
211
211
  // LIGHTNING OUT – LO app creation and error handling
212
212
  // ═══════════════════════════════════════════════════════════════════════════════
213
- function createAndMountLoApp(container, salesforceOrigin, appId, frontdoorUrl) {
213
+ function createAndMountLoApp(container, salesforceOrigin, appId, frontdoorUrl, sitePrefix) {
214
214
  const loApp = new LightningOutApplication();
215
215
  if (salesforceOrigin)
216
216
  loApp.setAttribute("org-url", salesforceOrigin);
@@ -220,6 +220,8 @@ function createAndMountLoApp(container, salesforceOrigin, appId, frontdoorUrl) {
220
220
  loApp.setAttribute("app-id", appId);
221
221
  if (frontdoorUrl)
222
222
  loApp.setAttribute("frontdoor-url", frontdoorUrl);
223
+ if (sitePrefix)
224
+ loApp.setAttribute("site-prefix", sitePrefix);
223
225
  loApp.style.opacity = "0";
224
226
  loApp.style.pointerEvents = "none";
225
227
  attachLoEventHandlers(loApp);
@@ -248,9 +250,9 @@ function resolveContainer(container) {
248
250
  return null;
249
251
  }
250
252
  function embedIntoContainer(containerElement, options) {
251
- const { salesforceOrigin, appId, frontdoorUrl, agentforceClientConfig = {} } = options;
253
+ const { salesforceOrigin, appId, frontdoorUrl, sitePrefix, agentforceClientConfig = {}, } = options;
252
254
  containerElement.classList.add("acc-container");
253
- const loApp = createAndMountLoApp(containerElement, salesforceOrigin, appId, frontdoorUrl);
255
+ const loApp = createAndMountLoApp(containerElement, salesforceOrigin, appId, frontdoorUrl, sitePrefix);
254
256
  const chatClientComponent = createAndMountFrame(containerElement, agentforceClientConfig, loApp);
255
257
  return { loApp, chatClientComponent };
256
258
  }
@@ -269,7 +271,7 @@ function embedIntoContainer(containerElement, options) {
269
271
  * });
270
272
  */
271
273
  export function embedAgentforceClient(options) {
272
- const { container, salesforceOrigin, appId, frontdoorUrl, agentforceClientConfig = {}, } = options ?? {};
274
+ const { container, salesforceOrigin, appId, frontdoorUrl, sitePrefix, agentforceClientConfig = {}, } = options ?? {};
273
275
  if (!container)
274
276
  throw new Error("Agentforce Conversation Client: container is required");
275
277
  if (!salesforceOrigin && !frontdoorUrl) {
@@ -284,6 +286,7 @@ export function embedAgentforceClient(options) {
284
286
  salesforceOrigin,
285
287
  appId,
286
288
  frontdoorUrl,
289
+ sitePrefix,
287
290
  agentforceClientConfig,
288
291
  });
289
292
  }
@@ -102,6 +102,14 @@ describe("Agentforce Conversation Client SDK", () => {
102
102
  expect(mockSetAttribute).not.toHaveBeenCalledWith("org-url", expect.anything());
103
103
  expect(mockSetAttribute).toHaveBeenCalledWith("frontdoor-url", "https://test.salesforce.com/secur/frontdoor.jsp");
104
104
  });
105
+ it("sets site-prefix when provided", () => {
106
+ embedAgentforceClient({
107
+ container: "#test-container",
108
+ salesforceOrigin: "https://test.salesforce.com",
109
+ sitePrefix: "/my-site",
110
+ });
111
+ expect(mockSetAttribute).toHaveBeenCalledWith("site-prefix", "/my-site");
112
+ });
105
113
  it("sets Lightning Out app-id when provided", () => {
106
114
  embedAgentforceClient({
107
115
  container: "#test-container",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/agentforce-conversation-client",
3
3
  "description": "Agentforce Conversation Client SDK for embedding via Lightning Out 2.0",
4
- "version": "2.0.0",
4
+ "version": "2.1.0",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",