Skip to content

Actions

Actions are JavaScript programs that execute when a trigger matches an event.

An action is a script that can:

  • Read event data
  • Call connected modules (send messages, switch scenes, etc.)
  • Store and retrieve data
  • Log information for debugging

Inside an action, you have access to these global variables and functions:

GlobalDescription
eventThe event that triggered this action
triggerThe trigger that matched
const user = event.payload.user;
const message = event.payload.message;
log("Triggered by", user, "with message", message);

Actions communicate with external modules via two types of calls :

FunctionDescription
module.request(target, method, params)Call a module method and wait for the response
module.notify(target, method, params)Send a command without waiting for a response
// Request — waits for the module to respond before continuing
const result = await module.request("twitch", "sendMessage", {
text: "Hello!"
});
log("Module responded:", result);
// Notify — sends the command and continues immediately
await module.notify("obs", "switchScene", { scene: "BRB" });

How it works behind the scenes:

  1. Your action calls module.request() or module.notify()
  2. The backend forwards the call to the target module via its WebSocket connection
  3. The module processes the command and (for request) sends back a result
  4. Your action receives the result and continues

The target can be:

  • A group name ("twitch") — Rawtoh picks any available module in that group
  • A specific module ("twitch/bot1") — sends to that exact module

The available methods and their parameters depend on the module. Check the module group’s manifest to see what methods are available (visible in the Modules page of the dashboard).

FunctionDescription
storage.get(key)Get a value by key (returns undefined if not found)
storage.set(key, value)Store a value (any JSON-compatible type)
// Count how many times someone said hello
const count = (await storage.get("hello_count")) || 0;
await storage.set("hello_count", count + 1);
await module.request("twitch", "sendMessage", {
text: `Hello! You're visitor #${count + 1}`
});
FunctionDescription
log(...)Log values (visible in process logs in the dashboard)
sleep(ms)Wait for a given number of milliseconds
await module.request("twitch", "sendMessage", { text: "3..." });
await sleep(1000);
await module.request("twitch", "sendMessage", { text: "2..." });
await sleep(1000);
await module.request("twitch", "sendMessage", { text: "1... Go!" });

Actions run in a secure sandbox with resource limits:

LimitDefault
Timeout30 seconds
Memory8 MB

If an action exceeds these limits, it is terminated and the error is logged.