Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@salesforce/agentforce-conversation-client

Package Overview
Dependencies
Maintainers
28
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/agentforce-conversation-client

Agentforce Conversation Client SDK for embedding via Lightning Out 2.0

latest
npmnpm
Version
1.54.0
Version published
Maintainers
28
Created
Source

@salesforce/agentforce-conversation-client

Agentforce Conversation Client SDK for embedding the Agentforce chat experience into external applications. By default, Lightning Out 2.0 is embedded within the target container.

Overview

This library embeds the Agentforce Conversation Client using Lightning Out 2.0. The salesforceOrigin option is passed to the Lightning Out application as the org-url attribute. You can also pass appId to set the Lightning Out app-id attribute. The appId is the 18-digit Lightning Out 2.0 app ID (for example, 1Usfi200000006TCAQ). You can find this value in the Lightning Out 2.0 App Manager in Setup.

Prerequisites

  • One of salesforceOrigin or frontdoorUrl is required.
  • Use salesforceOrigin when your app is hosted inside a Salesforce org and already has an authenticated session.
  • Use frontdoorUrl when embedding the chat client outside Salesforce (for example, a localhost or external app).
  • Lightning Out uses an existing session to initialize; without it, the embed will fail to start.

Installation

npm install @salesforce/agentforce-conversation-client

Usage

Basic Embedding

import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";

const { loApp, chatClientComponent } = embedAgentforceClient({
  container: "#agentforce-container",
  salesforceOrigin: "https://myorg.my.salesforce.com",
});

With agentId

import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";

const { loApp, chatClientComponent } = embedAgentforceClient({
  container: "#agentforce-container",
  salesforceOrigin: "https://myorg.my.salesforce.com",
  agentforceClientConfig: {
    agentId: "AGENT_ID_FROM_ORG",
  },
});

With rendering modes

import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";

// Floating (default)
embedAgentforceClient({
  container: "#agentforce-container",
  salesforceOrigin: "https://myorg.my.salesforce.com",
  agentforceClientConfig: {
    renderingConfig: { mode: "floating" },
  },
});

// Inline (width/height configurable)
embedAgentforceClient({
  container: "#agentforce-container",
  salesforceOrigin: "https://myorg.my.salesforce.com",
  agentforceClientConfig: {
    renderingConfig: { mode: "inline", width: 420, height: 600 },
  },
});

Theming with styleTokens

Use agentforceClientConfig.styleTokens to theme the Agentforce Conversation Client. You do not need to provide all tokens—only the ones you want to override. Tokens are grouped by UI area:

Example

import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";

const { loApp, chatClientComponent } = embedAgentforceClient({
  container: "#agentforce-container",
  salesforceOrigin: "https://myorg.my.salesforce.com",
  agentforceClientConfig: {
    styleTokens: {
      headerBlockBackground: "#7B2CBF",
      headerBlockTextColor: "#ffffff",
    },
  },
});

Agentforce Header

Token nameUI area themed
headerBlockBackgroundHeader background
headerBlockBorderColorHeader border
headerBlockFontFamilyHeader font family
headerBlockTextColorHeader text color
headerBlockHoverBackgroundHeader hover background
headerBlockActiveBackgroundHeader active background
headerBlockFocusBorderHeader focus border

Agentforce Messages

Token nameUI area themed
messageBlockBodyPaddingBottomMessage block body bottom padding
messageBlockTextPaddingMessage block text padding
messageBlockPaddingContainerMessage block container padding
messageBlockContainerMarginTopMessage block container top margin
messageBlockPaddingMessage block padding
messageBlockBorderRadiusMessage block border radius
messageBlockFontSizeMessage block font size
messageBlockLineHeightMessage block line height
messageBlockBackgroundColorMessage block background (base)
messageBlockBodyWidthMessage block body width

Inbound message (customer → agent)

Token nameUI area themed
messageBlockInboundHoverBackgroundColorInbound message hover background
messageBlockInboundBackgroundColorInbound message background
messageBlockInboundTextColorInbound message text color
messageBlockInboundWidthInbound message width
messageBlockInboundTextAlignInbound message text alignment

Outbound message (agent → customer)

Token nameUI area themed
messageBlockOutboundBackgroundColorOutbound message background
messageBlockOutboundTextColorOutbound message text color
messageBlockOutboundWidthOutbound message width
messageBlockOutboundMarginLeftOutbound message left margin
messageBlockOutboundTextAlignOutbound message text alignment

Agentforce Input

