Function to pass msg to Service Call(Alexa)

Hi guys,

Currently, in my NodeRed flows, i have alot of Service Calls that use Alexa to make announcements.

I am looking to streamline this and instead have just 1 Service Call node to make announcements.

{

"message": "Front Gate is now open..",

"data": {

"type": "announce"

},

"target": "media_player.ha_group"

}

How can i create a function to pass a msg payload data of just the message portion only that i want to send to my Service Call node to make the Front Gate is now open…

I tried this code but got API error. Not sure if im doing this right?

msg.payload.data = {
  "message": "Front Gate is now open..",
};

return msg;

In the call service node you would use

"message": "{{payload}}"

What ever comes through in the payload position of the incoming message will be substituted. This can also be done with the other msg parts like msg.entity will replace {{entity}} and so on.