admin管理员组

文章数量:1290995

I want to get the original input of a parameter in my fulfillment code.

I tried:

var time = agent.parameters.time.original

but the result was undefined.

I have tried:

var query = agent.query

but could not accurately parse the parameter I need the original input of.

I want to get the original input of a parameter in my fulfillment code.

I tried:

var time = agent.parameters.time.original

but the result was undefined.

I have tried:

var query = agent.query

but could not accurately parse the parameter I need the original input of.

Share Improve this question asked Jul 30, 2018 at 15:39 Nathan LiuNathan Liu 2845 silver badges13 bronze badges 4
  • Are you using Actions on Google Node.js client library? – Aza T Commented Jul 30, 2018 at 20:53
  • @AzaTulepbergenov Not using for this function, but it is a dependency. – Nathan Liu Commented Jul 31, 2018 at 8:46
  • 1 Could you paste in the value of agent.parameters at the point that this code is running? console.log(agent.parameters) – techpeace Commented Jul 31, 2018 at 20:18
  • 1 @techpeace Sure, it is { time: '2018-08-01T15:00:00+01:00', openclose: 'open', date: '2018-08-01T09:52:34+01:00' } – Nathan Liu Commented Aug 1, 2018 at 8:53
Add a ment  | 

4 Answers 4

Reset to default 3

According to an answer on the old API.ai discourse forums, it looks like original parameters may only be available in a webhook fulfillment request if you set a context on the intent. At that point, the original parameter should be available in the contexts key in the request.

The actual name of the original value used for the parameter is "time.original". In order to get this, you need to use something like

var time = agent.parameters['time.original'];

What you were trying was to get an attribute of agent.parameters.time named original instead of an attribute of agent.parameters named time.original.

The solution i found as dated 3rd-Apr-2019 is following

Add custom parameter with actual entity name heaving value $yourparametername.orignal

And get its value like that

Please try:

var time = agent.contexts[0].parameters['time.original']

本文标签: javascriptGet original parameter inputDialogflow FulfillmentStack Overflow