Actions
Actions are JavaScript programs that execute when a trigger matches an event.
What is an action?
Section titled “What is an action?”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
Action globals
Section titled “Action globals”Inside an action, you have access to these global variables and functions:
Event and trigger
Section titled “Event and trigger”| Global | Description |
|---|---|
event | The event that triggered this action |
trigger | The trigger that matched |
const user = event.payload.user;const message = event.payload.message;log("Triggered by", user, "with message", message);Module calls (RPC)
Section titled “Module calls (RPC)”Actions communicate with external modules via two types of calls :
| Function | Description |
|---|---|
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 continuingconst result = await module.request("twitch", "sendMessage", { text: "Hello!"});log("Module responded:", result);
// Notify — sends the command and continues immediatelyawait module.notify("obs", "switchScene", { scene: "BRB" });How it works behind the scenes:
- Your action calls
module.request()ormodule.notify() - The backend forwards the call to the target module via its WebSocket connection
- The module processes the command and (for
request) sends back a result - 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).
Storage
Section titled “Storage”| Function | Description |
|---|---|
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 helloconst 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}`});Utilities
Section titled “Utilities”| Function | Description |
|---|---|
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!" });Execution limits
Section titled “Execution limits”Actions run in a secure sandbox with resource limits:
| Limit | Default |
|---|---|
| Timeout | 30 seconds |
| Memory | 8 MB |
If an action exceeds these limits, it is terminated and the error is logged.