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

techco-chat-widget

v1.0.5

Published

This widget provides a user-friendly interface for interacting with the chatbot. It allows users to input messages and receive responses from the chatbot.

Downloads

6

Readme

A chatbot widget for React project.

This widget provides a user-friendly interface for interacting with the chatbot. It allows users to input messages and receive responses from the chatbot.

Usage:

  1. Declare your widget.
  2. Set the appropriate configuration options.
  3. Run your react project.

Example:

Here's an example of how to use the ChatBot component:

import React, { useState } from 'react';
import { ChatBot } from 'techco-chat-widget';

export const suggestions = [
  'What’s my account balance?',
  'What’s my refund status?',
  'Give me my account statement for last three months.',
];
const now = new Date();

const agentDetails = {
  name: 'Jane Doe',
  avatar:
    'https://images.unsplash.com/photo-1488426862026-3ee34a7d66df?q=80&w=1727&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
};
const userDetails = {
  name: 'John Doe',
  avatar:
    'https://images.unsplash.com/photo-1534528741775-53994a69daeb?q=80&w=1964&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
};

const emojis = {
  sad: '😢',
  happy: '😊',
  angry: '😡',
  love: '😍',
  like: '👍',
};

function App() {
  const [sampleMessages, setSampleMessages] = useState([
    {
      message:
        "That's awesome. I think our users will really appreciate the improvements. 1",
      date: now,
      isUser: false,
      emoji: 'happy',
    },
    {
      message:
        "That's awesome. I think our users will really appreciate the improvements. 2",
      date: now,
      isUser: false,
    },
  ]);
  const [inputText, setInputText] = useState('');

  const onClickSuggestion = suggestion => {
    const newMessage = {
      message: suggestion,
      date: new Date(),
      isUser: true,
    };
    setSampleMessages([...sampleMessages, newMessage]);
  };

  const onSend = () => {
    console.log(inputText);
    if (inputText === '') return;
    const newMessage = {
      message: inputText,
      date: new Date(),
      isUser: true,
    };
    setSampleMessages([...sampleMessages, newMessage]);
    setInputText('');
  };

  const onSelectEmoji = (emoji, index) => {
    console.log(emoji, index);
    const newMessages = [...sampleMessages];
    newMessages[index].emoji = emoji;
    setSampleMessages(newMessages);
  };
  return (
    <ChatBot
      emojis={emojis}
      messages={sampleMessages}
      userDetails={userDetails}
      agentDetails={agentDetails}
      inputText={inputText}
      suggestions={suggestions}
      inputPlaceholder="Type a message..."
      onInputChange={event => setInputText(event.target.value)}
      onSelectEmoji={onSelectEmoji}
      onSend={onSend}
      onClickSuggestion={onClickSuggestion}
    />
  );
}

export default App;

Attributes

emojis: `A dictionary of emojis used for reactions to messages. This is optional.

Format:

{
sad: '😢',
happy: '😊',
angry: '😡',
love: '😍',
like: '👍',
}

messages: `An array of message objects. Each object represents a message and should follow this format:

Format:

{
message: string; // The content of the message
date: Date; // The date when the message was sent
isUser: boolean; // A flag indicating if the message is from the user
emoji?: string; // An optional emoji reaction to the message
}

userDetails: `An object containing the user's details. It should follow this format:

Format:

{
  name: string; // The name of the user
  avatar: string; // The URL of the user's avatar
}

Agent: `An object containing the agent's details. It should follow this format:

Format:

{
  name: string; // The name of the agent
  avatar: string; // The URL of the agent's avatar
}

inputText: `A string state used to store the message currently being typed by the user.

Type: `string`

Description: This state holds the value of the message input field. It updates as the user types their message.`,

suggestions: `An optional array of strings used for providing suggestions to the user.

Type: `string[]`

Description: This array holds a list of suggestions that can be presented to the user. It's optional and can be omitted if no suggestions are needed.`,

inputPlaceholder: `An optional string used to display placeholder text in the message input field.

Type: `string`

Description: This string is used as the placeholder text in the message input field. It gives the user a hint about what they're supposed to type.`

Methods

const onClickSuggestion = suggestion => {
  // This method is triggered when a suggestion is clicked.
  // It creates a new message object with the clicked suggestion as the message,
  // the current date, and a flag indicating that the message is from the user.
  // This new message is then added to the 'sampleMessages' state.
};

const onSend = () => {
  // This method is triggered when the send button is clicked.
  // It first checks if the 'inputText' is not empty. If it's not,
  // it creates a new message object with the 'inputText' as the message,
  // the current date, and a flag indicating that the message is from the user.
  // This new message is then added to the 'sampleMessages' state and the 'inputText' is cleared.
};

const onSelectEmoji = (emoji, index) => {
  // This method is triggered when an emoji is selected.
  // It adds the selected emoji to the message at the given index in the 'sampleMessages' state.
};