Get original parameter input - Dialogflow Fulfillment

て烟熏妆下的殇ゞ 提交于 2020-03-05 04:42:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!