Syn Bot /OSCOVA 快速回复(11)

Quick Replies

 

快速回复,简单说就是小语料知识库。

具体说有两种,一种是直接文本

class SmallTalkDialog : Dialog
{
    public SmallTalkDialog()
    {
        QuickReplies.Add("How are you?","I am going great.");
        QuickReplies.Add("Hi there!", "Well, hello there!");
        //More quick replies...
    }
}

另一种,带参回复

QuickReplies.Add("I like @sys.music.genre", (context, result) =>
{
    var genre = result.Entities.OfType(Sys.MusicGenre);
    result.SendResponse($"I like {genre} music as well.");
});

SIML格式

<Siml>
  <Dialog Name="SmallTalkDialog" IntentAlias="SmallTalk.Greetings">
    <Intent>
      <Expression>How are you?</Expression>
      <Response>I am doing great!</Response>
    </Intent>
    <Intent>
      <Expression>Hi there</Expression>
      <Response>Well, hello there!</Response>
    </Intent>
  </Dialog>
</Siml>

在该例子中,IntentAlias在Dialog上定义了一个通用的名称,因此,在上面的示例代码中,如果任何意图匹配,则对应的响应由名称SmallTalk.Greeting的意图生成。
 
posted @ 2018-05-24 14:12  道木先生  阅读(131)  评论(0编辑  收藏  举报