Skip to content

Omnichannel Live Chat Widget UI Components offers a re-usable component-based library to help create a custom chat widget that can be connected to the Dynamics 365 Customer Service experience.

License

Notifications You must be signed in to change notification settings

microsoft/omnichannel-chat-widget

Repository files navigation

Omnichannel Live Chat Widget UI Components

Release CI npm version npm
Release CI npm version npm

@microsoft/omnichannel-chat-widget is a React-based UI component library which allows you to build your own live chat widget experience using @microsoft/omnichannel-chat-sdk.

NEW! Check out our new Developer Guide, which has detailed explanations of all component interfaces accompanied with sample code.

NEW! Veresion 1.2.0 introduces draggable widget, allowing the widget panel to move anywhere in the browser window. Set draggableChatWidgetProps.disabled to true to disable this behavior. See interface.

Table of Contents

  1. Introduction
  2. Installation
  3. Example Usage
  4. Components
  5. See Also

Introduction

Omnichannel Live Chat Widget UI Components offers a re-usable component-based library to help create a custom chat widget that can be connected to the Dynamics 365 Customer Service experience.

For more information about Live Chat Widget, see here.

Releases

New releases are published on a regular basis to ensure the product quality.

Chat Widget

Version Docs Release Date End of Support Deprecated
1.5.0 Release Notes 2023-11-21 2024-11-21
1.4.0 Release Notes 2023-10-25 2024-10-25
1.3.0 Release Notes 2023-09-18 2024-09-18
1.2.3 Release Notes 2023-09-07 2024-09-07
1.2.2 Release Notes 2023-08-16 2024-08-16
1.2.1 Release Notes 2023-07-24 2024-07-24
1.2.0 Release Notes 2023-07-20 2024-07-20
1.1.0 Release Notes 2023-06-08 2024-06-08
1.0.5 Release Notes 2023-05-26 2024-05-26
1.0.4 Release Notes 2023-05-08 2024-05-08
1.0.3 Release Notes 2023-04-24 2024-04-24
1.0.2 Release Notes 2023-04-06 2024-04-06
1.0.1 Release Notes 2023-03-23 2024-03-23
1.0.0 Release Notes 2023-03-22 2024-03-22

Chat Components

Version Docs Release Date End of Support Deprecated
1.1.0 Release Notes 2023-12-12 2024-12-12
1.0.9 Release Notes 2023-12-07 2024-12-07
1.0.8 Release Notes 2023-10-31 2024-10-31
1.0.7 Release Notes 2023-09-13 2024-09-13
1.0.6 Release Notes 2023-08-18 2024-08-18
1.0.5 Release Notes 2023-07-20 2024-07-20
1.0.4 Release Notes 2023-06-20 2024-06-20
1.0.3 Release Notes 2023-06-08 2024-06-08
1.0.2 Release Notes 2023-06-06 2024-06-06
1.0.1 Release Notes 2023-04-04 2024-04-04
1.0.0 Release Notes 2023-03-15 2024-03-15

Installation

npm i @microsoft/omnichannel-chat-sdk
npm i @microsoft/omnichannel-chat-widget

or

yarn add @microsoft/omnichannel-chat-sdk
yarn add @microsoft/omnichannel-chat-widget

The repo also contains the @microsoft/omnichannel-chat-components package, which is a collection of UI components. The @microsoft/omnichannel-chat-widget package is an integration of the Chat SDK and the UI components. To install the UI components separately, do

npm i @microsoft/omnichannel-chat-components

or

yarn add @microsoft/omnichannel-chat-components

Example Usage

The basic example below takes in the <LiveChatWidget/> component along with the Chat SDK to create a customized Omnichannel chat widget.

⚠️ The Chat SDK has to be initialized before being passed in.

import * as React from "react";

import { LiveChatWidget } from "@microsoft/omnichannel-chat-widget";
import { OmnichannelChatSDK } from "@microsoft/omnichannel-chat-sdk";
import ReactDOM from "react-dom";
//Below version numbers will help us to troubleshoot issues with specific package
import { version as chatSdkVersion } from "@microsoft/omnichannel-chat-sdk/package.json";
import { version as chatWidgetVersion } from "@microsoft/omnichannel-chat-widget/package.json";
import { version as chatComponentVersion } from "@microsoft/omnichannel-chat-components/package.json";

const render = async () => {
    const omnichannelConfig = {
        orgId: "00000000-0000-0000-0000-000000000000", // dummy config
        orgUrl: "https://www.org-url.com", // dummy config
        widgetId: "00000000-0000-0000-0000-000000000000" // dummy config
    };
    const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
    await chatSDK.initialize(); // mandatory
    const chatConfig = await chatSDK.getLiveChatConfig();
    const liveChatWidgetProps = {
        styleProps: {
            generalStyles: {
                width: "700px",
                height: "800px"
            }
        },
        headerProps: {
            controlProps: {
                hideMinimizeButton: true
            }
        },
        chatSDK: chatSDK, // mandatory
        chatConfig: chatConfig // mandatory
    };

    ReactDOM.render(
        <LiveChatWidget {...liveChatWidgetProps}/>,
        document.getElementById("my-container")
    );
};

render();

A javascript sample widget can be found in this repo here. To build it, do yarn build-sample or yarn build-sample:dev from chat-widget project root.

A typescript sample widget can be found here. To build it, do yarn install then yarn build then yarn start from typescript sample project root. See Create LiveChatWidget with Webpack5 and TypeScript for additional typescript sample project resources.

Components

For a detailed guide on how to customize each component with sample usages, please see our new Developer Guide.

Stateless UI Components

