Tipping44
Tipping44

Reputation: 281

Can I use the parameter of an intent in the inline editor for Dialogflow?

When using Dialogflow, parameters are set, in short, the training data may look something like this:

So on CHEESE, HAM and MEAT FEAST, you would store them in a parameter, maybe known as $PizzaChoice

In the response section of the intent I know I can say "You chose $PizzaChoice".

But can I do this in the inline editor too? This below DOES NOT work, but I imagine if it's possible, it'd be something like:

agent.add('You selected' + $PizzaChoice);

Any ideas?

Upvotes: 2

Views: 887

Answers (1)

Prisoner
Prisoner

Reputation: 50701

If you're using the dialogflow-fulfillment library, and following their usual convention of the parameter to the intent handler being named agent, then you can get all the parameters in an object at agent.parameters.

So the line you're looking to write would be something like

agent.add( 'You selected '+agent.parameters['PizzaChoice'] );   

or, if you want to use the ES6 backquote templates:

agent.add( `You selected ${agent.parameters['PizzaChoice']}` );

Upvotes: 2

Related Questions