@humach/lca-widget
v2.3.6
Published
A React widget for Humach LCA
Readme
LCA Widget
LCA Widget is a React based self-implementing widget for Humach LCA. This package provides a reusable API.
Building and Packing
Before using the package, it will need to be built and packaged. Run the following commands:
npm run build
npm run packThis will create a tarball file that can be installed in the host application.
Installation
To install the package in the host application, run:
npm install /path/to/tarball/file.tgzUsage
Below is an example of how to use the WidgetAPI functions in the host application:
import WidgetAPI from 'lca-widget';
const { initWidget, sendMessage, closeWidget } = WidgetAPI;
// Initializing the widget with configuration options
const config = {
wsUrl: "wss://example.com/websocket", // string
wsApiKey: "12345-ABCDE", // string
jwtToken: "eyJhbGciOiJIUzI1NiIsInR5c...", // string
widgetWidth: 400, // number
widgetHeight: 600, // number
campaignID: "campaign123", // string
tenantID: "tenant456", // string
sessionID: "session789", // string
queueID: "queue101112", // string
agentID: "agent131415", // string
agentName: "John Doe", // string
channel: "voice", // string
customerANI: "+1234567890", // string
customerID: 7890 // string | number
};
initWidget(config);
// Sending an array of messages
// The array should contain all of the messages with the most recent being at the end
const messages = [{
id: "987", //string
text: "How can I help you?", //string
createdAt: new Date().toISOString(), //ISO 8601 date format
senderType: 'Agent' | 'Customer'
}];
sendMessage(messages);
//Closing the websocket connection and removing the widget from the DOM
closeWidget();