BlockLogic

Let the rest of the flow run once per key for a set time. While the key is on cooldown, the blocks inside run instead and the flow stops.

Use a key like the user's ID for a per-user cooldown. Duration is like 30s, 10m or 1d. "This Flow" keeps the cooldown to this flow, "Global" shares it with every flow using the same key. In a custom block, "This Flow" means the flow that called it.

Inputs

KeyRequired

What the cooldown is for, like a user ID.

Example: [[ trigger.user_id ]]

DurationRequired

How long the cooldown lasts (30s, 10m, 1d).

Example: 1m

Scope

Whether the cooldown is for this flow only, or shared by every flow.

OptionsThis FlowGlobal
While On Cooldown

While On Cooldown

Holds blocks

Outputs

Seconds Left

Seconds until the cooldown ends.

Example: 42

Ends At (Unix)

When the cooldown ends.

Example: 1700003600

Build a bot using blocks like Cooldown

Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.

Advanced Documentation

This documentation can be useful when using code mode.

ID: cooldown

Inputs

FieldInventScript nameValue
Keykeye.g. "[[ trigger.user_id ]]"
Durationduratione.g. "1m"
Scopescope"This Flow", "Global"
While On Cooldownon_cooldownblocks: func() { ... }

Outputs

FieldInventScript nameValue
Seconds Leftseconds_lefte.g. "42"
Ends At (Unix)ends_ate.g. "1700003600"

Example InventScript

// cooldown
cooldown2 := cooldown(Args{key: "[[ trigger.user_id ]]", duration: "1m"})
send_text_message(Args{
	channel_id:      trigger.channel_id,
	message_content: "Seconds Left: " + cooldown2.seconds_left,
})

More logic blocks