Can Rule Machine dynamically reference a variable name like textToSpeak%Randnum%?

I currently do this with a large If Then Block, but it is a pain to change the number of items to randomly pick from for Alexa to speak. It would be much easier codee to be able to dynamically reference a variable name. Is there a way to do this? Maybe I am not thinking of this in the correct manner?

e use case is just I like for Alexa to tell me how many days to big events that are coming up as part of my nightly routine and I have it randomly pick an event and tell my "there are x days until y event"

Thank you!

Mike

If you have set a variable to a number or string value, Rule Machine should be able to send a notification that makes use of the variable value.

To have Rule Machine send the notification "there are x days until y event" you would type

"there are %variable-x% days until %variable-y% event"

Essentially, enclose the variable name in %’s and rule machine substitutes the current variable value automatically when sending the notification.

2 Likes

OP might wanna check out the RM5.1 docs on using %var% for strings.

I’m doing that now but I don’t think there is a way for the actual rule to change based on a variable value.

That's kinda where my first (deleted) answer was going, as I figured you meant "logic branching" or "indirect reference". But in RM, where there's a will, there's always a way!

Maybe show us a screenshot of how your rule currently works??

Not sure if this helps for your use case, but people have used RM's token function to pick random strings out of a list.

2 Likes