
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
@livechat/agent-app-sdk
Advanced tools
This SDK is a set of tools that will help you integrate your apps with the LiveChat Agent App.
For full documentation please head to LiveChat Docs.
The package can be installed directly from NPM.
npm install --save @livechat/agent-app-sdk
The NPM package is distributed both as a CommonJS and ES6 module. It should be used together with a module bundler, such as Webpack or Rollup.
We also distrubute a UMD build of the package, which can be used directly in the browser.
<script src="https://unpkg.com/@livechat/agent-app-sdk@1.6.3/dist/agentapp.umd.min.js"></script>
Use one of the methods exported by the SDK.
createDetailsWidget(): Promise<IDetailsWidget>Creates a widget instance to be used in the Chat Details context.
import { createDetailsWidget } from ‘@livechat/agent-app-sdk’;
createDetailsWidget().then(widget => {
// do something with the widget
});
createMessageBoxWidget(): Promise<IDetailsWidget>Creates a widget instance to be used in MessageBox.
import { createMessageBoxWidget } from ‘@livechat/agent-app-sdk’;
createMessageBoxWidget().then(widget => {
// do something with the widget
});
createFullscreenWidget(): Promise<IFullscreenWidget>Creates a widget instance to be used as a Fullscreen app.
import { createFullscreenWidget } from ‘@livechat/agent-app-sdk’;
createFullscreenWidget().then(widget => {
// do something with the widget
});
createSettingsWidget(): Promise<ISettingsWidget>Creates a widget instance to be used as a Settings app.
import { createSettingsWidget } from ‘@livechat/agent-app-sdk’;
createSettingsWidget().then(widget => {
// do something with the widget
});
IWidget)All widgets share a common interface.
on(eventName: string, eventHandler: (data: any) => void): void) - registers the event handler to be called when a given event occurs
off(eventName: string, eventHandler: (data: any) => void): void) - unregisters the previously registered handler from the event
You can use it to track the events happening in the Agent App.
import { createDetailsWidget } from ‘@livechat/agent-app-sdk’;
createDetailsWidget().then(widget => {
function onCustomerProfile(profile) {
// do something with the profile when it changes
}
// register when you need it
widget.on(‘customer_profile’, onCustomerProfile);
// ...
// unregister when you’re done
widget.off(‘customer_profile’, onCustomerProfile);
});
Each widget type offers a different set of events that you can listen to. Check them out in the descriptions below.
All widgets allow you to pass a registered charge and display a summary of it to the customer within the payment modal in the Agent App application, enabling them to complete or decline the transaction.
transaction_acceptedEmitted when a payment transaction is approved by the customer and successfully processed by the Billing API.
type TransactionEvent {
chargeId: string;
}
transaction_declinedEmitted when a payment transaction is declined by the customer (e.g., the user closes the payment modal or clicks the cancel button), and the charge is subsequently marked as declined in the Billing API.
type TransactionEvent {
chargeId: string;
}
transaction_failedEmitted when a payment transaction fails and cannot be processed by the billing API.
type TransactionError {
error: unknown;
}
update_billing_cycleThis event is triggered when a customer selects a different billing cycle for a transaction. It only emits if the showBillingCyclePicker flag is set to true in the metadata object at the start of the transaction. The event includes the new billing cycle number and key charge details, allowing you to register the updated charge with the provided information.
type UpdateBillingCycleEvent {
billingCycle: number,
chargeId: string,
paymentIntent: {
name: string,
price: number,
per_account: boolean,
test: boolean,
return_url: string | null,
months?: number,
trial_days?: number,
quantity?: number,
metadata: {
type: string,
isExternalTransaction: boolean,
showBillingCyclePicker: boolean,
icon: string,
description?: string,
}
}
}
startTransaction(charge: Charge, metadata: Metadata): Promise<void>This method allows you to pass a registered charge and accompanying metadata to the Agent App. The payment modal will then be displayed to the customer, enabling them to complete the transaction. For more information on registering a charge, refer to the Billing API documentation.
const charge = {...} // Billing API charge object
const metadata = {
icon: "https://icon.url";
description: "This is a description of the transaction.";
showBillingCyclePicker: true; // optional, use if you want to display the billing cycle picker to the customer
}
widget.startTransaction(charge, metadata);
IDetailsWidget)A type of widget that has access to the Chat Details context.
customer_profileEmitted when an agent opens a conversation within Chats, Archives, or the customer profile in the Customers sections. The handler will get the customer profile object as an argument:
interface ICustomerProfile {
id: string;
name: string;
geolocation: {
longitude?: string;
latitude?: string;
country: string;
country_code: string;
region: string;
city: string;
timezone: string;
};
email?: string;
chat: {
id?: string;
groupID: string;
preChatSurvey: { question: string; answer: string }[];
};
source: 'chats' | 'archives' | 'customers';
}
customer_details_section_button_clickEmitted when agent clicks a button located in a custom section in Customer Details. The handler gets the following payload:
interface ICustomerDetailsSectionButtonClick {
buttonId: string;
}
The buttonId property reflects the id specified for the button in the section definition.
getCustomerProfile(): ICustomerProfile | nullGets the customer profile recorded most recently. Returns the ICustomerProfile object, which is identical to the one emitted by the customer_profile event or null (if no profile was registered).
putMessage(text: string): Promise<void>Appends the text to the message box of the currently opened chat.
modifySection(section): Promise<void>With this method, you can modify any custom section declared in the widget's initial state in Developers Console. The section argument should be an object implementing the section defintion interface, for example:
const section = {
title: ‘My section’,
components: [
// …
{
type: ‘button’,
data: {
label: ‘My section button’,
id: ‘section-button’
}
}
// …
]
};
widget.modifySection(section);
The title of a given section has to match the one specified in the initial state. Otherwise, the section won't change. Also, the Agent App ignores the commands without valid section definitions. Make sure that the definition you're sending is correct.
IMessageBoxWidget)customer_profileEmitted after the widget is opened in the MessageBox. The handler will get a ICustomerProfile object (check the documentation for the customer_profile event in the Details widget to see the how the object is structured).
message_sentEmitted after the message is sent by the agent. Keep in mind that the message has to be set with [putMessage] method in order to be sent.
putMessage(msg: IRichMessage | string): Promise<void>Sets a message to be stored by MessageBox. Calling this method does not automatically send the message right away. The message is sent once an agent clicks the Send button. The message accepts the regular message type as string or rich messages. The latter must implement the IRichMessage interface.
const richMessage = {
template_id: 'cards',
elements: [
{
title: 'My cat photo',
image: 'imgs/john-the-cat.jpg'
}
]
};
widget.putMessage(richMessage);
getCustomerProfile(): ICustomerProfile | nullGets the customer profile recorded most recently. Returns the ICustomerProfile object, which is identical to the one emitted by the customer_profile event or null (if no profile was registered).
custom_id, properties and elements are optionalelements may contain 1-10 element objectselements properties are optional: title, subtitle, image, and buttonsurl on image is requiredimage properties: name, content_type, size, width, and heightbuttons may contain 1-11 button objectstemplate_id describes how the event should be presented in an appelements.buttons.postback_id describes the action sent via the send_rich_message_postback methodpostback_id; calling send_rich_message_postback with this id will add a user to all these buttons at once.elements.buttons.user_ids describes users who sent the postback with "toggled": trueIFullscreenWidget)page_dataEmitted when widget in initialized. The handler will get the main window page data object as an argument:
interface IPageData {
queryParams: object;
}
setNotificationBadge(count: number | null): Promise<void>Displays a red badge on top of the Fullscreen app icon. Use this to notify Agents there’s something important inside the widget. Make sure Agents can dismiss the notification to avoid cluttered UI.
navigate(pathname: string): Promise<void>Navigates LiveChat Agent App to given pathname.
setReportsFilters(filters: ReportsFilters): Promise<void>Updates "Reports" section filters to given filters object.
getPageData(): IPageData | nullGets the main window page data recorded most recently. Returns the IPageData object, which is identical to the one emitted by the page_data event or null (if no data were registered).
ISettingsWidget)page_dataEmitted when widget in initialized. The handler will get the main window page data object as an argument:
interface IPageData {
queryParams: object;
}
getPageData(): IPageData | nullGets the main window page data recorded most recently. Returns the IPageData object, which is identical to the one emitted by the page_data event or null (if no data were registered).
redirect(target: string): Promise<void>Redirects using the main window. Calling this method will send postmessage to Agent App, witch will be handled there. After that, redirect using window object is performed.
const target = 'https://example.com';
widget.redirect(target);
Pull requests are welcome. For major changes, please open an issue first, so we can discuss what you would like to change. Follow a Contributing guide for more details.
The code and documentation in this project are released under the MIT License.
FAQs
SDK for extending LiveChat's Agent App
The npm package @livechat/agent-app-sdk receives a total of 234 weekly downloads. As such, @livechat/agent-app-sdk popularity was classified as not popular.
We found that @livechat/agent-app-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 70 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.