Accessing function data from service node

I have a function node, which does the following:

msg = {
    payload :  "test payload",
    title: "test title"
};
return msg;

The function node is connected to a call service, to send a notify push message however I cannot access the data from the function node.

I’ve tried to access the data using:

{"message":"{{payload}}","title":"{{title}}"}

Which results in an empty message being pushed by the service.

I’ve also tried to access the data using:

{"message":"{{msg.payload}}","title":"{{msg.title}}"}

Which results in an error:

"Call-service error. UndefinedError: 'msg' is undefined"

I’ve attached a debug node, and can see that the message is being sent from the function node as expected:

{"payload":"test payload","title":"test title","_msgid":"2fe3d3c469fad76a"}

However, I cannot figure out how to access the payload and title information from the service node.

Can someone please assist with how I can access the payload and title data from the function node, within the service node?

msg. is not required, the first example is right. In data drop down box change from J:expression to json

2 Likes

Thanks you for this it helped me to understand!

{"message":"Allumage {{payload.attributes.friendly_name}}","title":"HASSIO"}