查询模式 (Dialogflow)

查询句式定义了用户可能会说出的示例短语。Google 助理可以 使用自然语言匹配用户说出的语义相似的短语 处理。

查询句式可以包含文字字符串、条件和参数,使用 Schema.org 类型

字面量字符串

查询模式可以包含文字字符串。

示例:"Start the guess the number game."

条件语句

部分查询句式可视为可选项。为了指明条件 查询句式,用括号括住短语的相应部分,并以 一个问号。以下示例将 Start the 定义为可选:

示例:"(Start the)? Guess the number game"

参数

查询句式可通过使用 具名实参(这也可以视为变量)。参数为 使用 $Type:argument_name 语法指定。

示例:"$org.schema.type.Number:number" 描述了一个查询句式, 需要输入 Schema.org 编号,且用户的实际编号 “number”参数中捕获的内容

Schema.org 类型

以下是用于查询格式的受支持 Schema.org 类型列表:

类型 查询模式示例 用户查询示例
$org.schema.type.Date 在 sms 专业版上读取来自 $org.schema.type.Date:my_date 的短信 在 sms Pro 上读出我 4 月 1 日的短信
$org.schema.type.Number 闪光灯 $org.schema.type.Number:number 次 闪烁手电筒五次
$org.schema.type.Time 在 sms 专业版上读取来自 $org.schema.type.Time:my_time 的短信 从下午 5 点起在 sms Pro 上读出我的短信
$org.schema.type.DayOfWeek 显示我在$org.schema.type.DayOfWeek:day_of_week 的会议 显示我星期二的会议
$org.schema.type.Color 打开 $org.schema.type.Color:my_color 闪光灯 打开红色闪光灯
$org.schema.type.priceCurrency 在币种应用中显示 $org.schema.type.priceCurrency:cur 的汇率 在货币应用中显示日元的汇率
$org.schema.type.Distance 显示 $org.schema.type.Distance:dist 的转换图表 显示公里的换算图表
$org.schema.type.Temperature 将温度设为 $org.schema.type.Number:numdegree$org.schema.type.Temperature:temp 把温度设为 70 华氏度
$org.schema.type.Organization 观看 $org.schema.type.Organization:organization highlights 观看湖人队的精彩集锦
显示$org.schema.type.Organization:organization 的股价 显示 Google 的股价
$org.schema.type.Person 显示前 10 大 $org.schema.type.Person:musician 歌曲 显示最热门的 10 首布鲁诺火星歌曲
给我看看关于 $org.schema.type.Person:person 的新闻 显示关于账单门的新闻
$org.schema.type.Place 为 $org.schema.type.Place:place 撰写评价 为北京撰写评价
显示 $org.schema.type.Place:location 的路况 显示山景的路况
$org.schema.type.Product 为 $org.schema.type.Product:product 为 Google Glass 撰写评价
$org.schema.type.Book 阅读 $org.schema.type.Book:my_book 阅读良好的预期
$org.schema.type.Movie 播放 $org.schema.type.Movie:my_movie 电影 回顾《卡萨布兰卡》电影
$org.schema.type.TVSeries 播放 $org.schema.type.TVSeries:tv_series 的下一集 播放《好友》的下一集
$org.schema.type.servesCuisine 显示 $org.schema.type.servesCuisine:my_cuisine 餐馆 显示意大利餐馆
$org.schema.type.MusicAlbum 把 $org.schema.type.MusicAlbum:album 添加到我的队列中。 将《Abbey Road》添加到我的队列中
$org.schema.type.MusicRecording 把 $org.schema.type.MusicRecording:song 添加到我的收藏夹。 添加到我的收藏夹中(无论是否有你)。
$org.schema.type.YesNo $org.schema.type.YesNo
$org.schema.type.URL 添加 $org.schema.type.网址 添加 google.com
$org.schema.type.Email 添加 $org.schema.type.Email 添加 john@google.com
$org.schema.type.PhoneNumber 添加 $org.schema.type.PhoneNumber 添加 (777) 777-7777
$org.schema.type.Text 上面写着“$org.schema.type.Text”的那首歌是什么 他们说《你是我的阳光》的那首歌吗?

自定义类型

customTypes 对象可让您指定自己的类型。你可以定义 自定义类型的 name,并在 items 中包含以下字段:

  • key:与中的字符串对应的自定义类型的值 synonyms
  • synonyms:用户可能用来引用 key 的方式

以下示例定义了一个自定义类型,用于说明 可以说“早上 6 点”

"customTypes": [
    {
      "name": "$MorningOptions",
      "items": [
        {
          "key": "6am",
          "synonyms": [
            "6 am",
            "6 o clock",
            "oh six hundred",
            "6 in the morning"
          ]
        }
      ]
    }
  ]