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

@freeday-ai/webchat-widget

v1.1.32

Published

Freeday webchat widget

Downloads

3,631

Readme

@freeday-ai/webchat-widget

Freeday chat widget

NPM Downloads JavaScript Style Guide

Demo

Available at https://chat-widget.freeday.chat

portal-chat-demo

Install

pnpm add @freeday-ai/webchat-widget

or

npm install --save @freeday-ai/webchat-widget

Usage

First, sign up at https://freeday.me/register to get your account token. Your account token is what you will use to pass in as the token prop below.

Using in HTML

Paste the code below between your <head> and </head> tags:

<script>
  window.Freeday = {
    config: {
      // Pass in your Freeday account token here after signing up
      token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx',
      title: 'Welcome to Freeday!',
      subtitle: 'Ask us anything in the chat window below 😊',
      // Optionally render inside a different theme
      theme: "freeday_v2",
      primaryColor: "#13c2c2",
      // Optionally pass in a default greeting
      greeting: 'Hi there! How can I help you?',
      // Optionally specify the base URL
      baseUrl: 'https://beta-webchat.freeday.chat',
    },
  };
</script>
<!-- Make sure to replace <version> with the actual version number. You can find the latest version at: https://www.npmjs.com/package/@freeday-ai/webchat-widget?activeTab=versions -->
<script
  type="text/javascript"
  async
  defer
  src="https://unpkg.com/@freeday-ai/webchat-widget@<version>/dist/freeday-webchat-widget.iife.js"
></script>

Using in React

Place the code below in any pages on which you would like to render the widget. If you'd like to render it in all pages by default, place it in the root component of your app.

import React from 'react';

import {ChatWidget} from '@freeday-ai/webchat-widget';

// You can also import the following
// import {ChatWidget, ChatWindow, Freeday} from '@freeday-ai/webchat-widget';
//
// The `ChatWindow` component allows you to embed the chat however you want,
// and the `Freeday` object provides access to functions that can programmatically
// open/close the chat widget, e.g.:
//
// `Freeday.open()` // => opens the chat widget
// `Freeday.close()` // => closes the chat widget
// `Freeday.toggle()` // => toggles (opens or closes) the chat widget

const ExamplePage = () => {
  return (
    <>
      {/*
        Put <ChatWidget /> at the bottom of whatever pages you would
        like to render the widget on, or in your root/router component
        if you would like it to render on every page
      */}
      <ChatWidget
        // Pass in your Freeday account token here after signing up
        token='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx'
        title='Welcome to Freeday!'
        subtitle='Ask us anything in the chat window below 😊'
        primaryColor='#13c2c2'
        theme='freeday_v2'
      />
    </>
  );
};

Options

These are the props you can pass into your <ChatWidget /> React component, or the fields you can specify in your Freeday.config:

| Prop | Type | Value | Default | | :-------------------------------- | :---------------------------------- | :------------------------------------------------------------------------------------------------------------------------- | :------------------------------- | | token | string | Your Freeday account token | N/A | | title | string | The title in the header of your chat widget | Welcome! | | subtitle | string | The subtitle in the header of your chat widget | How can we help you? | | primaryColor | string | The theme color of your chat widget | 1890ff | | avatar | string | An optional An optional initial image url to be used as avatar | N/A | iframeUrlOverride | string | An override of the iframe URL we use to render the chat, if you have a custom intergration | | false | | isOpenByDefault | boolean | If you want the chat widget to open as soon as it loads | false | | persistOpenState | boolean | Persists the open state of the chat across pages | false | | hideToggleButton | boolean | Hides the toggle button in case you want to open/close programmatically | false | | | customIconUrl | string | A link to a custom icon image URL | N/A | | iconVariant | 'outlined' \| 'filled' | The style of the default icon | outlined | | position | 'right' \| 'left' | The position of the chat on the page | right | | styles | object | Inline style overrides for chatContainer, toggleContainer, and toggleButton | {} | | storageType | 'local' \| 'session' \| 'cookie' \| 'memory' \| 'none' | The storage type used by the user session | session | | onChatLoaded | ({open, close, identify}) => void | Callback fired when chat is loaded, returning some utility functions | N/A | | onChatOpened | () => void | Callback fired when chat is opened | N/A | | onChatClosed | () => void | Callback fired when chat is closed | N/A |

Development

To build the project, run pnpm build in the root directory. (If you're running it for the first time, you'll have to run pnpm install first.)

pnpm install
pnpm build

To test it out

pnpm install
pnpm dev

This will start a development server on http://localhost:3000 by default, and open up the example app in your browser.

Important notes

By default, the example widget points at development servers for the Freeday API (which runs at http://localhost:4000). These values are set with the iframeUrlOverride props respectively.

If you want to develop against your account in production, you can update these values to the following:

  • iframeUrlOverride: https://webchat.freeday.chat

(Note that you can also simply remove these props, since the values above are the defaults.)

You'll also want to update your account token to point to your own account. If you haven't already, create a free account at https://freeday.me/register to get started.

Once you have your account token, update the token prop to point at yours.

Questions?

If you're having any trouble getting started or just want to say hi, ask Beaudinn add Slack.