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

@ssatai/chat-builder

v0.0.12

Published

Jelibot chat builder

Downloads

4

Readme

@ssatai/chat-builder

Papercups chat builder

NPM JavaScript Style Guide

What is it?

@ssatai/chat-builder is a library that allows you to create your own custom chat UI while leveraging the power of Papercups.

Try it out

Demo

Example of an imitation of Intercom's design using the Papercups ChatBuilder component:

Install

npm install --save @ssatai/chat-builder

Usage

First, sign up at https://app.papercups.io/register to get your account token. Your account token is what you will use to pass in as the accountId below.

To create a custom chat UI within the skeleton of a standard chat widget, you can use the header, body, footer, toggle, and notifications props to render custom React components:

import React from 'react';
import {ChatBuilder} from '@ssatai/chat-builder';

const Example = () => {
  const config = {
    // Put your personal account ID here
    accountId: '__MY_ACCOUNT_ID__',
    // Use a `greeting` to set the initial message in the chat
    greeting: 'Welcome to my website! Ask me anything below :)',
    // Provide some metadata about the person you're chatting with (if available)
    customer: {
      name: 'Demo User',
      // Ad hoc metadata
      metadata: {
        page: 'github',
      },
    },
  };

  return (
    <ChatBuilder
      config={config}
      header={({config, state, onClose}) => {
        return <Header {...} />;
      }}
      body={({config, state, scrollToRef}) => {
        return <Body {...} />;
      }}
      footer={({config, state, onSendMessage}) => {
        return <Footer {...} />;
      }}
      toggle={({state, onToggleOpen}) => {
        return <Toggle {...} />;
      }}
    />
  );
};

To create a completely custom UI from scratch, pass in your custom chat component as children like so:

import React from 'react';
import {ChatBuilder} from '@ssatai/chat-builder';

const Example = () => {
  const config = {
    // Put your personal account ID here
    accountId: '__MY_ACCOUNT_ID__',
    // Use a `greeting` to set the initial message in the chat
    greeting: 'Welcome to my website! Ask me anything below :)',
    // Provide some metadata about the person you're chatting with (if available)
    customer: {
      name: 'Demo User',
      // Ad hoc metadata
      metadata: {
        page: 'github',
      },
    },
  };

  return (
    <ChatBuilder
      config={config}
      // Optional callbacks
      onChatLoaded={() => console.log('Chat loaded!')}
      onChatClosed={() => console.log('Chat closed!')}
      onChatOpened={() => console.log('Chat opened!')}
      onMessageReceived={(message) => console.log('Message received!', message)}
      onMessageSent={(message) => console.log('Message sent!', message)}
    >
      {({config, state, onClose, onSendMessage, onToggleOpen, scrollToRef}) => {
        return (
          <MyCustomChat
            config={config}
            state={state}
            onClose={onClose}
            onSendMessage={onSendMessage}
            onToggleOpen={onToggleOpen}
            scrollToRef={scrollToRef}
          />
        );
      }}
    </ChatBuilder>
  );
};

Live demo

To see an example of a completely custom chat UI built with @ssatai/chat-builder and TailwindCSS, visit https://ssatai.github.io/chat-builder/

The code can be found here: https://github.com/ssatai/chat-builder/blob/master/examples/tailwind/src/App.js

Questions?

If you're having any trouble getting started or just want to say hi, join us on Slack! :wave:

Submitting a PR

We welcome any contributions! Please create an issue before submitting a pull request.

When creating a pull request, be sure to include a screenshot! 🎨

License

MIT © Papercups