Skip to content

Commit 445b282

Browse files
@W-18895609: 🚀 Shopper Agent Experience v3.0 (#2658)
* feat: shopper agent experience v3.0 * fix: enabling streaming (#2911)
1 parent 4a9f448 commit 445b282

File tree

23 files changed

+2540
-554
lines changed

23 files changed

+2540
-554
lines changed

packages/pwa-kit-create-app/assets/bootstrap/js/config/default.js.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66
*/
77
/* eslint-disable @typescript-eslint/no-var-requires */
88
const sites = require('./sites.js')
9+
const {parseCommerceAgentSettings} = require('./utils.js')
10+
911
module.exports = {
1012
app: {
13+
// Commerce shopping agent configuration for embedded messaging service
14+
// This enables an agentic shopping experience in the application
15+
// This property accepts either a JSON string or a plain JavaScript object.
16+
// The value is set from the COMMERCE_AGENT_SETTINGS environment variable.
17+
// If the COMMERCE_AGENT_SETTINGS environment variable is not set, the feature is disabled.
18+
commerceAgent: parseCommerceAgentSettings(process.env.COMMERCE_AGENT_SETTINGS),
1119
// Customize how your 'site' and 'locale' are displayed in the url.
1220
url: {
1321
{{#if answers.project.demo.enableDemoSettings}}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2021, salesforce.com, inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
/**
9+
* Safely parses commerce agent settings from either a JSON string or object
10+
* @param {string|object} settings - The commerce agent settings
11+
* @returns {object} Parsed commerce agent settings object
12+
*/
13+
function parseCommerceAgentSettings(settings) {
14+
// Default configuration when no settings are provided
15+
const defaultConfig = {
16+
enabled: 'false',
17+
askAgentOnSearch: 'false',
18+
embeddedServiceName: '',
19+
embeddedServiceEndpoint: '',
20+
scriptSourceUrl: '',
21+
scrt2Url: '',
22+
salesforceOrgId: '',
23+
commerceOrgId: '',
24+
siteId: ''
25+
}
26+
27+
// If settings is already an object, return it
28+
if (typeof settings === 'object' && settings !== null) {
29+
return settings
30+
}
31+
32+
// If settings is a string, try to parse it
33+
if (typeof settings === 'string') {
34+
try {
35+
return JSON.parse(settings)
36+
} catch (error) {
37+
console.warn('Invalid COMMERCE_AGENT_SETTINGS format, using defaults:', error.message)
38+
return defaultConfig
39+
}
40+
}
41+
42+
// If settings is undefined/null, return defaults
43+
return defaultConfig
44+
}
45+
46+
module.exports = {
47+
parseCommerceAgentSettings
48+
}

packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/ssr.js.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ const {handler} = runtime.createHandler(options, (app) => {
301301
'api.cquotient.com',
302302
'*.c360a.salesforce.com'
303303
]
304+
},
305+
referrerPolicy: {
306+
policy: 'strict-origin-when-cross-origin'
304307
}
305308
}
306309
})

packages/pwa-kit-create-app/assets/templates/@salesforce/retail-react-app/app/ssr.js.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ const {handler} = runtime.createHandler(options, (app) => {
300300
'api.cquotient.com',
301301
'*.c360a.salesforce.com'
302302
]
303+
},
304+
referrerPolicy: {
305+
policy: 'strict-origin-when-cross-origin'
303306
}
304307
}
305308
})

packages/pwa-kit-create-app/assets/templates/@salesforce/retail-react-app/config/default.js.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66
*/
77
/* eslint-disable @typescript-eslint/no-var-requires */
88
const sites = require('./sites.js')
9+
const {parseCommerceAgentSettings} = require('./utils.js')
10+
911
module.exports = {
1012
app: {
13+
// Commerce shopping agent configuration for embedded messaging service
14+
// This enables an agentic shopping experience in the application
15+
// This property accepts either a JSON string or a plain JavaScript object.
16+
// The value is set from the COMMERCE_AGENT_SETTINGS environment variable.
17+
// If the COMMERCE_AGENT_SETTINGS environment variable is not set, the feature is disabled.
18+
commerceAgent: parseCommerceAgentSettings(process.env.COMMERCE_AGENT_SETTINGS),
1119
// Customize settings for your url
1220
url: {
1321
{{#if answers.project.demo.enableDemoSettings}}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2021, salesforce.com, inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
/**
9+
* Safely parses commerce agent settings from either a JSON string or object
10+
* @param {string|object} settings - The commerce agent settings
11+
* @returns {object} Parsed commerce agent settings object
12+
*/
13+
function parseCommerceAgentSettings(settings) {
14+
// Default configuration when no settings are provided
15+
const defaultConfig = {
16+
enabled: 'false',
17+
askAgentOnSearch: 'false',
18+
embeddedServiceName: '',
19+
embeddedServiceEndpoint: '',
20+
scriptSourceUrl: '',
21+
scrt2Url: '',
22+
salesforceOrgId: '',
23+
commerceOrgId: '',
24+
siteId: ''
25+
}
26+
27+
// If settings is already an object, return it
28+
if (typeof settings === 'object' && settings !== null) {
29+
return settings
30+
}
31+
32+
// If settings is a string, try to parse it
33+
if (typeof settings === 'string') {
34+
try {
35+
return JSON.parse(settings)
36+
} catch (error) {
37+
console.warn('Invalid COMMERCE_AGENT_SETTINGS format, using defaults:', error.message)
38+
return defaultConfig
39+
}
40+
}
41+
42+
// If settings is undefined/null, return defaults
43+
return defaultConfig
44+
}
45+
46+
module.exports = {
47+
parseCommerceAgentSettings
48+
}

packages/pwa-kit-runtime/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
## v3.12.0-dev (Jul 22, 2025)
1+
## v3.12.0-dev (Jul 28, 2025)
2+
- This feature introduces an AI-powered shopping assistant that integrates Salesforce Embedded Messaging Service with PWA Kit applications. The shopper agent provides real-time chat support, search assistance, and personalized shopping guidance directly within the e-commerce experience. [#2658](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2658)
3+
24
## v3.11.0 (Jul 22, 2025)
35
- Fix the logger so that it will now print out details of the given Error object [#2486](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2486)
46
- Only allow requests for `/shopper/auth/` through the SLAS private client proxy. Also stop the proxy from swallowing SLAS errors [#2608](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2608)

0 commit comments

Comments
 (0)