几天来我一直在研究 watson 对话框,在学习了.xml
几个教程之后,我能够使用文件创建一个对话框。
<?xml version="1.0" encoding="UTF-8"?>
<dialog xsi:noNamespaceSchemaLocation="WatsonDialogDocument_1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<flow>
<folder label="Main">
<output>
<prompt selectionType="RANDOM">
<item>Hi, I'll show you the latest buzz around a topic of your choice. What topic are you interested in?</item>
</prompt>
<goto ref="getUserInput_2442994"/>
</output>
<output>
<prompt selectionType="RANDOM">
<item>Bye</item>
</prompt>
<getUserInput id="getUserInput_2442994">
<search ref="folder_2442998"/>
</getUserInput>
</output>
</folder>
<folder label="Library">
<folder label="Live Content" id="folder_2447777">
<output>
<prompt selectionType="RANDOM">
<item>Alright. Open this URL to see the tweets: http://insights-search.mybluemix.net/api/1/messages/search?q={Topic}%20AND%20posted%3A2015-07-01%20AND%20sentiment%3A{Sentiment}</item>
</prompt>
</output>
</folder>
<folder label="Live Content" id="folder_2442998">
<input>
<grammar>
<item>*</item>
</grammar>
<action varName="Topic" operator="SET_TO_USER_INPUT"/>
<output>
<prompt selectionType="SEQUENTIAL">
<item>Are you interested in positive or negative tweets?</item>
</prompt>
<getUserInput>
<input>
<grammar>
<item>positive</item>
</grammar>
<action varName="Sentiment" operator="SET_TO">positive</action>
<goto ref="folder_2447777"/>
</input>
<input>
<grammar>
<item>negative</item>
</grammar>
<action varName="Sentiment" operator="SET_TO">negative</action>
<goto ref="folder_2447777"/>
</input>
<input>
<grammar>
<item>*</item>
</grammar>
<action varName="Sentiment" operator="SET_TO">nothing</action>
<goto ref="folder_2442998"/>
</input>
</getUserInput>
</output>
</input>
</folder>
<folder label="Storage"/>
</folder>
<folder label="Global"/>
<folder label="Concepts">
<concept>
<grammar>
<item>positive</item>
<item>good</item>
</grammar>
</concept>
</folder>
</flow>
<entities>
</entities>
<constants>
</constants>
<variables>
<var_folder name="Home">
<var name="Topic" type="TEXT"/>
<var name="Sentiment" type="TEXT"/>
</var_folder>
</variables>
<settings>
</settings>
<specialSettings>
</specialSettings>
</dialog>
我正在为我的服务器使用 nodeJs 并希望切换到JSON
而不是XML
. 正如API 参考所说,
对话框模板文件。加密对话文件的有效扩展名为 .mct、.json 和 .xml。
我在对话框文件的文档中的任何地方都找不到任何 JSON 结构。
有没有人尝试过这个并成功地使用 JSON 而不是 XML?如何?