I have several old flows where I had to place along the flow a data that set the msg.variable to some sort of message and then pass along to Alexa announcements at that the end of the flow.
I am setting the msg.variable from another flow on another tab etc…
the issue now is that it says undefined… yadda yadda on echo when I pass the message: msg.variable…
so I then tried to set global.variable and attempted to have the message be message: global.variable but it still says undefined…
On the Person Object I set
On the other flow I then have a data object that is taking in the global.alexaperson variable
"message": global.alexaperson + " " + msg.alexaSpeak,
what might I be missing?
I think you need to use global.get(“alexaperson”) to retrieve the value in the global variable.
Thank you @nickgeorge333 I would do this in a function somwhere before I call it and how do I capture it and write back to the variable global.alexaperson or another variable for use…
so I added at the top of the function the following…
const person = global.get('alexaperson')
// "message": msg.alexaperson + " " + msg.alexaSpeak,
"message": person + " " + msg.alexaSpeak
and I get this in the debug now
SyntaxError: Invalid or unexpected token
You have a comma at the end of your commented line, but not at the new one. If you have more lines after that require the comma there, that could be your syntax error.
As far as writing to the global variable in the code. It is global.set(“alexaperson” , value)
So what do I use for value since I am setting that per person.name object…
example… person.frank object I added another parameter called global and alaexaperson and set it as frank. so when I const… do I do then…
const person = global.get(person,alexaperson)
Ok Solved it…
Added a change node
and did the following
Then changed that function’s single line (didn’t need the declare)
"message": msg.person + " " + msg.alexaSpeak,
and it worked perfect!