Core Concepts
Understand the building blocks of Rawtoh — events, triggers, actions, and processes.
Rawtoh is built around a few simple ideas. Understanding these will help you build powerful automations.
The automation loop
Every automation in Rawtoh follows the same flow:
This creates a Process — a complete record of what happened, what ran, and whether it succeeded.
Event
An event is something that happened. It's emitted by a module and represents a data point — a Twitch chat message, a song change on Spotify, an OBS scene switch, or anything your custom module sends.
What's inside an event?
| Field | Description |
|---|---|
name | The event type, e.g. chat.message |
payload | Arbitrary JSON data — the event content |
emitter_group | Which module type emitted it (e.g. twitch) |
emitter_name | Which specific instance emitted it (e.g. main-bot) |
Events are stored and can be browsed in the Activity panel. You can favorite events to keep them from being purged during cleanup.
Trigger
A trigger is a rule that watches for specific events and decides whether to execute an action. It connects an event pattern to a piece of code.
How a trigger matches
A trigger fires when all of these are true:
- The event's
emitter_groupmatches the trigger's module group - The event's
namematches the trigger's event name - The trigger's TypeScript condition evaluates to a truthy value
- The cooldown period has elapsed (if configured)
- Both the trigger and its action are enabled
Trigger code
The trigger's program is a TypeScript module that imports the event from "rawtoh" and uses export default to decide whether the action should run:
import { event } from "rawtoh"
// Only fire for messages starting with "!"
export default event.payload.message.startsWith("!")Cooldown
Triggers support a cooldown with two modes:
- Throttle — fires immediately, then ignores events for the duration
- Debounce — waits for the duration with no new events before firing. Each new event resets the timer.
Action
An action is the code that runs when a trigger fires. Actions are TypeScript programs that can:
- Read the event payload that triggered them
- Call methods on connected modules via
module() - Read and write persistent data via
storage - Log output with
log() - Pause execution with
await sleep(ms)
All of these are imported from the "rawtoh" module.
Action code example
import { event, log, module } from "rawtoh"
// Respond to a chat command
const user = event.payload.user_name
// Call the Twitch module to send a message
await module("twitch").request("chat.say", {
message: `Hello @${user}, welcome!`
})
// Log for debugging
log("Greeted", user)Organization
Actions are organized by path, similar to a file system. For example: /twitch/chat/greet or /obs/scene-switch. This lets you group related automations into folders.
Shared script
A shared script is a reusable piece of code that can be imported by any trigger or action. They help you avoid duplicating logic across your automations.
Shared scripts use standard TypeScript export / import syntax and are organized by path, just like actions.
Example
// /utils/format (shared script)
export function greet(name) {
return `Hello, ${name}!`
}Then import it in any action or trigger:
import { module } from "rawtoh"
import { greet } from "/utils/format"
await module("twitch").request("chat.say", {
message: greet(event.payload.user_name)
}) Shared scripts can import from "rawtoh" and from other shared scripts. They support both absolute paths (/utils/format) and relative paths (./format). Note: shared scripts imported by triggers must not use action-only APIs (log, module, storage, sleep).
Process
A process is an execution record. Every time an event matches a trigger and runs an action, a process is created to track the result.
A process contains:
- Which event triggered it
- Which trigger matched
- When it started and ended
- Whether it succeeded or failed (with error details)
- Process logs — output from
log()calls in your action code - Module call logs — every RPC call your action made to a module, with parameters and timing
You can review all processes in the Activity panel of the script editor to debug and monitor your automations.