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

teko-text2sql-chatbot-widget

v0.0.14

Published

Text to SQL Chatbot Widget for Superset Integration

Readme

Text to SQL Chatbot Widget

A React component library for integrating a Text to SQL chatbot widget into your React applications. This widget provides a floating button that opens a chat interface where users can generate SQL queries from natural language.

Features

  • 🎨 Framework-agnostic: Works with React 16.13.1+ (React is a peer dependency)
  • 🔌 Easy Integration: Simple integration with any React application
  • Chatbot Widget BFF: Threads, streaming, and auth via the Chatbot Widget backend (no direct LiteLLM or client-side permission filtering in this package)
  • 💬 Chat Interface: Modern chat UI with message history and drag-to-move functionality
  • 📋 SQL Display: Formatted SQL query display with copy and insert actions
  • 🎯 Event-based: CustomEvent API for loose coupling with host applications

Installation

npm install teko-text2sql-chatbot-widget

or with yarn:

yarn add teko-text2sql-chatbot-widget

Quick Start

1. Import the Component and CSS

import React from 'react';
import { ChatbotWidget } from 'teko-text2sql-chatbot-widget';
// Don't forget to import the CSS!
import 'teko-text2sql-chatbot-widget/dist/index.css';

function App() {
  return (
    <div>
      {/* Your app content */}
      <ChatbotWidget env="prod" />
    </div>
  );
}

2. Basic Usage

Pass env so the widget can call the Chatbot Widget BFF (threads, streaming). The widget obtains a JWT via same-origin POST /api/v1/tokens (session cookies), not a client-side secret. The BFF resolves the chatbot app from the authenticated session.

import { ChatbotWidget } from 'teko-text2sql-chatbot-widget';
import 'teko-text2sql-chatbot-widget/dist/index.css';

function MyApp() {
  return (
    <ChatbotWidget env="prod" />
  );
}

3. With Chatbot Widget BFF

The widget talks to the Chatbot Widget backend only. Auth uses the logged-in Superset session: the client calls same-origin POST /api/v1/tokens with credentials: 'include' (no client-side secret).

import { ChatbotWidget } from 'teko-text2sql-chatbot-widget';
import 'teko-text2sql-chatbot-widget/dist/index.css';

function MyApp() {
  return (
    <ChatbotWidget env="prod" />
  );
}

Access to databases and tables is enforced on the server; this package does not ship client-side permission helpers.

Environment Configuration

The env prop determines which API endpoint the widget will use:

  • "dev" - Development environment: https://dev-api.text2sql.com
  • "stag" - Staging environment: https://stag-api.text2sql.com
  • "prod" - Production environment: https://api.text2sql.com

Example:

// Development
<ChatbotWidget env="dev" />

// Staging
<ChatbotWidget env="stag" />

// Production
<ChatbotWidget env="prod" />

API Reference

ChatbotWidget Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | env | 'dev' \| 'stag' \| 'prod' | Yes | - | Environment: 'dev' for development, 'stag' for staging, 'prod' for production | | position | 'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left' | No | 'bottom-right' | Position of the floating button |

TypeScript Types

type Environment = 'dev' | 'stag' | 'prod';

interface ChatbotWidgetConfig {
  env: Environment;
  position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
}

Advanced Usage

Handling Query Insertion with Custom Events

The widget uses CustomEvents to notify your application when a user wants to insert a SQL query. Listen for the chatbot:insert-query event:

import { ChatbotWidget } from 'teko-text2sql-chatbot-widget';
import 'teko-text2sql-chatbot-widget/dist/index.css';

function MyApp() {
  React.useEffect(() => {
    const handleInsertQuery = (event: CustomEvent) => {
      const { query } = event.detail;
      // Insert query into your application
      insertSQLIntoEditor(query);
    };

    window.addEventListener('chatbot:insert-query', handleInsertQuery as EventListener);
    return () => {
      window.removeEventListener('chatbot:insert-query', handleInsertQuery as EventListener);
    };
  }, []);

  return (
    <ChatbotWidget
      env="prod"
    />
  );
}

Complete Example with All Features

import React, { useEffect } from 'react';
import { ChatbotWidget } from 'teko-text2sql-chatbot-widget';
import 'teko-text2sql-chatbot-widget/dist/index.css';

function MyApp() {
  // Listen for query insertion events
  useEffect(() => {
    const handleInsertQuery = (event: CustomEvent) => {
      const { query } = event.detail;
      // Insert SQL into your query editor
      insertSQLIntoEditor(query);
    };

    window.addEventListener('chatbot:insert-query', handleInsertQuery as EventListener);
    return () => {
      window.removeEventListener('chatbot:insert-query', handleInsertQuery as EventListener);
    };
  }, []);

  return (
    <div>
      <h1>My Application</h1>
      {/* Your app content */}
      
      <ChatbotWidget env="prod" position="bottom-right" />
    </div>
  );
}

Styling

The widget comes with its own CSS that must be imported. The widget uses a light theme by default with a cyan gradient color scheme.

Custom Styling

You can override the widget styles by targeting the CSS classes:

  • .floating-button - The floating action button
  • .chat-window - The chat window container
  • .message-item - Individual chat messages
  • .sql-display - SQL query display block

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

Requirements

  • React 16.13.1 or higher
  • React DOM 16.13.1 or higher

Bundle Size

With externalized React, the bundle size is approximately ~20KB gzipped, making it lightweight and suitable for production use.

License

MIT