DialogFlow - Get original string associated with parameter

自闭症网瘾萝莉.ら 提交于 2019-12-10 22:26:53

问题


Suppose I have a query like:

Turn on the lights from 5pm to 11pm.

I have a time-period entity that matches "5pm to 11pm", and the agent correctly parses the entity into two DateTime objects in the response. However, I need to get a mapping of the snippets of original text to the parameter, i.e. Original Text -> Parameter Name, e.g. "5pm to 11pm" maps to the "time-period" entity. Ideally, I would like the original text along with the parsed objects. Is this possible?


回答1:


If you are using just parameters, then it is not possible to get the original text from the user query. Dialogflow will only give you the parsed date. As you can see in the image below, there is only parsed startTime and endTime.

However, if you set a context in your intent, then you can get the value of both parsed date and the original text that user has entered. As you can see in the image below, there is both original text which is with .original suffix and the converted startDate and endDate.

You can set an output-context in the intent, with life-span of 1, just to get this value.

Hope it helps.



来源:https://stackoverflow.com/questions/54678897/dialogflow-get-original-string-associated-with-parameter

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