• UnoRouterUNOROUTER
Documentation
  • Chat Guide
Getting Started
  • Getting Started
Characters & World
  • Characters
  • Personas
  • Lorebooks
  • Cards
Prompting
  • Presets
  • Prompt Template
  • Group Chats
Scripting
  • Macros (CBS)
  • Regex Scripts
  • Triggers & Lua
Context & Media
  • Memory & Context
  • Images
  • Custom Providers
Your Data
  • Your Data
Navigate
  • Models
  • Rankings
  • Inspector
  • Pricing
  • Chat
  • Status

Search docs...

Start typing to search documentation

PlatformIntegrationsChat
Chat Guide

Triggers & Lua

Automation that runs around every message.

Triggers are event-driven scripts attached to characters. They fire at chat start or around messages, and can read history, set variables, inject system text, or stop a send.

The script format uses indent-scoped commands compatible with RisuAI trigger scripts v2, so existing cards' automation imports and runs.

Scripts with low-level access unlock effects that reach outside the chat:

runLLM checkSimilarity extractRegex runImgGen showAlert sendAIprompt triggerlua

LLM and image effects call real models and cost tokens; they require being signed in and run through your account.

For logic beyond the trigger VM, characters can carry Lua. The embedded runtime exposes an API of about 50 functions: chat access, variables, alerts, LLM calls, and more, compatible with RisuAI's Lua surface.

lua
onOutput = async(function(triggerId)
  local msg = getChat(triggerId, -1)
  if string.find(msg.data, "secret") then
    alertNormal(triggerId, "Secret mentioned!")
  end
end)
listenEdit("editoutput", function(triggerId, data)
  return data:gsub("%s+$", "")
end)

Lua can register hooks that rewrite text in flight: your input before assembly, the model's output before saving, and the raw request right before it is sent.

Hooks run in order with regex scripts of the same stage; use the request log to see the final result of the whole pipeline.

Display and request script modes run in a sandbox with a restricted command set. Scripts cannot touch your account, keys, or other conversations; the worst a bad script can do is garble its own chat.

Regex ScriptsMemory & Context

On this page

Trigger scripts
Low-level effects
Lua scripting
Edit hooks
Safety