Stop inject message

I am currently stuck on a problem.
I need to be able to send messages from my automaton to a phone every 15 minutes until the person who receives the messages answers a message to say that he has taken it into account.
For the moment I succeeded with an inject to send a message then on the other hand to send a message to the automaton by checking with a function that this last one is well the expected one.
Now my problem is that I have to link all the nodes so that when the person sends his acknowledgement the automaton stops sending messages.
And this without installing new nodes and flows because my automaton does not allow it.
It's quite urgent :frowning:
Sorry if my english is not very good, I am french :slight_smile:

Normally I would use node-red-contrib-simple-gate to block the messages when appropriate, but if you can't install additional nodes then a crude way is to make the acknowledgement set a global variable and feed the inject node into a Switch node set to only pass messages when the global variable is in the right state. You need to decide when to start allowing them through again of course and reset the global at that point.

you can easily achieve this with a function node...


Demo flow

[{"id":"fb21b077.e82d8","type":"inject","z":"59c1e9ca.dd6988","name":"every 15m","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"0.5","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":630,"y":940,"wires":[["9c7b3790.838ae8"]]},{"id":"f8cb95c9.09e8f8","type":"debug","z":"59c1e9ca.dd6988","name":"to message sender","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1050,"y":940,"wires":[]},{"id":"9c7b3790.838ae8","type":"function","z":"59c1e9ca.dd6988","name":"block/unblock","func":"var block = context.get(\"block\") || false;\n\nif (msg.topic == \"block\") {\n    block = true;\n    node.status({fill:\"red\",shape:\"ring\",text:\"blocked\"});\n} else if (msg.topic == \"unblock\") {\n    block = false;\n    node.status({});//clear status\n}\n\ncontext.set(\"block\", block);\n\nif(block) return null; //halt the flow\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":940,"wires":[["f8cb95c9.09e8f8"]]},{"id":"55a14164.9d978","type":"inject","z":"59c1e9ca.dd6988","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"block","payload":"","payloadType":"str","x":610,"y":1000,"wires":[["9c7b3790.838ae8"]]},{"id":"a1cef437.a22018","type":"inject","z":"59c1e9ca.dd6988","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"unblock","payload":"","payloadType":"str","x":620,"y":1040,"wires":[["9c7b3790.838ae8"]]}]

My problem is that I don't have to do it manually from my pc but from sending a sms via a mobile phone.
So I'm looking into whether this is possible with a switch node.

the injects are for demo purposes only - to show you it is posible using regular nodes (as per your requirement) - you are supposed to change things around to whatever you need to achieve your goal (remember, I dont have your project, i have no idea what the user "sends" in his "SMS", you have shared zero code or flows!)


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