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

@livechat/helpdesk-sdk

v1.0.3

Published

SDK for extending HelpDesk App

Downloads

286

Readme

HelpDesk SDK

This SDK is a set of tools that will help you integrate your apps with the HelpDesk App.

mit npm turborepo

For full documentation please head to Building HelpDesk apps.

Installation

The package can be installed directly from NPM.

npm install --save @livechat/helpdesk-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/[email protected]/dist/helpdesk-sdk.umd.min.js"></script>

Basic usage

Use one of the methods exported by the SDK.

createDetailsWidget(): Promise<IDetailsWidget>

Creates a widget instance to be used in the Ticket Details context.

import { createDetailsWidget } from ‘@livechat/helpdesk-sdk’;

createDetailsWidget().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/helpdesk-sdk’;

createFullscreenWidget().then(widget => {
  // do something with the widget
});

Widgets (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 HelpDesk App.

import { createDetailsWidget } from ‘@livechat/helpdesk-sdk’;

createDetailsWidget().then(widget => {
  function onTicketInfo(ticketInfo) {
    // do something with the ticket info when it changes
  }

  // register when you need it
  widget.on('ticket_info', onTicketInfo);

  // ...

  // unregister when you’re done
  widget.off('ticket_info', onTicketInfo);
});

Each widget type offers a different set of events that you can listen to. Check them out in the descriptions below.

Details widget (IDetailsWidget)

A type of widget that has access to the Chat Details context.

Events

ticket_info

Emitted when user opens a ticket within Tickets. The handler will get the ticket info object as an argument:

interface ITicketInfo {
  id: string;
  shortId: string;
  date: Date;
  createdBy?: string;
  updatedAt?: Date;
  updatedBy?: string;
  lastMessageAt?: Date;
  events: any[];
  requester: any;
  status: any;
  spam: any;
  subject: string;
  source: any;
  tagIds: string[];
  teamIds: string[];
  assignment: any;
  ratingRequestSent: boolean;
  totalRatings: number;
  rating?: any;
  ccs?: any[];
  draft?: any;
  integrations?: any;
  priority: any;
  followers: string[];
  childTickets: any[];
  parentTicket: any;
  customFields?: any;
}

Methods

getTicketInfo(): ITicketInfo | null

Gets the ticket info recorded most recently. Returns the ITicketInfo object, which is identical to the one emitted by the ticket_info event or null.

modifySection(section): Promise<void>

With this method, you can modify any custom section declared in the widget's opening 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 opening state. Otherwise, the section won't change. Also, the HelpDesk App ignores the commands without valid section definitions. Make sure that the definition you're sending is correct.

Fullscreen widget (IFullscreenWidget)

Events

This widget currently does not support any events.

Methods

setNotificationBadge(count: number | null): Promise<void>

Displays a red badge on top of the Fullscreen app icon. Use this to notify users there’s something important inside the widget. Make sure users can dismiss the notification to avoid cluttered UI.

Contributing

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.

License

The code and documentation in this project are released under the MIT License.