Token nameUI area themed
messageInputPaddingMessage input container padding
messageInputBorderRadiusMessage input border radius
messageInputFooterBorderColorMessage input footer border color
messageInputFooterBorderFocusColorMessage input footer focus border color
messageInputBorderTransitionDurationMessage input border transition duration
messageInputBorderTransitionEasingMessage input border transition easing
messageInputTextColorMessage input text color
messageInputTextBackgroundColorMessage input text background color
messageInputFooterPlaceholderTextMessage input placeholder text color
messageInputErrorTextColorMessage input error text color
messageInputFontSizeMessage input font size
messageInputFontWeightMessage input font weight
messageInputPlaceholderFontWeightPlaceholder font weight
messageInputLineHeightMessage input line height
messageInputMaxHeightMessage input max height
messageInputTextPaddingMessage input text padding
messageInputActionsWidthMessage input actions width
messageInputActionsPaddingRightMessage input actions right padding
messageInputActionsGapMessage input actions gap
messageInputActionsPaddingMessage input actions padding
messageInputOverflowYMessage input overflow Y
messageInputScrollbarWidthMessage input scrollbar width
messageInputScrollbarColorMessage input scrollbar color
messageInputTextareaMaxHeightMessage input textarea max height
messageInputTextareaWithImageMaxHeightMessage input textarea max height (with image)
messageInputFilePreviewPaddingMessage input file preview padding
messageInputActionButtonSizeMessage input action button size
messageInputActionButtonRadiusMessage input action button radius
messageInputActionButtonFocusBorderMessage input action button focus border
messageInputActionButtonHoverShadowMessage input action button hover shadow
messageInputFooterSendButtonMessage input send button color
messageInputFooterSendButtonHoverColorMessage input send button hover color
messageInputSendButtonDisabledColorMessage input send button disabled color

With Configuration

import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";

const { loApp, chatClientComponent } = embedAgentforceClient({
  container: "#agentforce-container",
  salesforceOrigin: "https://myorg.my.salesforce.com",
  agentforceClientConfig: {
    // styleTokens supports theming the Agentforce Conversation Client
    styleTokens: {
      MessageBlockInboundColor: "#0176d3",
    },
    renderingConfig: {
      mode: "inline", // or "floating"
      width: 420,
      height: 600,
    },
  },
});

With Lightning Out App ID

import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";

const { loApp } = embedAgentforceClient({
  container: "#agentforce-container",
  salesforceOrigin: "https://myorg.my.salesforce.com",
  appId: "18_DIGIT_SALESFORCE_ID",
});

Listening for Events

const { loApp } = embedAgentforceClient({
  container: "#agentforce-container",
  salesforceOrigin: "https://myorg.my.salesforce.com",
});

loApp.addEventListener("lo.application.ready", () => {
  console.log("Lightning Out is ready");
});

loApp.addEventListener("lo.component.ready", (event) => {
  console.log("Component ready:", event.detail.componentName);
});

loApp.addEventListener("lo.application.error", (event) => {
  console.error("Error:", event.detail);
});

API

embedAgentforceClient(options)

Embeds the Agentforce Conversation Client into a specified DOM container. By default, Lightning Out is embedded within the target container.

Parameters

ParameterTypeRequiredDescription
options.containerstring | HTMLElementYesCSS selector or HTMLElement to embed into
options.salesforceOriginstringNoSalesforce org origin URL (use when hosted in a Salesforce org)
options.appIdstringNo18-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
options.frontdoorUrlstringNoFrontdoor URL for authentication (use when embedding outside Salesforce)
options.agentforceClientConfigAgentforceClientConfigNoConfiguration for the Agentforce client

Returns

PropertyTypeDescription
loAppLightningOutApplicationThe Lightning Out application
chatClientComponentHTMLElementThe chat client component element

Types

// Accepts any style property key-value pairs
type StyleTokens = Record<string, string>;

interface AgentforceClientConfig {
  // styleTokens supports theming the Agentforce Conversation Client
  styleTokens?: StyleTokens;
  renderingConfig?: {
    mode?: "inline" | "floating";
    width?: string | number;
    height?: string | number;
  };
}

interface EmbedAgentforceClientOptions {
  container: string | HTMLElement;
  salesforceOrigin?: string;
  appId?: string;
  frontdoorUrl?: string;
  agentforceClientConfig?: AgentforceClientConfig;
}

interface EmbedAgentforceClientResult {
  loApp: LightningOutApplication;
  chatClientComponent: HTMLElement;
}

Development

# Build the package
npm run build

# Watch mode for development
npm run dev

License

See LICENSE file in the repository root.

FAQs

Package last updated on 25 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts