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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@buni.ai/chatbot-vue

v1.0.16

Published

Vue 3 composables for BuniAI chat widget

Readme

@buni.ai/chatbot-vue

Vue 3 components and composables for seamless BuniAI chat widget integration.

npm version Vue 3 TypeScript

🚀 Quick Start

Installation

npm install @buni.ai/chatbot-vue

Basic Usage

Option 1: Using the Composable (Recommended)

<template>
  <div>
    <h1>My Vue App</h1>
    <button @click="toggle">
      {{ isOpen ? 'Close Chat' : 'Open Chat' }}
    </button>
    
    <button @click="setCustomer">
      Set Customer Data
    </button>
    
    <p>Unread messages: {{ unreadCount }}</p>
  </div>
</template>

<script setup>
import { useBuniChat } from '@buni.ai/chatbot-vue';

const { 
  isOpen, 
  unreadCount, 
  toggle, 
  setCustomerData,
  initialize 
} = useBuniChat();

// Initialize the widget
await initialize({
  token: 'your-widget-token',
  config: {
    position: 'bottom-right',
    theme: 'light',
    primaryColor: '#007bff'
  },
  onReady: () => {
    console.log('✅ BuniAI widget loaded!');
  },
  onNewMessage: (data) => {
    console.log('💬 New message:', data);
  }
});

const setCustomer = () => {
  setCustomerData({
    name: 'John Doe',
    email: '[email protected]',
    userId: '12345'
  });
};
</script>

Option 2: Using the Vue Component

<template>
  <div>
    <h1>My Vue App</h1>
    <BuniChatWidget 
      token="your-widget-token"
      :config="{
        position: 'bottom-right',
        theme: 'light'
      }"
      @ready="onReady"
      @new-message="onNewMessage"
    />
  </div>
</template>

<script setup>
import { BuniChatWidget } from '@buni.ai/chatbot-vue';

const onReady = () => {
  console.log('Widget is ready!');
};

const onNewMessage = (data) => {
  console.log('New message received:', data);
};
</script>

Option 3: Using as a Vue Plugin

// main.js
import { createApp } from 'vue';
import { BuniChatPlugin } from '@buni.ai/chatbot-vue';
import App from './App.vue';

const app = createApp(App);
app.use(BuniChatPlugin);
app.mount('#app');
<!-- Now you can use the component globally -->
<template>
  <div>
    <BuniChatWidget token="your-widget-token" />
  </div>
</template>

📖 API Reference

useBuniChat(options?)

A Vue 3 composable for managing the BuniAI chat widget.

Parameters

| Parameter | Type | Description | |-----------|------|-------------| | options | BuniChatOptions | Optional initialization options |

Returns

{
  // Reactive state
  state: BuniChatState,
  isOpen: Ref<boolean>,
  isLoaded: Ref<boolean>,
  isMinimized: Ref<boolean>,
  unreadCount: Ref<number>,
  
  // Methods
  initialize: (options: BuniChatOptions) => Promise<void>,
  show: () => void,
  hide: () => void,
  toggle: () => void,
  minimize: () => void,
  maximize: () => void,
  destroy: () => void,
  
  // Data management
  setCustomerData: (data: CustomerData) => void,
  getCustomerData: () => CustomerData | null,
  setSessionVariables: (variables: SessionVariables) => void,
  getSessionVariables: () => SessionVariables | null,
  
  // Chat actions
  sendMessage: (message: string) => void,
  clearChat: () => void
}

<BuniChatWidget>

Vue component for rendering the chat widget.

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | token | string | - | Your BuniAI widget token (required) | | config | object | {} | Widget configuration options | | onReady | function | - | Callback when widget is ready | | onNewMessage | function | - | Callback for new messages | | onVisibilityChanged | function | - | Callback for visibility changes | | onError | function | - | Callback for errors |

Configuration Options

interface BuniChatOptions {
  token: string;
  config?: {
    position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
    theme?: 'light' | 'dark' | 'auto';
    primaryColor?: string;
    welcomeMessage?: string;
    placeholder?: string;
    showBranding?: boolean;
  };
  onReady?: (data: any) => void;
  onNewMessage?: (data: any) => void;
  onVisibilityChanged?: (data: any) => void;
  onError?: (error: Error) => void;
}

🎯 Advanced Examples

Custom Customer Data Management

<script setup>
import { useBuniChat } from '@buni.ai/chatbot-vue';
import { ref, watch } from 'vue';

const user = ref({
  name: '',
  email: '',
  plan: 'free'
});

const { initialize, setCustomerData } = useBuniChat();

// Initialize widget
await initialize({
  token: 'your-token',
  config: { position: 'bottom-right' }
});

// Watch for user changes and update widget
watch(user, (newUser) => {
  setCustomerData({
    name: newUser.name,
    email: newUser.email,
    customFields: {
      plan: newUser.plan,
      lastLogin: new Date().toISOString()
    }
  });
}, { deep: true });
</script>

Event Handling

<script setup>
import { useBuniChat } from '@buni.ai/chatbot-vue';
import { ref } from 'vue';

const chatHistory = ref([]);
const notifications = ref([]);

const { initialize } = useBuniChat();

await initialize({
  token: 'your-token',
  onNewMessage: (data) => {
    chatHistory.value.push(data);
    
    if (data.isFromBot) {
      notifications.value.push({
        message: `New message: ${data.message}`,
        timestamp: Date.now()
      });
    }
  },
  onVisibilityChanged: (data) => {
    console.log('Chat visibility:', data.visibility);
  }
});
</script>

Integration with Pinia Store

// stores/chat.js
import { defineStore } from 'pinia';
import { useBuniChat } from '@buni.ai/chatbot-vue';

export const useChatStore = defineStore('chat', () => {
  const { 
    isOpen, 
    unreadCount, 
    initialize, 
    toggle,
    setCustomerData 
  } = useBuniChat();

  const initializeWidget = async (token) => {
    await initialize({
      token,
      onNewMessage: (data) => {
        // Handle new messages in store
        console.log('Store received message:', data);
      }
    });
  };

  return {
    isOpen,
    unreadCount,
    initializeWidget,
    toggle,
    setCustomerData
  };
});

🔧 TypeScript Support

Full TypeScript support is included:

import type { 
  BuniChatOptions, 
  CustomerData, 
  SessionVariables 
} from '@buni.ai/chatbot-vue';

const options: BuniChatOptions = {
  token: 'your-token',
  config: {
    position: 'bottom-right',
    theme: 'light'
  }
};

const customerData: CustomerData = {
  name: 'John Doe',
  email: '[email protected]',
  userId: '12345'
};

🤝 Requirements

  • Vue 3.0+
  • Modern browser with ES2020 support

📝 License

MIT © BuniAI

🔗 Links

🆘 Support