Install the Agentforce Commerce Client on Storefront Next
For Storefront Next, enable and configure Agentforce Commerce Client through a Managed Runtime environment variable, PUBLIC__app__cimulateAgent. The storefront-next template reads that variable, selects the Commerce Client provider, and injects the widget for you.
The setup is covered in B2C Shopper Agent Setup. In particular, these are the prerequisites:
- Required Licenses for the B2C Shopper Agent: Make sure your org has the required licenses provisioned for the B2C Shopper Agent.
- Enable Agentic Commerce Search for the Shopper Agent: Enable Agentic Commerce Search so that Shopper Agent can return relevant product results.
- Create a B2C Shopper Agent Using the Automated Setup: Run the automated setup to provision and configure the B2C Shopper Agent on your Salesforce org. This includes setting up the Embedded Service deployment, obtaining the org ID, SCRT2 URL, and ES developer name, which are then supplied via the configuration below.
Set the PUBLIC__app__cimulateAgent environment variable on your Managed Runtime environment, or in your local .env file for local development.
To add an environment variable in Runtime Admin:
-
Log in to the Runtime Admin (
https://runtime.commercecloud.com/). -
Select your project, then the environment.
-
Under Environment Variables, add
PUBLIC__app__cimulateAgentwith this JSON value. -
Replace fields in
PUBLIC__app__cimulateAgentwith valid values. In your Salesforce org, go to Setup > Service > Embedded Service > Embedded Service Deployments, and then open the deployment for the agent created in the automated setup (see Create a B2C Shopper Agent Using the Automated Setup. Then click Install Code Snippet. Copy these values to the JSON value forPUBLIC__app__cimulateAgent:- Replace the
esDeveloperNamevalue with the copiedDeveloperNamevalue. - Replace the
scrt2Urlvalue with the copiedUrlvalue. The SCRT2 URL is the endpoint used by the embedded chat widget to communicate with the messaging service backend. - Replace the
salesforceOrgIdvalue with the copiedOrganizationIdvalue. commerceClientScriptSourceUrlrefers to the script of the Cimulate NPM package that powers search. We recommend you use the latest version in the URL, which is currently set to/1.36.0/. Get the latest version from https://www.npmjs.com/package/@cimulate/copilot-widget.
- Replace the
The Shopper Agent is now configured for your Storefront Next storefront.
Because the widget is driven entirely by PUBLIC__app__cimulateAgent, disable it by setting "enabled": "false" or by removing the PUBLIC__app__cimulateAgent environment variable.