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

vue-converse

v4.3.7

Published

Build a form using a chat interface

Downloads

73

Readme

vue-converse

Build a form using a chat interface.

Install

npm install vue-converse

// or
yarn add vue-converse

Usage

Import VueConverse as a component where you want to use it.

import VueConverse from 'vue-converse'

Use it on your app by passing the required props:

<VueConverse
  :dialog="messages"
  @skip="getNextBotMessage"
  @response="handleResponse"
/>

Handling the response

data () {
  return {
    questionnaire: {}, // keep responses
    messages: [
      {
        type: 'text',
        text: 'How are you doing?',
        action: {
          type: 'buttons',
          field: 'fellings',
          options: [
            {
              label: 'Great',
              value: false,
              style: 'btn btn-green',
            },
            {
              label: 'Not so good',
              value: true,
            },
          ],
        },
      },
    ],
    dialog: [],
    currentDialog: 0,
  }
},

methods: {
  handleResponse({ field, response }) {
    this.questionnaire[field] = response // update your response data

    this.dialog.push({ // append messages to chat
      agent: 'user',
      type: 'text',
      text: response,
    })

    this.getNextBotMessage() // ask something else
  },

  getNextBotMessage() {
    this.currentDialog += 1
    const nextMessage = this.messages[this.currentDialog]
    this.dialog.push(nextMessage)
  }
}

Message structure:

| Field | Description | | ------------------- | ---------------------------------------------------------------------------------------------------------- | | Agent Required | Indicates if the message comes from the bot or the user. | | Type Required | Indicates the type of the message. For now, the only supported type is text | | Message Required | String that indicates the message that will be shown to the user. | | Required | If the message is set to required, the "skip question" option won't be available. Default Value: false | | Finish | Indicates if the conversation should finish after this question. Default Value: false | | Delay | If set up, the typing component is shown with this duration. | | Action | link | | Conditional Message | ...... |

Action

The action is optional and represents what the user can do after the bot's message. The supported action types are: input, buttons and dropdown.

If the action type is buttons or dropdown, you should set up a required field options, that contains an array of the options that will be displayed to the user.

| Field | Description | | ---------------- | --------------------------------------------------------------------------------- | | Type Required | Accept types: input, buttons and dropdown | | Field Required | String that is used to represent an unique user response | | Options | This represents the options to be displayed. Required for button and dropdown |

Example:

const messages = [
  {
    agent: 'bot',
    type: 'text',
    text: 'Hi, what\'s your name'
    delay: 2000,
    finish: false
    conditionalMessage: {}
    action: {
      required: true
      type: 'buttons',
      field: 'name',
      options: [
        {
          label: 'I don\'t know', // Button/Select label
          value: 'NOT_SURE', // Button/Select value
        },
      ],
    }
  },
  ...
]

Props

Available props's component:

| Name | Type | Default | Description | | --------- | -------- | --------------- | ---------------------------------------- | | dialog | Messages | [] | Required. Data of Messages | | labels | Labels | DEFAULT_LABELS | Labels for the "skip" and "send" buttons | | options | Options | DEFAULT_OPTIONS | Allow to enable and disable features |

Events

Available event's component:

| Name | Description | Data | | ------------------ | -------------------------------------------------------------- | ------------------------------------------------------------ | | response | Handles the user response to a message (action) | { field: 'isHappy', value: true, text: 'Yes' } | | skip | Go to the next message after the user has skipped an action | none | | registerDateTime | For every message, this event handles the DateTime it was sent | Fri Jul 15 2022 10:58:11 GMT-0300 (Brasilia Standard Time) |

Features

DateTime

VueConverse is able to display the time when the message was sent in chat and/or pass the DateTime to a registerDateTime event.

Both options are disabled by default and can be enabled by passing the option object to VueConverse as props, like so:

<VueConverse
  ...
  :options="{ displayDateTime: true, registerDateTime: true }"
  @registerDateTime="registerDateTime"
/>

Remember to always pass the registerDateTime event in case you want to have access to this data.