I'm going through a NodeJS tutorial for Google Assistant / Actions on Google https://codelabs.developers.google.com/codelabs/actions-1/#5 and have code that looks like :
app.intent('Location', (conv, {geo-city}) => {
const luckyNumber = geo-city.length;
// Respond with the user's lucky number and end the conversation.
conv.close('Your lucky number is ' + luckyNumber);
});
Neither the linter in Dialogflow nor in my IDE is happy with {geo-city}
but I can't find a way around it. I've tried quotes, backticks etc but no joy. I can't change the variable name since it is a Google AI system entity (https://cloud.google.com/dialogflow-enterprise/docs/reference/system-entities).
What is the correct way to handle this please?
geo-city
is a subtraction outside of a string; this isn't just a lint problem. You can't destructure keys that aren't valid identifier names. Just do e.g.(conv, data)
thendata["geo-city"]
. – jonrsharpeYour lucky number is ${luckyNumber}
– L. Farosapp.intent('Location', (conv, data) => { const luckyNumber = data["geo-city"].length;
. ? – Stuart Brown