Watson Dialog Dynamic Data variable input/output

旧时模样 提交于 2019-12-11 13:15:05

问题


I'm trying to build a simple dialog that the user will write: "My name is Joe", and I want the Dialog to set a userName variable to "Joe". I found this example, but the response is always empty string.

<folder label="Main">

        <output>
            <prompt selectionType="RANDOM">
                <item>Hello, What's your name?
                </item>
            </prompt>
        </output>
        <input id="input_2530402">
            <grammar>
                <item>My name is</item>
                <item>my name is (DYNAMIC_DATA)={userName}</item>
                <item>mine is (DYNAMIC_DATA)={userName}</item>
                <item>(DYNAMIC_DATA)={userName} </item>
                <item>(DYNAMIC_DATA)={userName} GiveName</item>
            </grammar>
            <action varName="userName" operator="SET_TO">{userName.source}</action>
            <action varName="Defaulted_Previous" operator="SET_TO_NO"/>
            <output>
                <prompt>
                    <item>Hi {userName}!</item>
                </prompt>
            </output>
        </input>
    </folder>

Variable definition:

<variables>
    <var_folder name="Home">
        <var name="agentName" type="TEXT" initValue="Alice"
            description="The virtual agent's name." />
        <var name="userName" type="TEXT" initValue="SomeName" description="The user's name" />
    </var_folder>
</variables>

I don't want the user name input to be seperated from the sentence... Any suggestions?

Thanks!


回答1:


I did something like this recently. Perhaps it will help:

https://github.com/codyburleson/watson-dialogs/blob/master/dialogs/getUserNameAndRespond.xml




回答2:


You need to have an entity such as

<entity name="DYNAMIC_DATA" entityType="GENERIC">
    <value name="DataCapture" value="DataCapture">
        <grammar>
            <item>*</item>
        </grammar>
    </value>
    <entityRules/>
</entity>



回答3:


The best way I’ve found is to use this entity instead:

<entity name="ANYTHING">
  <value>
    <grammar>
      <item>!.*</item>
    </grammar>
  </value>
</entity>

All examples from IBM contain the DYNAMIC_DATA thing, but it’s a really awful way of capturing data, since it silently loses many characters.

Examples of characters that are dropped are / \ " ! ? ( ) ° . , ; : _ – — > < = @. Try capturing an email address, for instance.

Then you use this to set a variable in exactly the same way.

<grammar>
  <item>my name is (ANYTHING)={userName}</item>
</grammar>

<action varName="userName" operator="SET_TO">{userName.source}</action>

What the above entity does is to use a regular expression to capture anything. The ! at the start means that everything following it is a regular expression.



来源:https://stackoverflow.com/questions/36055111/watson-dialog-dynamic-data-variable-input-output

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