npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@intility/flex-chat

v1.3.11

Published

Wrapped component with basic setup and theming based on Twilios WebChat Component

Downloads

13

Readme

Intility Chat

Build and deploy package to NPM

Intility Chat is a React Component that wraps Twilio's WebChat UI with basic configuration and theme.

Purpose

Intility Chat makes it easy for third parties to implement a customized version of Flex WebChat UI that is tailored to fit our design guidelines and then deliver an consistent user experience to the end user.

Intended consumers

This component is intended for customer facing web portals that isn't developed by Intility, but we use in production.

Main technologies

This project utilizes among others the following libraries:

Getting Started

Installation

NPM

npm i @intility/flex-chat

Required Configuration

Environment variables

NOTE: If you haven't got these keys, please contact your provided Intility Contact.

REACT_APP_ACCOUNT_SID=xxxxx
REACT_APP_FLOW_SID=xxxxx

Properties

type ConfigProps = {
    flexFlowSid: string;
    flexAccountSid: string;
    user: ChatContext; // User context
    loglevel?: 'debug' | 'superDebug';
    closeOnInit?: boolean;
    theme?: ThemeConfig;
    preEngagementFormMessage?: MultiLangText;
    user: ChatContext;
};

type FlexChatProps = {
    config: ConfigProps;
    isDarkMode: boolean;
    isDisabled?: boolean;
};

NOTE: The properties marked with ? is optional.

Authentication

Since this package initializes an chat session with an Intility Support Agent there is a requirement to provide a authenticated users details in the config object.

NOTE: This components does not give other requirements to authentication implementations but to provide the components with these values.

type AllowedValues = string | number | boolean | undefined | null | string[] | number[] | boolean[] | object;

type ChatContext = { 
    // Value to be displayed as the sender in the chat. 
    // This should be the authenitcated users full name if available, but fallback to the users login EMail.
    userPrincipalName: string;
    
    // The email used for login for the user
    mail: string;
    
    // Telephone number for the user
    mobilePhone: string;
    
    // The preferred language for the user. Should follow ISO 639-1 Code
    preferredLanguage: string;
    
    // Other user context is welcome and can be sent as other optional properties.
    [key: string]: AllowedValues;
};

Example Configuration

import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import { FlexChat, ConfigProps } from '@intility/flex-chat/dist/index';

const App: React.FC = (props) => {
    const [isDarkMode, setIsDarkMode] = useState(false);

    const config: ConfigProps = {
        flexAccountSid: process.env.REACT_APP_ACCOUNT_SID,
        flexFlowSid: process.env.REACT_APP_FLOW_SID,
        user: {
            userPrincipalName: '[email protected]',
            mail: '[email protected]',
            mobilePhone: '815-493-00',
            preferredLanguage: 'nb-NO'
        },
    };

    return (
        <FlexChat config={config} isDarkMode={isDarkMode} isDisabled={false} /> 
    );
};

ReactDOM.render(<App />, document.getElementById('root'));

Optional Configuration

Keep the chat closed on page load

If you want to have the Chat component closed on initialization you can set the property named closeOnInit to true in the config object. Default behavior is for the chat component to expand on page load.

NOTE: If there is an ongoing chat session the chat window will always expand on page load.

const config: ConfigProps = {
    // ...required config
    closeOnInit: true
};

PreEngagementFormMessage

If you want to add a message to the start page you can add a property named preEngagementFormMessage to the config object.

This object is of type MultiLangText and consists of an English (en) and Norwegian (no).

const config: ConfigProps = {
    // ...required config
    preEngagementFormMessage: {
        en: 'Du kan nå teknikere på ansvarlig avdeling innenfor tidspunktene 08:00 - 16:00 (CET/CEST)',
        no: 'You can reach technicians in the responsible department within the hours 08:00 - 16:00 (CET / CEST)';
    },
};

Theming

You can change CSS properties on the MainContainer, EntryPoint and CloseButton components to make them fit your experience, e.g. hide the EntryPoint button or change the height, width or render properties like position.

  • MainContainer: The expanded chat box.
  • EntryPont: Toggle button in the bottom right corner.
  • CloseButton: Toggle button on the top bar in the MainContainer

NOTE: some properties will be default from Twilio or overwritten by Intility's setup of the chat component.

type ThemeConfig = {
    MainContainer?: CSSProps;
    EntryPoint?: CSSProps;
    CloseButton?: CSSProps;
};
const config: ConfigProps = {
    // ...required config
    theme: {
        MainContainer: {
            width: '800px',
            height: '87vh',
            '@media only screen and (min-width: 1415px)': {
                width: `1080px`,
            },
        },
        // Display EntryPoint for small devices (i.e. Smart phones)
        EntryPoint: {
            '@media only screen and (min-width: 767px)': {
                display: 'none !important',
            },
        },
        // Display CloseButton for small devices (i.e. Smart phones)
        CloseButton: {
            '@media only screen and (min-width: 767px)': {
                display: 'none',
            },
        },
    },
};

Usage

Hooks

This component can be interacted with using integrated useChatActions hook.

type UseChatActionsFuncs = {
    setInputFieldContent: (body: string) => Promise<unknown>;
    setAndSendInputFieldContent: (body: string) => Promise<unknown>;
    toggleChatVisibility: () => Promise<unknown>;
    hasUserReadLastMessage: () => Promise<boolean>;
    isChatOpen: () => Promise<boolean>;
};

Illustration

Successful chat setup