Need some quick assistance

I am creating a flow that triggers when I receive certain text messages. The texts will always contain the following language:

"MyENVERA: PERSON just arrived for ME, was verified and entry granted"

I want to be able to extract the PERSON from the payload so I can send it to a notification on my google home, saying something along the lines of PERSON has arrived.

I am able to get the text, no problem, and only read the texts that contain this message, but I am lost after that on how to extract the PERSON. Any help would be appreciated.

In a function node something like
msg.payload = msg.payload.split(" ")[1]
should do it. The split splits it into an array, splitting on space, then the [1] says to take the second element which will be the PERSON string. However that assumes that it is just one word. Otherwise it is more complex.

Do you have control of the message? If so then changing the text might make it easier. Imagine the case where the name contained the word "just". It then becomes rather tricky. Does the text need to be human readable? If not then send a JSON string. If it does then perhaps surround the name with single quotes or something similar, then you could split on the quotes.

I don't have control over the message and it does have more than one word for the person. The constants that I have to work with are trying to extract from "MyENVERA: " and " just...". All that stuff on the quotes I can drop and just take what's left. Just how to do it? And need to maintain spaces in the PERSON bexause it can be more than one word.

Split on space then drop the first element and step through until you find just, then use join() to put it back together.

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