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

@andesphereai/core

v2.0.1

Published

Core utilities and API client for AndyChat - embeddable AI chatbot library

Readme

@andesphereai/core

Core utilities and API client for AndyChat - embeddable AI chatbot library.

Overview

This package contains shared functionality used by all AndyChat implementations:

  • API Client - Functions to communicate with AndyChat backend
  • Design Tokens - Colors, typography, spacing constants
  • Utilities - Helper functions for sessions, markdown parsing, etc.
  • Styles Helper - CSS generation and theming functions

Installation

npm install @andesphereai/core

API Reference

API Functions

fetchChatbotConfig(embedId)

Fetches chatbot configuration from the API.

  • embedId (string): The chatbot embed ID
  • Returns: Promise - The chatbot configuration with defaults applied

sendMessage(embedId, sessionId, message)

Sends a user message to the API and returns bot response.

  • embedId (string): The chatbot embed ID
  • sessionId (string): The current session ID
  • message (string): The user's message
  • Returns: Promise - The bot's response text

submitUserInfo(embedId, sessionId, userInfo)

Submits user information (name and email) to the server.

  • embedId (string): The chatbot embed ID
  • sessionId (string): The current session ID
  • userInfo (object): User information {name, email}
  • Returns: Promise - Server response

setApiBaseUrl(url) / getApiBaseUrl()

Set or get the API base URL for backend communication.

Utility Functions

generateSessionId()

Generates a unique session ID using crypto.randomUUID() with fallback.

  • Returns: string - A unique session ID

parseMarkdown(text)

Parses markdown text to HTML with support for:

  • Bold text (text or text)
  • Italic text (text or text)
  • Links (text)
  • Headings (# ## ### etc.)
  • Lists (numbered and bullet)
  • Returns: string - Parsed HTML

sanitizeUrl(url)

Sanitizes URLs to prevent XSS attacks, allowing http/https/mailto/tel protocols.

  • Returns: string - Sanitized URL or '#' fallback

createGreetingMessage(config)

Creates a greeting message from chatbot configuration.

  • config (ChatbotConfig): The chatbot configuration
  • Returns: string|null - Formatted greeting message

getEmbedId()

Gets the embed ID from the global window.ANDY_CHATBOT_ID variable.

  • Returns: string - The chatbot embed ID

Design Tokens

Comprehensive design system with consistent styling values:

Colors

import { colors } from '@andesphereai/core'
// colors.primary, colors.gray100, colors.userMessage, etc.

Typography

import { typography } from '@andesphereai/core'
// typography.fontFamily.primary, typography.fontSize.base, etc.

Spacing, Border Radius, Shadows, Z-Index, Animation

import { spacing, borderRadius, shadows, zIndex, animation } from '@andesphereai/core'

Chat-Specific Tokens

import { chat } from '@andesphereai/core'
// chat.bubbleSize, chat.windowWidth, chat.messageMaxWidth, etc.

Style Helpers

generateCssVariables()

Generates CSS variables string from design tokens for use in shadow DOM.

  • Returns: string - CSS variables block with :host selector

getBaseCss()

Generates base CSS rules using design token variables.

  • Returns: string - Base CSS for chatbot components

applyThemeColor(brandColor)

Applies custom brand color to CSS variables.

  • brandColor (string): Hex color code
  • Returns: string - CSS with theme-specific variables

applyOrientation(orientation)

Generates orientation-specific CSS for left/right positioning.

  • orientation (string): 'left' or 'right'
  • Returns: string - CSS for positioning

Configuration Objects

DEFAULT_CHATBOT_CONFIG

Default configuration object with all chatbot settings and sensible defaults.

CONFIG

Application configuration constants (form delays, session persistence, etc.).

Usage Example

import { fetchChatbotConfig, sendMessage, generateSessionId, colors, generateCssVariables } from '@andesphereai/core'

// Initialize
const embedId = 'your-embed-id'
const sessionId = generateSessionId()

// Fetch configuration
const config = await fetchChatbotConfig(embedId)

// Send a message
const response = await sendMessage(embedId, sessionId, 'Hello!')

// Use design tokens
const primaryColor = colors.primary
const cssVars = generateCssVariables()

TypeScript Support

The package includes JSDoc type definitions for all functions and configuration objects. For full TypeScript support, the types are documented in the source code.

Architecture

This core package provides the "cookbook and pantry" for AndyChat implementations:

  • API Logic: All backend communication
  • Design Tokens: Consistent styling system
  • Utilities: Common functions for parsing, validation, etc.
  • Configuration: Centralized settings management

Both @andesphereai/vanilla and @andesphereai/react use this core package for all business logic while implementing their own UI layers.

License

MIT