Query Patterns

A query pattern defines an example phrase a user might say. The Assistant Platform can match user spoken phrases that are semantically similar using natural language processing.

Query patterns can contain a literal string, conditionals, and arguments using Schema.org types.

Literal string

A query pattern can contain a literal string.

Example: "Start the guess the number game."

Conditionals

Portions of a query pattern can be considered optional. To indicate conditional query patterns, wrap the portion of the phrase in parenthesis and end it with a question mark. The following example defines Start the as optional:

Example: "(Start the)? Guess the number game"

Arguments

A query pattern can collect a portion of the user’s input through the use of named arguments (this can also be considered variables). Arguments are specified using the syntax: $Type:argument_name.

Example: "$org.schema.type.Number:number" describes a query pattern that expects an input of a Schema.org number, and that the actual number the user says will be captured in an argument named “number”.

Schema.org types

Following is the list of supported Schema.org types used for query patterns:

Type Example Query Pattern Example User Query
$org.schema.type.Date read my sms from $org.schema.type.Date:my_date on sms pro read my sms from april 1st on sms pro
$org.schema.type.Number blink the flashlight $org.schema.type.Number:number times blink the flashlight five times
$org.schema.type.Time read my sms from $org.schema.type.Time:my_time on sms pro read my sms from 5 pm on sms pro
$org.schema.type.DayOfWeek show me my meetings on$org.schema.type.DayOfWeek:day_of_week show me my meetings on Tuesday
$org.schema.type.Color turn on the $org.schema.type.Color:my_color strobe light turn on the red strobe light
$org.schema.type.priceCurrency show conversion rate for $org.schema.type.priceCurrency:cur on currency app show conversion rate for yen on currency app
$org.schema.type.Distance show conversion chart for $org.schema.type.Distance:dist show conversion chart for kilometer
$org.schema.type.Temperature set temperature to $org.schema.type.Number:num degrees$org.schema.type.Temperature:temp set temperature to 70 degrees fahrenheit
$org.schema.type.Organization watch $org.schema.type.Organization:organization highlights watch lakers highlights
show me stock price for$org.schema.type.Organization:organization show me stock price for Google
$org.schema.type.Person show top 10 $org.schema.type.Person:musician songs show top 10 bruno mars songs
show me news about $org.schema.type.Person:person show me news about bill gates
$org.schema.type.Place write review for $org.schema.type.Place:place write review for new york
show traffic on $org.schema.type.Place:location show traffic on mountain view
$org.schema.type.Product write review for $org.schema.type.Product:product write review for google glass
$org.schema.type.Book read $org.schema.type.Book:my_book read great expectations
$org.schema.type.Movie play the $org.schema.type.Movie:my_movie movie review the casablanca movie
$org.schema.type.TVSeries play next episode of $org.schema.type.TVSeries:tv_series play next episode of friends
$org.schema.type.servesCuisine show $org.schema.type.servesCuisine:my_cuisine restaurants show italian restaurants
$org.schema.type.MusicAlbum add $org.schema.type.MusicAlbum:album to my queue. add abbey road to my queue
$org.schema.type.MusicRecording add $org.schema.type.MusicRecording:song to my favorites. add with or without you to my favorites.
$org.schema.type.YesNo $org.schema.type.YesNo Yes
$org.schema.type.URL Add $org.schema.type.URL Add google.com
$org.schema.type.Email Add $org.schema.type.Email Add john@google.com
$org.schema.type.PhoneNumber Add $org.schema.type.PhoneNumber Add (777) 777-7777
$org.schema.type.Text What's that song where they say $org.schema.type.Text What's that song where they say you are my sunshine?

Custom types

Custom types allow you to define your own types, which are a collection of items, the possible ways that user might say an item (synonyms), and the corresponding argument value (key). This lets you define custom

The following example defines a custom type for the different ways a person might say "6am".

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