Replace variable name from object?

Hi,
I'm receiving an IFTTT webhookrelay from Google Home object and I'm trying to use its content.
It outputs this:

    {
        "type": "webhook",
        "meta": {
            "id": "815a9995-208e-44fd-be82-45ec2112dd6f",
            "bucked_id": "1ecec89d-b44e-4c53-87c5-f2abcc38392d",
            "bucket_name": "gactions",
            "input_id": "68922408-5099-4ab7-89b5-844210568a24",
            "input_name": "Default public endpoint",
            "output_name": "",
            "output_destination": ""
        },
        "headers": {
            "X-Newrelic-Id": [
                "VwAOU1RRGwAFUFZUAwQE"
            ],
            "X-Newrelic-Transaction": [
                "PxQGUgNUClYGB1lWVgFSUUYdUFIOFQZOElMLBw8KUQRQXQ0AAQQEQEgUUQMDW1kEVQZDPw=="
            ],
            "Content-Type": [
                "application/json"
            ],
            "Content-Length": [
                "58"
            ]
        },
        "query": "",
        "body": "{ \"time_google\": \"7.30\", \"message_google\": \"the potatoes are burning\" }",
        "method": "POST"
    }

Via a Function, then a JSON convert, I'm able to output


    Message.payload : object
        {"time_google":"7","message_google":"the potatoes are burning"}

Now I'm stuck. I need to change the payload (of "message_google" above) to
msg.payload.message = "the potatoes are burning"

(so I can cast this on another google device)

Help please? I've tried so many things....

You have a nicely formatted JSON event object as input -- but the msg.body property is a JSON string?

In a function node, you can parse the body string into an object, and then add a new "message" property, using code like this (untested):

// parse the json body string
var msgBody = JSON.parse(msg.body);

// replace the entire payload with a new object...
msg.payload = { "message": msgBody.message_google };
// ... or add the message to the existing payload object
msg.payload.message = msgBody.message_google;

return msg;

For those who prefer NOT to actually code, use a json node to convert msg.body to an object.
Then wire that to a change node and add a rules to:

"Set:" msg.payload.message "To:" msg.body.message_google

Oh, and for the adventurous types who like compact "one-liners", skip the json node and use this JSONata expression to convert it to an object AND extract the new message to its own payload:

Thank you very much for this. I struggled a little bit but I ended up with a json convert and the following function:

var msg = {payload:{ontime: msg.payload.time_google, message: msg.payload.message_google}};
return msg;

which worked. Thanks a lot!