These are components that are included in the @microsoft/omnichannel-chat-components package.

Component Usage Interface
CallingContainerPane The container for voice and video feature in the chat widget ICallingContainerProps
ChatButton The button that appears on the user's portal that is designed to be the entry point for the user to initate chat IChatButtonProps
CommandButton A customizable button component that can be injected to the header and/or footer ICommandButtonProps
ConfirmationPane The default pane used when the Header close button is launched IConfirmationPaneProps
Footer The bottom container of the chat containing the download transcript, notification sound and email transcript buttons by default. IFooterProps
Header The top container of the chat containing the default minimize, close and title of the chat widget IHeaderProps
InputValidationPane A pop-up input pane with validation. In the default widget this is used as part of EmailTranscriptPane IInputValidationPaneProps
LoadingPane The default pane used after the chat button is clicked and before the chat loads completely ILoadingPaneProps
OutOfOfficeHoursPane The pane that is displayed when the chat is outside of operating hours set on admin side IOOOHPaneProps
PostChatSurveyPane The pane that holds the Customer Voice survey which would be used by the customer to input their chat experience, provide user ratings etc. It uses an IFrame to render the survey URL fetched from getPostChatSurveyContext call from OmniChannel ChatSDK. IPostChatSurveyPaneProps
PreChatSurveyPane The pane that holds the form which would be used by the customer to input helpful information for using the Support Chat before starting up the Chat Process. Makes use of AdaptiveCards IPreChatSurveyPaneProps
ProactiveChatSurveyPane A pane that holds more information than a normal chat button and can be configured to proactively pop up IProactiveChatPaneProps
ReconnectChatPane The pane that shows up when the customer is re-connecting to the chat to add additional conversation IReconnectChatPaneProps

⚠️ Because the components extend Microsoft's Fluent UI components, the base interface for all the styleProps in the above table is IStyle, which extends the IRawStyleBase interface, which is the most useful reference.

Stateful Components

Component Default Usage Interface
WebChatContainer The default wrapper around BotFramework's WebChat, which is the message container we are using IWebChatContainerStatefulProps
LiveChatWidget The default widget that stitches the UI components with Chat SDK ILiveChatWidgetProps
PostChatLoadingPane The default loading pane used after the chat is ended and before the post chat pane loads completely ILoadingPaneProps

Some of the interfaces listed in the Stateless table have Stateful counterparts defined in the @microsoft/omnichannel-chat-widget package. For example, IConfirmationPaneStatefulProps extends IConfirmationPaneProps with additional attributes that only makes sense in the stateful context.

Custom Components

There are two ways to custom the components provided in the library - 1) Replacing components using ComponentOverrides, and 2) Adding custom components in header and footer.

ComponentOverrides

Most sub-components and the default panes provided can be overriden. Components have "componentOverrides" as part of props interface, which consists of ReactNodes or strings for each part of the component. For example, the "ProactiveChatPane" component has a close button, and the close button can be overriden by creating a custom react node and setting it to the "closeButton" attribute of "componentOverrides" interface that is part of the props.

const customButton = (
    <button style={{
        background: "green",
        height: "80px",
        margin: "30px 15px 0 0",
        padding: "10px",
        width: "160px"
    }}>
        This is a custom button
    </button>
);

const liveChatWidgetProps = {
    proactiveChatPaneProps: {
        componentOverrides: {
            closeButton: customButton
        };
    };
}

Custom Components in Header and Footer

Header's and Footer's child components consist of three parts:

  1. "leftGroup" - adding child components at the left of the Header/Footer
  2. "middleGroup" - adding child components in the middle of the Header/Footer
  3. "rightGroup" - adding child components at the right of the Header/Footer

By default Header has the header icon and title on the left and minimize and close buttons on the right, and Footer has Download Transcript and Email Transcript buttons on the left and audio notification button on the right. These components can be overriden with ComponentOverrides. In addition, other custom child components can be added to both Header and Footer by creating custom react nodes and adding them to attributes "leftGroup", "middleGroup" or "rightGroup" of "controlProps".

const buttonStyleProps: IButtonStyles = {
    root: {
        color: "blue",
        height: 25,
        width: 25,
    }
};

const calendarIcon: IIconProps = { iconName: "Calendar" };
const calendarIconButton = <IconButton
    key="calendarIconButton"
    iconProps={calendarIcon}
    styles={buttonStyleProps}
    title="Calendar">
</IconButton>;

const emojiIcon: IIconProps = { iconName: "Emoji2" };
const emojiIconButton = <IconButton
    key="emojiIconButton"
    iconProps={emojiIcon}
    styles={buttonStyleProps}
    title="Sentiment">
</IconButton>;

const uploadIcon: IIconProps = { iconName: "Upload" };
const uploadIconButton = <IconButton
    key="uploadIconButton"
    iconProps={uploadIcon}
    styles={buttonStyleProps}
    title="Upload">
</IconButton>;

const customizedFooterProp: IFooterProps = {
    controlProps: {
        leftGroup: { children: [uploadIconButton] },
        middleGroup: { children: [calendarIconButton] },
        rightGroup: { children: [emojiIconButton] }
    }
};

📌 Note that WebChat hooks can also be used in any custom components.

See Also

Customizations Dev Guide
Telemetry
Create LiveChatWidget with Webpack5 and TypeScript
Omnichannel Features
How to Add Visual Regression Tests
Security
Third Party Cookie Support
Storybook

About

Omnichannel Live Chat Widget UI Components offers a re-usable component-based library to help create a custom chat widget that can be connected to the Dynamics 365 Customer Service experience.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published