2

I'm currency trying out dialogflow fulfillment with NodeJS (dialogflow-fulfillment).

I am trying to access the parameters from dialogflow, but when I'm trying to access the currency-name parameter I get the following error: ReferenceError: name is not defined

But when I print the parameters I get: parameters: {"currency-name":["GBP","USD"],"number":500}

Currently using this code:

agent.add("parameters: " + JSON.stringify(agent.parameters.currency-name));
agent.add("parameters: " + JSON.stringify(agent.parameters));

1 Answers1

2

The problem is that agent.parameters.currency-name is treated as trying to access agent.parameters.currency and subtracting what is in name.

To reference a parameter name that includes characters besides letters and numbers, you need to use [] referencing and a string for the name. Something like this:

agent.parameters['currency-name']

You can also change the name of the parameter in Dialogflow to remove the hyphen.

Prisoner
  • 49,922
  • 7
  • 53
  • 105