cc-digital-interactions
v3.0.6-beta.1
Published
This package provides a React component for Webex Engage conversations and a helper to initialize API/auth configuration.
Readme
cc-digital-interactions — Consumer Guide
This package provides a React component for Webex Engage conversations and a helper to initialize API/auth configuration.
- Default export:
Engage(React component) - Named export:
initializeApp(dataCenter, jwtToken)
Use:
import Engage, { initializeApp } from "cc-digital-interactions";Install
Install the package and its peer dependencies.
npm install cc-digital-interactions react react-dom @momentum-ui/web-components
# or
yarn add cc-digital-interactions react react-dom @momentum-ui/web-components
# or
pnpm add cc-digital-interactions react react-dom @momentum-ui/web-componentsThen register Momentum UI Web Components once in your app (usually at the root):
// e.g., src/main.tsx or src/index.tsx
import "@momentum-ui/web-components";Quick Start (React)
import React, { useEffect } from "react";
import ReactDOM from "react-dom/client";
import Engage, { initializeApp } from "cc-digital-interactions";
function ConversationsView() {
useEffect(() => {
// 1) Initialize API endpoints + fetch access token using a short-lived JWT
// Call this once (e.g., on app start or when JWT rotates)
initializeApp("qa", "<JWT_FROM_YOUR_BACKEND>");
}, []);
return (
<Engage
conversationId="<CONVERSATION_ID>"
interactionId="<INTERACTION_ID_OR_EMPTY>"
readonly={false}
theme="LIGHT" // LIGHT | DARK
isVisualRebrand={true} // optional UI style
dataCenter="qa" // must match initializeApp's dataCenter
/>
);
}
ReactDOM.createRoot(document.getElementById("root")!).render(
<ConversationsView />,
);API
initializeApp(dataCenter: string, jwtToken: string): Promise<void>- Sets the REST base URL and retrieves/stores an access token using your short-lived
jwtToken. - Call before rendering
Engageand whenever your JWT rotates.
- Sets the REST base URL and retrieves/stores an access token using your short-lived
Engagecomponent props:conversationId: string— Target conversation ID (or useinteractionId).interactionId: string— Optional interaction ID if available.readonly: boolean— Whentrue, disables authoring actions.theme?: "LIGHT" | "DARK"— Visual theme; defaults toLIGHT.isVisualRebrand?: boolean— Enables the newer visual look and feel.dataCenter?: string— Selects the SignalR endpoint region; should match the value passed toinitializeApp.
Supported dataCenter values
Use one of the following keys for both initializeApp(dataCenter, ...) and the Engage prop dataCenter:
intgus1qaprodanz1prodca1prodeu1prodeu2prodsg1produs1
These map internally to REST and SignalR endpoints (see source config in src/app/apiConfig.ts).
Auth Model
- Your backend issues a short-lived JWT per agent/session.
- Call
initializeApp(dataCenter, jwtToken)with that JWT to exchange for an access token used by the SDK. - Tokens and agent info are stored in session storage; the SDK refreshes as needed.
Notes & Troubleshooting
- Make sure
@momentum-ui/web-componentsis imported once at app startup; otherwise some UI elements may not render. - Always call
initializeAppbefore first renderingEngage, and again if your JWT rotates or expires. - Provide either a valid
conversationIdorinteractionId. - Ensure
dataCenteris consistent betweeninitializeAppand theEngagecomponent to establish SignalR connections correctly.
TypeScript
This package ships with type definitions. Props for Engage are derived from the component’s TypeScript source in src/app/App.tsx.
For advanced usage (events, storage, or lower-level APIs), refer to the source modules within src/ in this repository.
