【问题标题】:Create dialog using json file使用 json 文件创建对话框
【发布时间】:2016-12-25 06:28:59
【问题描述】:

我这几天一直在研究 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 reference 所说,

对话框模板文件。有效的扩展名是 .mct 用于加密 对话框文件、.json 和 .xml。

我在对话框文件的文档中的任何地方都找不到任何 JSON 结构。

之前有没有人尝试过并成功地使用 JSON 代替 XML?怎么样?

【问题讨论】:

    标签: ibm-watson watson-dialog watson-conversation


    【解决方案1】:

    Dialog service 仅接受 XMLMCT 文件。我认为您在文档中发现了一个错误。

    另一方面,该服务已于 2016 年 8 月 15 日弃用。该服务的现有实例将继续运行到 2017 年 8 月 9 日。我们鼓励用户迁移以使用 @ 987654322@.

    对话服务有一个网络工具,可以让您创建对话,而不必编写 XML。它还允许您将项目导出为 JSON。

    【讨论】:

      猜你喜欢
      • 2018-11-29
      • 2017-08-09
      • 1970-01-01
      • 2018-08-31
      • 1970-01-01
      • 2011-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多