# Connect Salesforce B2C Commerce to ChatRex

Install the ChatRex Commerce App Package and connect one Salesforce B2C Commerce site for live catalog lookup.

The integration gives a ChatRex assistant read-only access to the online catalog of one Salesforce B2C Commerce site. Salesforce calculates prices and availability in the selected site, locale, and currency context.

ChatRex does not request customers or orders and cannot modify products, inventory, or price books.

# Before you connect

You need:

  • B2C Commerce administrator access and access to Business Manager;
  • permission to install a Commerce App Package and activate a code version;
  • access to SCAPI and SLAS configuration;
  • an online product in the target site;
  • the exact SCAPI short code, organization ID, site ID, content library ID, locale, and currency.

# Install the package

  1. In ChatRex, open Integrations, select Salesforce B2C Commerce, and open Connection setup.
  2. Select Download installation package.
  3. Install the Commerce App Package for the target site and complete its tasksList.
  4. Activate the installed code version.
  5. Confirm that int_chatrex_catalog is present in the target site's cartridge path and that the Storefront Next pull request contains the chatrex-ai-sales-assistant extension.
  6. In Custom Site Preferences, set chatrexProductUrlTemplate to an HTTPS template containing the required {id} placeholder. {variantId} is optional.
  7. Create a private SLAS client for the target site with the single functional scope c_chatrex_catalog.

Example product URL template: https://store.example/products/{id}.

# Connect the site in ChatRex

Enter these values in the Salesforce B2C Commerce connection form:

  • SCAPI short code — the eight-character B2C Commerce API environment code;
  • Organization ID;
  • Site ID;
  • Content library ID assigned to the site;
  • Public storefront URL using HTTPS;
  • Locale, for example en-US;
  • Currency as a three-letter code, for example USD;
  • Private SLAS client ID and Private SLAS client secret.

Select Connect. ChatRex verifies the site, catalog, content library, locale, currency, and required scope before saving the connection. The SLAS credentials are sent only to the ChatRex backend, encrypted at rest, and never shown after connection.

# Add the widget to Storefront Next

  1. In ChatRex, create or select an Online chat channel and allowlist the exact Storefront Next origin.
  2. Copy that integration's public ID. It identifies the widget and is not a Salesforce or SLAS secret.
  3. Set this Storefront Next environment variable:

    PUBLIC__app__extension__chatrexAiSalesAssistant__widgetIntegrationId=<online chat ID>
  4. In the storefront Content Security Policy, add https://app.chatrex.pro to script-src and connect-src, and add wss://socket.chatrex.pro to connect-src.
  5. Build and publish Storefront Next.
  6. Open the storefront, interact with the page, and verify that exactly one ChatRex widget loads.

If the ID is missing or invalid, the extension leaves the storefront unchanged and does not load an external script. Never place Salesforce or SLAS credentials in frontend configuration.

# Add assistant actions

Open the bot, go to Integrations and actions, and add any of these actions:

  • Search Salesforce products — searches online products and variants by query, SKU, category, and variation attributes;
  • Get Salesforce product — returns a product, variants, media, and platform-calculated prices;
  • Check Salesforce inventory — returns Salesforce-calculated availability for a product or exact variant;
  • Get Salesforce product URL — returns the public URL generated from the merchant-configured site template.

Use identifiers returned for the connected site only. When several variants are available, ask the customer to choose one before reporting availability. Prices and availability should be checked immediately before the assistant responds.

# Test the connection

  1. Ask a ChatRex test bot to find an online product from the connected site.
  2. Retrieve its product details and variants.
  3. Compare the price and currency with the target storefront.
  4. Check availability for an exact variant.
  5. Open the returned public URL and verify that it belongs to the selected site.
  6. Open the widget on the published Storefront Next site and send a test product question through it.

If the connection check fails, verify the site context, assigned content library, SLAS credentials, and the c_chatrex_catalog scope.

# Disconnect and uninstall

Disconnect Salesforce B2C Commerce in ChatRex first so the stored SLAS credentials are deleted. Remove the widget environment variable from Storefront Next, revoke or delete the dedicated SLAS client, and complete the CAP uninstall tasks. Confirm that the extension and cartridge are removed and that the widget no longer loads.