Vue Storefront is now Alokai! Learn More
Assisted Service Module

Assisted Service Module

If Assisted Service Module is enabled on your SAP Commerce Cloud instance, you can configure the Alokai SAPCC integration to make use of it.

This feature is currently not available in the Unified Data Layer.

SAP pre-requisites

Extensions

Please ensure that your SAP instance has Assisted Service Module enabled - this entails enabling the correct extensions. The "CX" template from the SAP Commerce Cloud Sample Repository contains sample configuration that includes Assisted Service Module, among other things.

Additionally, you'll need a valid support agent employee account to use log in and use ASM features with. Otherwise, you'll be met with 403 Unauthorized errors when calling the methods.

Employees, customers

To make sure that your instance configuration and customer support agent employee account is valid, see if:

  1. you have a customer list configured - you can find ImpEx scripts that create a sample list here
  2. the customer support agent employee is a member of:
    1. customermanagergroup - to allow searching customers to emulate
    2. asagentgroup - for emulation and viewing customer lists. If this group doesn't exist for you, you can create it yourself with exactly asagentgroup as the name.
    3. A store group (e.g. nakanostoreemployees) - this allows for creating a customer list which will show customers assigned to the same location as the customer support agent employee. Assigning to physical stores is also described in the SAP documentation linked in point 1.

Feature flags

Some ASM features are disabled by default depending on your SAP Commerce Cloud version. If you need the features described below and your SAP CC version is lower than 2211.16, please make sure to explicitly enable their associated feature flags as described below. This can be done by adding a new key in the core-customize/manifest.json file's properties property in your SAP Cloud Portal configuration Git repository.

Please see:

// core-customize/manifest.json
 {
   ...,
   "properties": [
+    {
+      "key": "toggle.customer360.enabled",
+      "value": "true"
+    },
+    {
+      "key": "toggle.customerList.enabled",
+      "value": "true"
+    },
+    {
+      "key": "assistedservicewebservices.api.restrictions.disabled.endpoints",
+      "value": ""
+    },
     ...
   ],
    ...,
 }

Configuration

To configure middleware to work with ASM, provide the base URL of the assistedserviceswebservices extension in middleware.config.js.

  1. Add a new environment variable for holding the ASM URI in your .env file:
 ...
 SAPCC_API_URI=...
 # This is an example URI, replace it with the URI to your SAP CC's instance
+SAPCC_ASM_API_URI=https://api.abcdf-123replacewithyourenvironment-d1-public.model-t.cc.commerce.ondemand.com/assistedservicewebservices
  1. Use the new environment variable in middleware.config.js:
 // middleware.config.js
 
 require('dotenv').config();
 
 module.exports = {
   integrations: {
     sapcc: {
       location: '@vsf-enterprise/sapcc-api/server',
       configuration: {
         OAuth: {
           uri: process.env.SAPCC_OAUTH_URI,
           clientId: process.env.SAPCC_OAUTH_CLIENT_ID,
           clientSecret: process.env.SAPCC_OAUTH_CLIENT_SECRET,
           tokenEndpoint: process.env.SAPCC_OAUTH_TOKEN_ENDPOINT,
           tokenRevokeEndpoint: process.env.SAPCC_OAUTH_TOKEN_REVOKE_ENDPOINT,
           cookieOptions: {
             'vsf-sap-token': { secure: process.env.NODE_ENV !== 'development' }
           }
         },
         api: {
           uri: process.env.SAPCC_API_URI,
+          asmUri: process.env.SAPCC_ASM_API_URI,
           baseSiteId: process.env.DEFAULT_BASE_SITE_ID,
           catalogId: process.env.DEFAULT_CATALOG_ID,
           catalogVersion: process.env.DEFAULT_CATALOG_VERSION,
           defaultLanguage: process.env.DEFAULT_LANGUAGE,
           defaultCurrency: process.env.DEFAULT_CURRENCY
         }
       }
     }
   }
 };

Emulating a customer

In the context where we're not using ASM, the methods execute the action (e.g. create cart) for the account connected token that is passed in the vsf-sap-token cookie. In other words, the value current will be passed to the userId parameter of the SAP CC methods.

In the case of Assisted Service Module, the mechanism of action is different. The token of the Customer Support Agent employee has the permission to execute actions (e.g. create carts) not only in their own name (e.g. employee customer.support@nakano.com), but also in the name of regular customers. So the token of the Customer Support agent employee is sent with e.g. the request createCart, but the userId parameter of the SAP CC method is set to a customer's e-mail (e.g. akiro.nakamura@pronto-hw.com) instead of current. The end result is that the customer.support@nakano.com account has no cart, and the akiro.nakamura@pronto-hw.com account has a cart.

Emulating a customer in the SDK

SDK methods that support passing userId in SAP CC will also have an optional userId property, that allows running the method in the name of another customer.

await sdk.sapcc.signUserIn({ username: 'customer.support@nakano.com', password: 'hunter2'});
await sdk.sapcc.getOrgUser({ userId: "e7bb713a-50d1-4e20-9347-e48e0ccdd001" }); // UUID of SAP customer's account, e.g. `akiro.nakamura@pronto-hw.com`

Please make sure to always pass the userId prop if the intention is to emulate a customer. If you forget to pass it, the method will be called in the name of the customer support agent employee.

await sdk.sapcc.signUserIn({ username: 'customer.support@nakano.com', password: 'hunter2'});
await sdk.sapcc.getOrgUser(); // WRONG! Did you forget to pass `userId`?