Hotlink Ready Lightweight

Build smart chat bots
for Chattable in seconds.

A tiny JavaScript framework with powerful triggers, automatic unit conversion, dictionary lookups, and personality through random responses.

No build step
Regex support
Works in any Chattable room
Support Bot
Online
User: Hey, it's 85°F outside!
SupportBot: 85°F is 29.4°C

Everything you need for great bots

Simple API. Powerful behavior. Zero dependencies.

Regex Triggers

Match messages with powerful patterns. Use strings or arrays of patterns that share the same response. Full regex support included.

bot.trigger("help|whats this|what is this", "Welcome to my website!...")
Random Personality

Add idle chatter and personality. Bot occasionally sends random phrases when no trigger matches (configurable chance).

bot.random("Ask me anything!")
Auto Unit Conversion

Automatically detects temperatures, speeds, and distances in messages and replies with converted values (°F↔°C, mph↔km/h, miles↔km).

"72°F" → "72°F (22.2°C)"
Dictionary Lookup

Users type define [word] and instantly receive definitions with part of speech and usage examples from a free public API.

define serendipity
Local Weather Data

Automatically retrieves local weather data based on the client IP when prompted.

what's the weather?

Get up and running in 30 seconds

Two ways to integrate. Both are production ready.

Recommended

Hotlink via CDN

Fastest setup. Always up to date.

Add the bot framework to your website

<script src="https://iframe.chat/scripts/bot.js"></script>

Place it before your custom bot configuration script. The Bot constructor will be globally available.

Full Control

Download & Self-Host

Host the file yourself for complete control.

Download the exact source used by the hotlink:

Download bot.js

Works great with any static hosting or even as an inline script.

Usage Guide

Create bots with just a few lines of code.

1. Create a new bot
const myBot = new Bot("HelperBot", {
  autoConvertUnits: true,   // Enable automatic °F/°C, mph/kmh, miles/km conversion
  dictionary: true,         // Enable "define word" responses
  weather: true,            // Enable automatic local weather responses
  chance: 10                // Set how often you want your bot to use it's random phrases (0-100)% default is always 10
});

The first argument is the display name shown when the bot sends messages. Options are optional but recommended.

2. Add triggers (pattern → response)
// Single pattern
myBot.trigger("help", "Try saying hi, your current temp, define ephemeral, or ask about the weather...");

// Multiple patterns sharing the same response(s)
myBot.trigger(["hello", "hi", "hey", "sup"], [ // triggers are not case sensitive
  "Hello $NAME! How can I help you today?",
  "Hi $NAME!",
  "Welcome, $NAME"
]);

// Regex power is fully supported
myBot.trigger("joke|funny", "Why did the developer go broke? Because he used up all his cache!"); //Regex autoflags 'igm'

$NAME is automatically replaced with the current user's name from Chattable in all bot outputs.

3. Add random personality phrases
// Single phrase
myBot.random("Did you know I can convert units automatically?");

// Multiple phrases (one is chosen at random)
myBot.random([
  "Having a good day so far?",
  "Feel free to ask me to define any word!",
  "Type 'define serendipity' to see what I can do."
]);

Random phrases are sent occasionally (roughly 1 in 10 messages) when no trigger matches.

4. That's it!

Once instantiated, your bot is live and listening. No need to call any start method. It hooks into chattable.on("message", ...) automatically.

Interactive Demo

Type messages below to see triggers, unit conversion, dictionary, and random responses in action.

DemoBot Live Simulation
Demo uses the same logic as the real script but has been modified to run outside of the Chattable container.

Tips & Best Practices

Order matters

Triggers are evaluated in the order you register them. Put more specific patterns before general ones.

Regex is powerful but be careful

Patterns are turned into new RegExp(pattern, "igm"). Escape special characters if you want literal matches.

Use $NAME for personalization

It gets replaced with chattable.user.name automatically in both trigger responses and random phrases.

Dictionary & conversion run on every message

Even if a trigger replies, unit conversion (if enabled) will still analyze the user's message and may send an extra message.

Only responds to the current user

By design, the bot only processes messages where data.uid === chattable.user.uid. This prevents it from replying to everyone in a shared room.

Server enforced abuse protection

Running a bot that spams the server can result in an automated temporary IP ban. Be courteous when scripting your bots.