Store values with variables and counters
Automation · 3 min read ·
Create a channel variable, choose reset and expiry behavior, and inspect the history before correcting a value.
Variables hold channel state that automation can read later. Viewer metadata belongs to a specific viewer. Counters are named numbers; when Automation is enabled, they are also number variables. Keep these scopes distinct when designing a workflow.
Create a variable
- Open Automation › Variables and choose New variable.
- Enter a name using the accepted lowercase letters, digits, underscores and hyphens. The editor shows the read syntax, such as
{var.hats}. - Set its value and kind. Resolve validation errors before saving; changing a kind may be refused if the existing value cannot become that kind.
- Set Default to the value it should return to when reset, cleared or expired. An empty default means no value.
- Optionally set Expires after, measured in minutes after each change, and Reset when a stream starts.
- Add a useful Description, save, then reopen it to confirm the value and policy.
A variable can also appear the first time an action sets it. Creating it explicitly is useful when its default, description and lifetime should be decided before the first run.
Correct and inspect state
The variable editor shows recent changes and offers Restore for a historical value. Inspect what changed and when before restoring; restoration is another state change, so it can affect later automation. Deleting a variable is not the same as returning it to its default.
On Counters, edit a named number; a valid changed integer is saved when the field loses focus. The chat command !count changes counters, and a command can display one with {count hats}. When Automation exposes it as a variable, {var.hats} reads the same named number. Check the relevant command's permissions before letting viewers change it.
A Goal Bar on the Stage can show a number variable: set its Tracks to Number variable, then pick the variable, the Goal that fills the bar, and a Title (empty shows the variable’s name). The bar updates when a step changes the value and when you edit it by hand on Variables.
Viewer metadata
Use the viewer lookup in Variables to inspect remembered metadata for that person. Confirm the viewer and key before editing or clearing it. A channel-wide variable cannot stand in for one viewer's balance or preference without mixing people together.
If an automation reads an unexpected value, compare its exact fill-in name, the value's kind, recent history, expiry and stream-start reset. Test using a disposable name before connecting the value to rewards or other external effects. Do not use a production viewer's data as a test fixture.