Separate out different messages

I want to know when I get a LoRA Join message rather than other data packets - so for instance the following is a join message - I want to separate out these from other messages - but trying to look for instance ---

if (msg.payload.join_accept.session_key_id){
                   // do nothing 
 } else if (msg.payload.uplink_message.decoded_payload.Cert > 0){

does not work as the msg.payload.join_accept.session_key_id does not exist in other messages - would love some thoughts - thanks, Garth


Admin edit: wrap code in backticks

You can use a switch mode to direct messages by adding 2 entries

  1. Has key : msg.payload.join_accept.session_key_id
  2. Otherwise

Then you don't need to worry about testing for the existence of the key at all

Thanks so much Steve

how do you recommend implementing this as an if statement throws an error if that part of the payload is not present - indeed a Switch statement would be a great approach

actually I got it - thanks Genius!!

OK I'm back

so this works msg.payload.join_accept and catches all Join requests which is great
However if I try

  1. Has key : uplink_message.decoded_payload.Cert

I do not get a match, even though this exists in the alternative uploaded message.
Any advice would be welcome - thanks

Show us the incoming message copied from the debug pane using Copy Value in the debug pane, and also screenshot of how you have setup the Switch node.