Hi all, I’ve installed Hassio and Node Red today and what I want to do seems simple enough in theory but can’t find an obvious answer anywhere online.
I managed to create an email in and out node and the work just fine, I’m not expert with any of this so please be kind as I’ve seen techy forums before and they can be quite rough, all I want is this:
“If the email in the inbox contains “FIRE ALARM” in the body, do something, anything else leave as unread”
I have it working with all unseen mails but I only want unseen ones containing the above string.
I’m not experienced enough to translate git documents and just go ahead and configure them. queue abuse so would really appreciate a bit more guidance on how I achieve this.
Managed to get it to change the payload but I guess I still need something different. Is there a way to do an IF statement to say “if “FIRE ALARM do THIS, else BREAK” type thing? If it’s using js would be great if someone could share. The result of the hangs is that all inout email still hit my debug, only the payload is changed for matching emails.
Is that using the Switch node as suggested?
If you are using a Function node then show us the code you have already and explain in more detail what you are trying to do. What do you mean by BREAK in a function node? Do you mean that you want the function node to not pass on a message? If so then if you return null from the function node that tells it not to pass on a message.
I think the above (bold) is not going to be easy to do with the standard email node, as the check on contents can only be done after the message has been received, and passed on for further processing. You can't go back and reset non-matching messages to "unread".
You have not given us enough information here as to what email system you are looking at emails in.
Could i suggest a slightly different approach though
Use your email system (lets for the sake of the argument say Gmail) to setup some rules - so if the incoming email contains the key words (FireAlarm) in this case, then copy/move the email to a specific folder
Use the Email in node to just poll that specific folder for new incoming emails and then act on them in NR as you see fit