问题
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