问题
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.
回答1:
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.
回答2:
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
回答3:
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
.
回答4:
Please try:
var time = agent.contexts[0].parameters['time.original']
来源:https://stackoverflow.com/questions/51597601/get-original-parameter-input-dialogflow-fulfillment