SDK requires a JSON Web Token (JWT) to initialize and connect to Avaya Experience Platform™ Digital services. A unique token must be used for each end user (your customers using the chat client). Since your backend web application is aware of the user using your services, it should securely fetch the token from Avaya Experience Platform™ Digital for the user whenever your web page requires it.
This reference application is a simple Express JS web server which illustrates the flow of procuring a unique JWT token for an end user.
⚠ WARNING
This application is provided as a sample for the purpose of reference only and shouldn't be used in production. Existing production provisioning may impact to Sample Code’s expected working.
The Sample Token Server requires Node JS version v20.9.0 LTS
or above.
-
Run
npm install
-
Make appropriate configuration changes in the file
src/configuration.js
.
Once the configuration changes are done, to start server run npm start
.
For starting server in HTTP mode, make the ssl
flag false in the src/configuration.js
file, in the server
related configuration section.
For starting server in HTTPS mode, make the ssl
flag true in the src/configuration.js
file, in the server
related configuration section.
For HTTPS mode, make sure that the certificatePath
and privateKeyPath
configurations points to the location of SSL certificate and its private key, and the passPhrase
is the correct pass phrase which was used to create the private key. These configurations are also present in the server
related configuration section in the config file.
The server starts listening to HTTP requests (by default on port 3000). To fetch JWT, use the following URL: http://:<server.port>/token
To see all the internal debug logs of the Express JS please start the server with the following command - npm run start:debug
.
Note: If you are running the Sample Token Server on Windows, please start the server with this command instead - npm run start:debug-windows
.
All configurations are present in the src/configuration.js
file.
These are the configurations related to the Sample Token Server. Following are the configuration options.
port
: The port on which the Sample Token Server server will listen for incoming HTTP requests. Default value is3000
.allowedOrigins
: An Array of origins allowed by this server. This is required for CORS. Typically the URL of the website hosting the chat widget. For example["http://www.example.com"]
. Use["*"]
for allowing all origins. Default value is["*"]
.ssl
: Controls whether the server is started in HTTPS mode or normal HTTP mode. Value should betrue
to start this server in HTTPS mode.false
for starting in HTTP mode. Default value isfalse
.sslCertificatePath
: Path to the SSL certificate required for HTTPS. Required ifserver.ssl
is true. Default value is""
(empty string).sslPrivateKeyPath
: Path to the private key required for decrypting SSL certificate. Required ifserver.ssl
is true. Default value is""
(empty string).sslPassPhrase
: Passphrase required for required for decrypting SSL certificate. Required ifserver.ssl
is true. Default value is""
(empty string).
These are AXP account related configurations required to access the AXP APIs. Following are the configuration options.
hostName
: Host region specific to AXP. For example -na.api.avayacloud.com
for North America region.accountId
: The unique 6 character AXP customer account ID.integrationId
: The 36 character integration ID that your app will connect through. This is obtained from your account administrator when setting up an AXP SDK integration.clientId
: Client ID used to obtain an access token that will be used by the client to authenticate with AXP APIs.clientSecret
: Secret for the above Client ID (axp.clientId
).appKey
: The application key used to authenticate your application with AXP. This key is received along with your client ID and client secret when registering an application with AXP. This must be included in theappkey
HTTP header for all AXP requests.jwtValidityInterval
: Time to live for the JWT token to be used by the client, in minutes. Must be between 15 and 60 minutes. Default value is30
. Once this token expires the client application will need to request a new token to continue using the AXP Omni SDK.callingRemoteAddress
: The remote address (typically a phone number) used for placing voice calls to your contact center. This field is only used by the SDK's calling module.fcmConnectorBaseUrl
: Base URL of the Sample Firebase Cloud Messaging connector used by the mobile messaging demo application. This is used to register the device's push token to be able to receive push notifications from Firebase.configId
: The AXP Push notification configuration ID used to receive messaging push notifications. This ID is obtained from your account administrator when setting up an AXP SDK Push Notification Configuration.