Detect a word and activate an output

Hello good day
I want to make a flow that when detecting a specific word when receiving it in an email message, it triggers an output.

The idea is to receive a message such as "High temperature alert" that when detecting the word "alert" an output is activated.

Thanks for the help

I would make the "alert" more distinctive as a message may contain "alert" in a sentence. Maybe "*alert*".
here is an example of checking the email text payload and outputing only if it contains "*alert*". You would need to add the email node you are going to use.

[{"id":"c7648fb2.b10bd","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"this an *alert* high temp","payloadType":"str","x":120,"y":540,"wires":[["f4392a80.3c6538"]]},{"id":"4c559864.5b934","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"this is a simple message that contains the word alert alert","payloadType":"str","x":110,"y":580,"wires":[["f4392a80.3c6538"]]},{"id":"f4392a80.3c6538","type":"function","z":"c74669a0.6a34f8","name":"","func":"if(msg.payload.includes(\"*alert*\")){\n    return msg;\n}else{\n    return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":560,"wires":[["f3880de1.60f03"]]},{"id":"f3880de1.60f03","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":530,"y":580,"wires":[]}]

the top inject contains "*alert*" the lower one does not.

Thank you very much for your quick response and for your help.

now I have the problem that the output does not separate me, with the switch node.

for example I have two exits and if it receives * alert * it will exit through exit 1 and if it does not contain the message * alert * it will exit through exit 2

Do you have an example flow?

Thats not what your original question asked. :confused:

Use a switch node instead of a function...

image

Demo...

[{"id":"c7648fb2.b10bd","type":"inject","z":"4b3f21a3.ba434","name":"this an *alert* high temp","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"this an *alert* high temp","payloadType":"str","x":500,"y":2360,"wires":[["65088910.38ce38"]]},{"id":"4c559864.5b934","type":"inject","z":"4b3f21a3.ba434","name":"this is a simple message that contains the word alert","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"this is a simple message that contains the word alert","payloadType":"str","x":410,"y":2400,"wires":[["65088910.38ce38"]]},{"id":"f3880de1.60f03","type":"debug","z":"4b3f21a3.ba434","name":"ALERT! - to email we go","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":2340,"wires":[]},{"id":"65088910.38ce38","type":"switch","z":"4b3f21a3.ba434","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"*alert*","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":690,"y":2360,"wires":[["f3880de1.60f03"],["426e9e4.0c7346"]]},{"id":"6fc35c78.1aa394","type":"inject","z":"4b3f21a3.ba434","name":"this is a warning only","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"this is a warning only","payloadType":"str","x":510,"y":2320,"wires":[["65088910.38ce38"]]},{"id":"426e9e4.0c7346","type":"debug","z":"4b3f21a3.ba434","name":"No alert in that message - yippee","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":2380,"wires":[]}]

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