# Define rate limit with context variable

**URL:** https://discourse.nodered.org/t/define-rate-limit-with-context-variable/62156
**Category:** General
**Created:** [4 May 2022 07:32 UTC](https://discourse.nodered.org/t/define-rate-limit-with-context-variable/62156 "2022-05-04T07:32:08Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Blovorad](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Blovorad](https://discourse.nodered.org/u/Blovorad)
#### Post date: [4 May 2022 07:32 UTC](https://discourse.nodered.org/t/define-rate-limit-with-context-variable/62156/1 "2022-05-04T07:32:08Z")

</div>

Hello,  
I'm trying, with node red dashboard, to configure rate limit with a slider. But on delay and inject nodes, i don't see how to put a context variable in the delay. Any idea how to proceed to manage a delay from a context variable.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [4 May 2022 08:19 UTC](https://discourse.nodered.org/t/define-rate-limit-with-context-variable/62156/2 "2022-05-04T08:19:16Z")

</div>

Hi and welcome to the forum.

What can help you in these times is to make a very simple flow that does only that specific thing.

When you say `context`.... That is at the flow level or specific to some code you wrote in a `function` node?

If it is at the flow level:  
You will need to use a `change` node to do what you want.  
Then when you open the `change` node you change it to something like:

![Screenshot from 2022-05-04 18-17-42](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fd76762c41ab3c97a4941018f182e69e9a1bdcf5.png)

Then the `msg.delay` will have the value from your context.

But if it is from a function node, slightly different.

But I'll leave it here for now.

---

<div class="post-metadata">

### Author: ![Blovorad](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Blovorad](https://discourse.nodered.org/u/Blovorad)
#### Post date: [4 May 2022 08:24 UTC](https://discourse.nodered.org/t/define-rate-limit-with-context-variable/62156/3 "2022-05-04T08:24:36Z")

</div>

Yes indeed I want to use it with the flow, thank you for this answer I will try right away

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [4 May 2022 08:35 UTC](https://discourse.nodered.org/t/define-rate-limit-with-context-variable/62156/4 "2022-05-04T08:35:56Z")

</div>

You will also have to tick the option in the node to allow the delay to be adjusted by `msg.delay`.

And!

Don't forget that the value is in MILLISECONDS......  
😉

It can catch you if you forget that.

---

<div class="post-metadata">

### Author: ![Blovorad](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Blovorad](https://discourse.nodered.org/u/Blovorad)
#### Post date: [4 May 2022 08:40 UTC](https://discourse.nodered.org/t/define-rate-limit-with-context-variable/62156/5 "2022-05-04T08:40:25Z")

</div>

Oh thanks for editing your message because that doesn't work, but when i set it ms this work fine thank you !

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [4 May 2022 08:52 UTC](https://discourse.nodered.org/t/define-rate-limit-with-context-variable/62156/6 "2022-05-04T08:52:09Z")

</div>

Yeah, it's caught me a lot of times.  
You want a 5 second delay and enter 5 as the value.

All good. 🙂

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [18 May 2022 08:52 UTC](https://discourse.nodered.org/t/define-rate-limit-with-context-variable/62156/7 "2022-05-18T08:52:47Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
