0.2.0 • Published 2 years ago

vue-simple-chatbot v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Vue Simple Chatbot

Getting Start

npm install vue-simple-chatbot --save

# or use yarn

yarn add vue-simple-chatbot

Usage

Import as local component

import VueChatbot from 'vue-simple-chatbot';

export default {
  name: 'App',
  components: {
    VueChatbot
  }
}

Import as global component

import { createApp } from 'vue'
import VueChatbot from 'vue-simple-chatbot';
import App from './App.vue'

const app = createApp(App)

app.use(VueChatbot)

app.mount('#app')

Use the component

<template>
   <vue-chatbot :steps="steps">
        <template v-slot:header>
          <div>Hi, Chatbot Here</div>
       </template>
   </vue-chatbot>
</template>

<script>

export default {
    name: 'App',
    data() {
        return {
            steps: [
                {
                    id: '1',
                    hideInput: true,
                    message: 'Hello There...',
                    trigger: '2'
                },
                {
                    id: '2',
                    hideInput: true,
                    options: [
                        { id: '1', label: 'Please try again', trigger: '1' },
                        { id: '2', label: 'I am busy', trigger: '3' },
                        { id: '3', label: 'Ask me phone number', trigger: '4' },
                    ],
                },
                {
                    id: '4',
                    message: 'What is your phone number?',
                    trigger: 'phone',
                },
                {
                    id: 'phone',
                    user: true,
                    validator: (value) => {
                        if (isNaN(value)) {
                            return 'Value should be a number';
                        }
                        return true;
                    },
                    trigger: '3'
                },
                {
                    id: '3',
                    hideInput: true,
                    message: 'Enjoy your activities!',
                    end: true
                },
            ]
        }
    }
}

</script>

Api Reference

Props

NameTypeDefaultDescription
stepsArray[]Step by step chat declare here, you can check through this doc example
widthString'350px'Define width of chat
styleConfigObject{ theme: 'rgb(110, 72, 170)' }Set theme color of chat
delayNumber1000Set delay response chat both user and bot (1000 = 1 second)
botAvatarImagenpm.ioSet bot image
userAvatarImagenpm.ioSet user image

Slot

NameDescription
headerReplace header content, you can refer to this doc example

Credit

Inspired by React Simple Chatbot

License

MIT

0.2.0

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago