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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@twyla-ai/widget-core

v1.2.0

Published

Twyla Widget Core

Readme

Widget Core

Installation

npm i -S @twyla-ai/widget-core

Usage

import TwylaWidgetCore from '@twyla-ai/widget-core';

// create an instance
// this doesn't initialise a connection with the bot
const twylaWidgetCore = new TwylaWidgetCore({
  hookURL,
  apiKey,
});

const onMessage = message => {
  // append new message to the state or UI
};

// set callback for incoming messages
twylaWidgetCore.onMessage(onMessage);

// initialise a connection with the bot
twylaWidgetCore
  .init()
  .then(({ history }) => {
    // insert chat history into the state or UI
    twylaWidgetCore.initiateConversation();
  })
  .catch(error => {});

// send a message
twylaWidgetCore.send('I need to book a ticket');

// clean up
// end chat session
twylaWidgetCore.endSession();
// clear reference to instance if required
twylaWidgetCore = null;

Note: Try to call init only when user has to chat with the bot (typically on chat window open) rather than on website/app load. Once initialised, the connection will be active in background for the lifetime of the website/app and will automatically reconnect on outages such as network loss. Call endSession to finish the chat in cases such as navigating to a page that doesn't have the chat feature. If you have to resume the chat on re-navigating to the page(s) with the chat, you can create a new instance and the chat will resume where it was left off.

You can chat with multiple bots by creating different instances of the library.

API

See API Documentation.

Browser Support

Supports all browsers that support WebSockets API.

You must include a promise polyfill such as es6-promise and a fetch polyfill such as whatwg-fetch if the following browser support is required:

  • Chrome
  • Firefox
  • Safari 7+
  • IE 10+
  • Edge

For more info see:

  • https://caniuse.com/#search=fetch
  • https://caniuse.com/#search=promise
  • https://caniuse.com/#search=web%20socket

License

MIT © Twyla GmbH