Variables
Introduction
When a trigger executes an action, it will automatically generate a set of variables specific to that event source and make them available to that action via the argument stack. You can use subsequent sub-actions to populate additional arguments, or even manipulate existing arguments on the stack.
Arguments only persist until the called action finishes execution and can not be referenced by any other action. To share variables across multiple actions, or to persist them across restarts, you can store them as Global Variables.
Types
Arguments
The argument stack contains all local variables accessible by an action and its sub-actions.
These variables can be utilized in most sub-action configuration text fields.
To use a variable from the current argument stack, wrap the variable name with %
symbols:
%userName%
Global Variables
Global variables allow you to share data between multiple actions, or even persist it across multiple restarts of Streamer.bot.
To quickly access a global variable, wrap the variable name with ~
symbols:
~myGlobalVariable~
User Global Variables
User variables function as global variables, but store values per user.
Generic
The following variables are always available:
Get the current system date, formatted as yyyy/MM/dd
Formatting is supported, e.g. %date:yyyy/MM/dd%
or %date:dddd, dd MMMM yyyy%
Get the current system time, formatted as hh:mm
Formatting is supported, e.g. %time:HH-mm%
Get the current system time, formatted as hh:mm:ss
Get the current system time, represented as unix time, in seconds.
Example: 1725936677
Get the current system time, formatted as yyyyMMdd.hhmmss
Insert a new line character sequence, \r\n
Get the unique ID of the action being executed
Get the name of the action being executed
Get the running ID of the action instance within the queue
Get the time the action was queued
Formatting
Variables can be formatted inline using standard C# notation
Numbers
For example, to format a numeric variable %tipAmount%
as a currency with 2 decimal places, we can use the following syntax: %tipAmount:c2%
Date and Time
Similarly, %time%
can be formatted in short notation with AM/PM using the following syntax: %time:t%
Inline Functions
Anywhere you can do a variable replacement, you can also execute inline functions to manipulate them.
math()
Leveraging the mXparser library, you can evaluate mathematical equations directly inline with variable replacements.
// Expected output: 20
$math(10+10)$
// Multiply %x% by 1.25
$math(%x% * 1.25)$
// Multiply %tier% by 10
$math(%tier% * 10)$
// Divide %duration% by 1000
$math(%duration% / 1000)$
length()
Obtain the length of arbitrary text or a given variable.
// Expected output: 69
$length(Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi, ut.)$
// Obtain the length of %rawInput%
$length(%rawInput%)$
Variable Viewer
The Variable Viewer in Streamer.bot provides a convenient location to view, modify, and create all types of global variables, including per-platform user variables.
You can open the variable viewer at any time by clicking Variables
on the Streamer.bot toolbar:
You will be greeted with a popup window:
Options
Add/Edit Variables
Selecting Add
or Edit
from the context menu will greet you with the following options:
Enter the name for your new variable
Enter a new value for this variable
By default, all values are treated as text, or string
variables.
Enable Auto Type
to automatically determine the type for the entered value.
For example:
0
can be auto-typed to a numeric type such asint
orlong
true
orfalse
can be auto-typed to abool
Variables Context Menu
The Right-Click context menu provides the following options:
Create a new variable of the current category type (e.g. persisted, non-persisted)
Edit the selected variable, see configuration options above
Remove the selected variable
Copy the selected variable name to your clipboard
Remove all variables from the current category type (e.g. persisted, non-persisted)
Inspecting Arguments
Action Queues > Action History
in Streamer.botFrom the Action History
view, you can Right-Click an action execution to inspect all variables on the argument stack:
View all variables on the argument stack before the action has started
View all variables on the argument stack after the action has completed
Variables Dialog
When you select one of these options, you will be greeted with a dialog containing the respective variables: