2016-08-18 214 views
0

我已经在watson对话框上工作了几天,并且我可以在遵循几个教程后使用.xml文件创建一个对话框。使用json文件创建对话框

<?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?怎么样?

回答

3

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

在另一方面,该服务8月15日弃用,服务的2016年现有的情况下,将继续运行,直到8月9日,2017年我们鼓励用户迁移到使用Conversation service

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

+0

Thanks German .. –