Catalog npm
Back to packageRELEASE DETAILS

1.0.33

npm

1ff-chat-ui

chatbot to communicate with taught ai

aichatuifrontend
Published11 Sept 2023
Direct dependencies16
Transitive dependenciesNot calculated

README

Current package documentation

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.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 16

Native requirements
16 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
socket.io-client
Environment
{
  "local_name": "socket.io-client",
  "alias": false,
  "peer_metadata": null
}
^4.6.1runtime
@babel/preset-env
Environment
{
  "local_name": "@babel/preset-env",
  "alias": false,
  "peer_metadata": null
}
^7.16.11development
@babel/preset-typescript
Environment
{
  "local_name": "@babel/preset-typescript",
  "alias": false,
  "peer_metadata": null
}
^7.16.7development
@faker-js/faker
Environment
{
  "local_name": "@faker-js/faker",
  "alias": false,
  "peer_metadata": null
}
^7.6.0development
@testing-library/jest-dom
Environment
{
  "local_name": "@testing-library/jest-dom",
  "alias": false,
  "peer_metadata": null
}
^5.16.4development
babel-core
Environment
{
  "local_name": "babel-core",
  "alias": false,
  "peer_metadata": null
}
^6.26.3development
babel-loader
Environment
{
  "local_name": "babel-loader",
  "alias": false,
  "peer_metadata": null
}
^9.1.2development
html-webpack-plugin
Environment
{
  "local_name": "html-webpack-plugin",
  "alias": false,
  "peer_metadata": null
}
^5.5.1development
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^27.5.1development
jest-fetch-mock
Environment
{
  "local_name": "jest-fetch-mock",
  "alias": false,
  "peer_metadata": null
}
^3.0.3development
jest-location-mock
Environment
{
  "local_name": "jest-location-mock",
  "alias": false,
  "peer_metadata": null
}
^1.0.9development
node-libs-browser
Environment
{
  "local_name": "node-libs-browser",
  "alias": false,
  "peer_metadata": null
}
^2.2.1development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.8.8development
webpack
Environment
{
  "local_name": "webpack",
  "alias": false,
  "peer_metadata": null
}
^5.82.0development
webpack-cli
Environment
{
  "local_name": "webpack-cli",
  "alias": false,
  "peer_metadata": null
}
^5.1.1development
webpack-dev-server
Environment
{
  "local_name": "webpack-dev-server",
  "alias": false,
  "peer_metadata": null
}
^4.15.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-mnESx+YcjDD+2xgW3yGux/cIqB5w3QEpwaSKSvHrKu6zhMaoefV4oRfTVcHixar3DuMEcOdjNZVpAFX9kEw72g==",
  "shasum": "edc717e68c340f0adf56aab4e49e0643403d343f",
  "tarball": "https://registry.npmjs.org/1ff-chat-ui/-/1ff-chat-ui-1.0.33.tgz",
  "fileCount": 38,
  "unpackedSize": 129136,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQCpyTJCs+D0U0EXNTf27uylheOv5spDQzJyWA9DawwvKgIhALVnsszubN6d0FB76IN10aHW5Fc2WbNczKXX7eKTi/xK"
    }
  ]
}

Repository

PENDING
1ff/chat-ui

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:28 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:a367eafdbf8701acf1455abc16ce3ecaf66a302d2b213e97716d5453a523b09f

Other collected versions

1.0.4721 Dec1.0.467 Nov1.0.442 Nov1.0.431 Nov1.0.4226 Oct1.0.4116 OctView all collected versions →