Is this a good way to add delay for each msg

[{"id":"5273c8b7.2e5bb8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"7066c53d.b7f40c","type":"function","z":"5273c8b7.2e5bb8","name":"++","func":"if ( (msg.i += 1) < msg.items.length ) return msg;\n","outputs":1,"x":550,"y":380,"wires":[["ecca47f3.6a80a8"]]},{"id":"ecca47f3.6a80a8","type":"function","z":"5273c8b7.2e5bb8","name":"for each item"[{"id":"5273c8b7.2e5bb8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"7066c53d.b7f40c","type":"function","z":"5273c8b7.2e5bb8","name":"++","func":"if ( (msg.i += 1) < msg.items.length ) return msg;\n","outputs":1,"x":550,"y":380,"wires":[["ecca47f3.6a80a8"]]},{"id":"ecca47f3.6a80a8","type":"function","z":"5273c8b7.2e5bb8","name":"for each item","func":"if( msg.i     == undefined ) msg.i = 0;\nif( msg.items == undefined ) msg.items = msg.payload;\n\nmsg.payload = msg.items[ msg.i ];\n\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":260,"wires":[["7ce357bb.ec4f18"]]},{"id":"dd576484.19f8d8","type":"inject","z":"5273c8b7.2e5bb8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":280,"wires":[["1879bff4.42ad5"]]},{"id":"1879bff4.42ad5","type":"function","z":"5273c8b7.2e5bb8","name":"arr","func":"msg.payload = [10,12,16];\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":280,"wires":[["ecca47f3.6a80a8"]]},{"id":"7ce357bb.ec4f18","type":"delay","z":"5273c8b7.2e5bb8","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":720,"y":260,"wires":[["7066c53d.b7f40c","e4fde399.d9c3c"]]},{"id":"e4fde399.d9c3c","type":"debug","z":"5273c8b7.2e5bb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":180,"wires":[]}]![Screenshot from 2020-02-10 23-10-32|690x372](upload://83GJxaRhHmaFXia7fumwyNm5CIG.png) ,"func":"if( msg.i     == undefined ) msg.i = 0;\nif( msg.items == undefined ) msg.items = msg.payload;\n\nmsg.payload = msg.items[ msg.i ];\n\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":260,"wires":[["7ce357bb.ec4f18"]]},{"id":"dd576484.19f8d8","type":"inject","z":"5273c8b7.2e5bb8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":280,"wires":[["1879bff4.42ad5"]]},{"id":"1879bff4.42ad5","type":"function","z":"5273c8b7.2e5bb8","name":"arr","func":"msg.payload = [10,12,16];\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":280,"wires":[["ecca47f3.6a80a8"]]},{"id":"7ce357bb.ec4f18","type":"delay","z":"5273c8b7.2e5bb8","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":720,"y":260,"wires":[["7066c53d.b7f40c","e4fde399.d9c3c"]]},{"id":"e4fde399.d9c3c","type":"debug","z":"5273c8b7.2e5bb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":180,"wires":[]}]![Screenshot from 2020-02-10 23-10-32|690x372](upload://83GJxaRhHmaFXia7fumwyNm5CIG.png) 

Please give more than just a flow because that forces people to load it and, quite frankly, many of us don't have time to do that for every question.

4 Likes

Also your flow is not importable. Please read How to share code or flow json

beat me to it, its like there is a parts of a flow pasted several times with the same screenshot pasted into the middle and at the end. All wrapped in ``` code markers ```

this is the screen shots I pulled out of the code block...

it looks like he is looping through an array and sending messages delayed by 4s.

@abhishekjaiswalraw I would say, no (IMO), not the ideal way to do that. You'd be better sending the array of items in one go via a delay node set to "rate limit 1msg / 4s"

image

1 Like

what is name of this node

I also highlighted it in the screen shot