Timer functions control the countdown for transitions or task execution.
timer.startStarts the countdown timer. After the specified time has elapsed, the bot will transition to the specified node (block).
Signature: timer.start(time int, nodeId string) string
Arguments:
time — time in seconds.nodeId — block ID for transition after the countdown is complete.Return value: Timer ID.
Example of use:
$timerId = timer.start(60, “760b9732-4bfb-4846-a348-faae5138fcb2”) // $timerId contains a unique timer ID for 60 seconds
timer.stopStops (deletes) the countdown timer.
Signature: timer.stop(timerId string)
Arguments: timerId — timer ID.
Return value: None.
Example of use:
$timerId = timer.start(60, “760b9732-4bfb-4846-a348-faae5138fcb2”)
timer.stop($timerId) // stop (delete) the timer
timer.stopAllStops (deletes) all countdown timers.
Signature: timer.stopAll()
Arguments: No arguments.
Return value: None.
Example of use:
// start two timers
timer.start(60, “760b9732-4bfb-4846-a348-faae5138fcb2”)
timer.start(120, “760b9732-4bfb-4846-a348-faae5138fcb2”)
// stop all timers
timer.stopAll($timerId)