Rawtoh Rawtoh / Docs

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:

Module → emits → Event → matches → Trigger → runs → Action

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
nameThe event type, e.g. chat.message
payloadArbitrary JSON data — the event content
emitter_groupWhich module type emitted it (e.g. twitch)
emitter_nameWhich 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:

  1. The event's emitter_group matches the trigger's module group
  2. The event's name matches the trigger's event name
  3. The trigger's TypeScript condition evaluates to a truthy value
  4. The cooldown period has elapsed (if configured)
  5. 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:

Action

An action is the code that runs when a trigger fires. Actions are TypeScript programs that can:

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:

You can review all processes in the Activity panel of the script editor to debug and monitor your automations.