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

1ff-chat-ui

v1.0.47

Published

chatbot to communicate with taught ai

Downloads

1,439

Readme

1ff-chat-ui

1ff-chat-ui is a Node.js package that provides a chatbot widget for integrating a chatbot into Node.js projects. It uses Socket.IO for real-time communication with the server.

Installation

To install 1ff-chat-ui, use the following command:

npm install 1ff-chat-ui

Updates

To update 1ff-chat-ui, use the following command:

npm update 1ff-chat-ui

Usage

To use ChatUi in your Node.js project, follow these steps:

  • Import the required modules:
import ChatUi from "chat-ui";
  • Initialize it (Make sure to replace SOCKET_IO_URL with the URL of your socket server.):
document.addEventListener('DOMContentLoaded', () => {
  ChatUi.init(config);
})
  • Define the necessary configuration (optional):
const assistantConfig = {
  image: 'https://randomuser.me/api/portraits/women/90.jpg',
  role: 'Lead Nutrition Expert, PhD',
  name: 'Jenny Wilson',
  welcome: 'Have a quick chat with our personal nutritionist and get a free consultation about the perfect diet for you',
  ctaTextContent: 'Visit',
  initialMessage: { 
  	role: roles.assistant, 
  	content: 'Hi, Im Jenny Wilson, your personal nutritionist. Im here to help you with your nutritional needs.', 
  	time: '2023-05-12T12:34:56.000Z'
  }
};
const customTheme = {
  '--lumina': '#f0f2f5',
  '--whisper': '#ffffff',
  '--seraph': '#21bb5a',
  '--ember': '#cacadb',
  '--zephyr': '43, 49, 57',
  '--enigma': '#FFAE19',
  '--font-family': 'Roboto',
};
const containerId = "chatbot-container"; 
  • In the end, run this command, which is one of the commands found in package.json file:
    npm run build

Configuration

ChatUi supports the following configuration options:

  • SOCKET_IO_URL (String, default: 'http://localhost:5000'): The URL of the socket server.
  • assistant (Object, default: /lib/config/theme.js): Custom configuration for the assistant.
  • theme (Object, default: /lib/config/theme.js): Custom theme configuration for the chatbot.
  • socketConfig (Object, default: /lib/config/socket.js): Default socket.io-client config.
  • containerId (String, default: 'chatbot-container'): ID of the HTML container element for the chatbot.

Methods

ChatUi provides the following methods:

  • init(config): Initializes the chatbot with the specified configurations and elements.
  • closeWidget(): Closes the chat widget.
  • getTerm(): Retrieves the value of the 'utm_chat' parameter from the current URL.
  • setSocket(): Initializes the socket connection with the server.
  • socketEmitChat(): Emits a chat event to the socket server with the last question data.
  • sendMessage(): Sends a user message.
  • onError(): Handles the error event.
  • onKeyDown(event): Handles the keydown event.
  • toggleActiveTextarea(): Toggles the pointer events for the message textarea and send button elements.

Example

NOTE: everything outside of lib is a boilerplate example of how 1ff-chat-ui could be used in your project with an example, index.js file and index.html file where the index.js file is placed into a script tag;

Remember to replace SOCKET_IO_URL with the actual URL of your socket server.