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
.nvmrc
files - Valid
configurationId
created 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 (
buildUrl
method) 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 use
or use node version specified in.nvmrc
- Verify and adjust
.npmrc
file- if you use private npm registry (e.g. Verdaccio, GitHub Packages etc.) as a proxy for
@spartacus
and to host your own packages then just set environment variables to your proxy URL and auth token - otherwise replace
@spartacus:registry
with URL and credentials that you use in your spartacus app (e.g. RBSC) and optionally add@cx-spartacus:registry
to 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 install
inside projects/cxai-assistant/, only in workspace root
- never run
npm run build
If you own a private npm repository:
- Update
@cx-spartacus:registry
in.npmrc
to point to your private repository - Run
build.sh
script - 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:
cd
intodist/cxai-assistant
afternpm run build
- Run
npm pack
- this will produce a.tgz
file - Copy the
.tgz
into 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 link
indist/cxai-assistant
folder (afternpm run build
) - Run
npm link @cx-spartacus/cxai-assistant
in your applicationYou need to have
"preserveSymlinks": true,
in app'sangular.json
projects/<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 link
is temporary and will be removed after eachnpm install
in 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
CxaiAssistantFeatureModule
from@cx-spartacus/cxai-assistant/feature
intoapp.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.