“Set Variable to Text” Different Text Options

Hi! Is there a way to provide text options for the “Set Variable to Text” action?

E.g. “[Hello there / Hey], my name is [Chris / Joe / Bob]. I like [pizza, pasta]."

And then Keyboard Maestro Engine can just randomly choose one of the options each time the action is ran?


Hi, @mercuriel,

The list should be separated by a comma.

Call RAND(1,B). "B" is the count of the list. This number will be used to get an item from the list, using the random number as the index.

Use double %% for your list variable (something like %%Variable%%VarName[index to be calculated by RAND() function]%%) and add a "Process Tokens" action, because the index itself is a variable to be processed first.

KM will first process the RAND() function and make double %% into one %. The process tokens action then processes the variable.

It looks like this:


Hi Martin, thanks very much for this detailed explanation! Clever use of RAND. I've marked this as “Solved”.

1 Like