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

@ray-solutions/v-chat-bot

v1.0.3

Published

Chatbot UI using Vue.js 2

Downloads

92

Readme

Vue Chat Bot

For the one who is finding a customizable chatbot UI.

I build for my private project, but I tried to bring as many options as I think someone need it, so feel free to use it.

Install

npm i @ray-solutions/v-chat-bot

// or

yarn add @ray-solutions/v-chat-bot

Usage

Import & register the component

import { VueChatBot } from '@ray-solutions/v-chat-bot'

export default {
  components: {
    VueChatBot,
  },
  ...
}

And use it:

<VueChatBot
  :messages="data"
  :options="botOptions"
  @msg-send="messageSendHandler"
/>
data () {
  return {
    data: [], // See Data example below
    botOptions: {
      // See the list of options below
    }
  }
}

Props

List of available props to use in the component:

| Name | Type | Default | Description | | --- | --- | --- | --- | | messages | Array | [] | Required. Data of Messages | | options | Object | see below | Some options to customize UI | | bot-typing | Boolean | false | If true, the bot typing indicator will show | | input-disable | Boolean | false | If true, message input will be disabled | | is-open | Boolean | false | If true, the board will open from init |

Options

List of available options to customize UI:

| Name | Type | Default | Description | | --- | --- | --- | --- | | botTitle | String | 'Chatbot' | The bot name that will be shown on header of the board | | colorScheme | String | '#1b53d0' | Background color of bubble button & board header | | textColor | String | '#fff' | Color of bubble button icon & board header title | | bubbleBtnSize | Number | 56 | Size of bubble button (px) | | animation | Boolean | true | Set to false to disable animation of bubble button icon & board showing | | boardContentBg | String | '#fff' | Background color of board messages box | | botAvatarSize | Number | 32 | Size of bot avatar (px) | | botAvatarImg | String | 'http://placehold.it/200x200' | Avatar image | | msgBubbleBgBot | String | '#f0f0f0' | Background color of Bot message | | msgBubbleColorBot | String | '#000' | Text color of Bot message | | msgBubbleBgUser | String | '#4356e0' | Background color of user message | | msgBubbleColorUser | String | '#fff' | Text color of user message | | inputPlaceholder | String | 'Message' | The placeholder for message input | | inputDisableBg | String | '#fff' | Background color for the disabled input, mixed with opacity: 0.2 | | inputDisablePlaceholder | String | null | Placeholder message for disabled input |

Components & Events

This is the most important part you need to know, because you need these to integrate your bot API. Take a look my App.vue file if you need an example.

Events

| Name | Params | Description | | --- | --- | --- | | init | | Fire the first time the board is opened | | open | | Fire everytime the board is opened | | msg-send | value (Object) | Fire when user hit Send or select an option | | destroy | | Fire when board is closed |

Use msg-send to get the message from user and trigger request to bot API.

Components

Common pattern / Example data:

const messages = [
  {
    agent: 'bot', // Required. 'bot' or 'user'
    type: 'text', // Required. Bubble message component type: 'text' / 'button'
    text: 'Hello. How can I help you', // Required. The message
    disableInput: false, // Disable message input or not
    ...
  },
  {
    agent: 'user',
    type: 'text', // always
    text: 'I need a new laptop',
  },
  ...
]

Component list:

Current components supported by this package, path to files: components/MessageBubble/..

  • SingleText - type: 'text'
{
  agent: 'bot',
  type: 'text',
  text: 'Hello. How can I help you',
  disableInput: false,
}
  • ButtonOptions - type: 'button'
{
  agent: 'bot',
  type: 'button',
  text: 'Select the option below',
  disableInput: true,
  options: [
    {
      text: 'Open Google',
      value: 'https://google.com',
      action: 'url'
    },
    {
      text: 'Submit Support Ticket',
      value: 'submit_ticket',
      action: 'postback' // Request to API
    },
    ...
  ],
}
  • Other components are coming soon...

Slots

List of available slots:

| Name | Description | | --- | --- | | header | Board header, that contains Bot name. | | actions | The slot beside Send button in the input message. You can add extra actions here (emoji, attach,...) | | sendButton | Send button icon, you can change it to text. | | bubbleButton | Bubble button that contains BubbleIcon & CloseIcon as default. | | botTyping | Bot Typing message bubble that contains 3 dots indicator as default. |

Not found what your need?

You can overwrite the CSS by class name. Each type and state has separate class for you to customize.

Feature request: Feel free to open an issue to ask for a new feature.

Developers / Build

# Clone repo
git clone https://github.com/RAY-Solutions/v-chat-bot.git

# Install packages
yarn

# Development & Demo - http://localhost:1901
yarn serve

# Build main library
yarn build-bundle

Todo:

Many things...

  • ~~Events~~
  • ~~Loading / Typing indicators~~
  • ~~Disable message input on loading, vice versa...~~
  • Properties for target of button options
  • Add more message bubble components (video, images,...)
  • Add more events
  • Test
  • Accessibility

Thanks

Thank you! :tada: