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 🙏

© 2026 – Pkg Stats / Ryan Hefner

convai-widget-ahmad

v1.0.0

Published

A lightweight embeddable ConvAI widget for web pages

Readme

🤖 ConvAI Widget

A lightweight, embeddable ConvAI widget that works in any web page - just like ElevenLabs! Simply drop in a script tag and start chatting with your AI agent.

✨ Features

  • 🚀 Zero Dependencies - Pure vanilla JavaScript
  • 🎨 Customizable Themes - Light and dark modes
  • 📱 Responsive Design - Works on all devices
  • 🔧 Easy Integration - One script tag, that's it!
  • 💬 Real-time Chat - Smooth conversation flow
  • 🎯 Agent-based - Each widget connects to specific agents
  • 🛡️ Shadow DOM - Isolated styles, no conflicts

🚀 Quick Start

1. Add to Your Website

<!-- Basic usage -->
<my-convai-widget agent-id="your-agent-id"></my-convai-widget>
<script src="https://unpkg.com/@ahmad/convai-widget@latest" async></script>

2. That's It! 🎉

Your widget is now live and ready to chat. Users can type messages and get responses from your AI agent.

📖 Usage Examples

Basic Widget

<my-convai-widget agent-id="customer-support-bot"></my-convai-widget>
<script src="https://unpkg.com/@ahmad/convai-widget@latest" async></script>

Dark Theme

<my-convai-widget agent-id="your-agent-id" theme="dark"></my-convai-widget>
<script src="https://unpkg.com/@ahmad/convai-widget@latest" async></script>

Custom Size

<my-convai-widget 
    agent-id="your-agent-id" 
    width="500px" 
    height="600px"
    theme="dark">
</my-convai-widget>
<script src="https://unpkg.com/@ahmad/convai-widget@latest" async></script>

🎛️ Configuration Options

| Attribute | Type | Default | Description | |-----------|------|---------|-------------| | agent-id | string | "default" | Your AI agent identifier | | theme | string | "light" | Theme: "light" or "dark" | | width | string | "400px" | Widget width (CSS value) | | height | string | "500px" | Widget height (CSS value) |

🔧 JavaScript API

Get Widget Reference

const widget = document.querySelector('my-convai-widget');

Send Message Programmatically

widget.sendMessageToWidget('Hello from JavaScript!');

Clear All Messages

widget.clearMessages();

Get Message History

const messages = widget.getMessages();
console.log(messages);

Listen for Events

// Listen for new messages
widget.addEventListener('message-sent', (event) => {
    console.log('Message sent:', event.detail);
});

widget.addEventListener('message-received', (event) => {
    console.log('Message received:', event.detail);
});

🎨 Styling

The widget uses Shadow DOM for style isolation, so it won't conflict with your existing CSS. However, you can still customize it:

/* Target the widget container */
my-convai-widget {
    --primary-color: #your-color;
    --bg-color: #your-bg;
    --text-color: #your-text;
    --border-color: #your-border;
}

🧪 Testing Locally

  1. Clone this repository
  2. Open test.html in your browser
  3. Try the interactive demo with different themes and settings
# Serve locally (optional)
npx serve .
# Open http://localhost:3000/test.html

📦 Installation

Via CDN (Recommended)

<script src="https://unpkg.com/@ahmad/convai-widget@latest" async></script>

Via npm

npm install @ahmad/convai-widget
import '@ahmad/convai-widget';
// Widget is now available globally

🔌 Backend Integration

Currently, the widget includes simulated responses. To connect to your real AI service:

  1. Replace the simulateAgentResponse method in index.js
  2. Add your API endpoint
  3. Handle authentication and error cases

Example:

async simulateAgentResponse(userMessage) {
    try {
        const response = await fetch(`https://your-api.com/chat/${this.agentId}`, {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ message: userMessage })
        });
        
        const data = await response.json();
        this.addMessage(data.reply, 'agent');
    } catch (error) {
        this.addMessage('Sorry, I encountered an error.', 'agent');
    }
}

🌐 Browser Support

  • ✅ Chrome 54+
  • ✅ Firefox 63+
  • ✅ Safari 10.1+
  • ✅ Edge 79+
  • ✅ Mobile browsers

📄 License

MIT License - feel free to use in your projects!

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

🆘 Support

🎯 Roadmap

  • [ ] Voice input/output
  • [ ] File upload support
  • [ ] Multiple language support
  • [ ] Advanced theming options
  • [ ] Analytics integration
  • [ ] A/B testing support

Made with ❤️ by Ahmad

Just like ElevenLabs, but yours! 🚀