Spartacus library to use CXII Assistant and Ask Product API.
CXAI Assistant library for use with CXAI assistant API CXAI Ask Product library for use with CXAI Ask Product API
- Node version specified in
.nvmrcfiles - Valid
configurationIdcreated by Assistant API. You can pass it viaprovideConfig, or expose backend endpoint that returns it, or use provided sample backend extensions. See section in Backend README. - Library depends on backend which allows access to part of API without authorization. Library assumes API is served via OCC, you need to modify code (
buildUrlmethod) to allow arbitrary URL. Sample backend extension is provided: Backend README
The following instructions are for assistant library. For ask-product you can follow exactly the same steps, just change assistant to ask-product.
- cd into workspace
cxai-assistant-angular-lib nvm useor use node version specified in.nvmrc- Verify and adjust
.npmrcfile- if you use private npm registry (e.g. Verdaccio, GitHub Packages etc.) as a proxy for
@spartacusand to host your own packages then just set environment variables to your proxy URL and auth token - otherwise replace
@spartacus:registrywith URL and credentials that you use in your spartacus app (e.g. RBSC) and optionally add@cx-spartacus:registryto be able tonpm publish
- if you use private npm registry (e.g. Verdaccio, GitHub Packages etc.) as a proxy for
npm i- never run
npm installinside projects/cxai-assistant/, only in workspace root
- never run
npm run build
If you own a private npm repository:
- Update
@cx-spartacus:registryin.npmrcto point to your private repository - Run
build.shscript - Add library to your application's
package.json, e.g."@cx-spartacus/cxai-assistant": "~2211.43.0"
If you don't own a private npm repository:
cdintodist/cxai-assistantafternpm run build- Run
npm pack- this will produce a.tgzfile - Copy the
.tgzinto your application's codebase, e.g. intolib/cx-spartacus-cxai-assistant-<version>.tgz - Add library to your application's
package.json, e.g."@cx-spartacus/cxai-assistant": "file:lib/cx-spartacus-cxai-assistant-<version>.tgz"
If you want to run the library in watch mode:
- Run
npm linkindist/cxai-assistantfolder (afternpm run build) - Run
npm link @cx-spartacus/cxai-assistantin your applicationYou need to have
"preserveSymlinks": true,in app'sangular.jsonprojects/<project_name>/architect/build/options - Run the library using
npm run watch - Run your app
ng s - When you modify library code, the application will reload automatically
npm linkis temporary and will be removed after eachnpm installin your application
After you've successfully added library as a dependency in your application's package.json, and either run npm install or npm link you can now use it.
- Add import
CxaiAssistantFeatureModulefrom@cx-spartacus/cxai-assistant/featureintoapp.module - Build your application - it must build without errors.
Next follow Assistant README for instructions about backend, configuration options and how to add the cms component.
For ask product library, do the same steps in cxai-ask-product-angular-lib workspace and follow Ask Product README
This implementation assumes one chat config per site. Currently backend configs do not take into account language parameter, also language is not passed when opening a new session. To support welcome message in different languages it is required to use translations - see lib.i18n.ts for translation keys.
Create an issue in this repository if you find a bug or have questions about the content.
For additional support, ask a question in SAP Community.
If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses the standard DCO text of the Linux Foundation.
Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.