DialogFlow Fulfilment - How to get both original and default value for a parameter

橙三吉。 提交于 2019-12-11 05:45:03

问题


I am trying to get a time value from an intent as both $time and $time.original. I need the $time value to do some processing on it and I need the $time.original to show the output back to user.

For example, if user says, 'are you open tomorrow?', I want to respond 'Yes, we are open tomorrow?' but on the back end, I need the value of date 'tomorrow' to do the processing.

Any help would be appreciated.


回答1:


First, you would need @sys.date entity if you want to catch value of entities like tomorrow instead of @sys.time

Now coming to the question, directly extracting the parameter value will only give us parsed date value, not the original value.
But if we set an output context, then from that context we can extract both parsed value and the original value as intended.

Here is a request that we get on webhook we can get date and date.original by parsing the output-context that we set in the intent:

{"responseId":"###","queryResult":{"queryText":"are you open tomorrow","parameters":{"date":"2018-12-28T12:00:00+05:30"},"allRequiredParamsPresent":true,"fulfillmentText":"","fulfillmentMessages":[{"text":{"text":[""]}}],"outputContexts":[{"name":"projects/###/agent/sessions/###/contexts/time","lifespanCount":5,"parameters":{"date":"2018-12-28T12:00:00+05:30","date.original":"tomorrow"}}],"intent":{"name":"projects/###/agent/intents/###","displayName":"time-intent"},"intentDetectionConfidence":1,"languageCode":"en"}}




回答2:


I have not also tried with it yet but I Guess you would be able to parse it with it system entity Dialogflow system Entities as they're shown @sys.date and example matches with what you need. I guess it will be processing it into date



来源:https://stackoverflow.com/questions/53935387/dialogflow-fulfilment-how-to-get-both-original-and-default-value-for-a-paramet

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