查詢模式 (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 讀我的簡訊內容:$org.schema.type.Date:my_date 在 4 月 1 日傳簡訊給簡訊專家
$org.schema.type.Number 閃爍手電筒 $org.schema.type.Number:number times 將手電筒閃爍五次
$org.schema.type.Time 唸出我的簡訊 Pro 內容:$org.schema.type.Time:my_time 在下午 5 點傳簡訊給對方
$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 將溫度設為華氏 21 度
$org.schema.type.Organization 觀看 $org.schema.type.Organization:organization 亮點 觀看湖人隊精彩回顧
顯示$org.schema.type.Organization:organization 的股價 顯示 Google 的股價
$org.schema.type.Person 顯示 $org.schema.type.Person:musician 的前 10 大熱門歌曲 顯示前 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 加入我的待播清單。 在我的待播清單中新增便捷道路
$org.schema.type.MusicRecording 將 $org.schema.type.MusicRecording:song 加入我的收藏。 無論是否你自己都能加入收藏
$org.schema.type.YesNo $org.schema.type.YesNo
$org.schema.type.URL 新增 $org.schema.type.URL 新增 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"
          ]
        }
      ]
    }
  ]