Why is my custom intent mixing parameters?

168 views Asked by At

I have a custom intent for app actions to say something like these sentences:

  1. Hey Google, open MyCookingApp to bake a Cake for 10 minutes
  2. Hey Google, open MyCookingApp to bake a Pizza for 15 minutes
  3. Hey Google, open MyCookingApp to bake a Pizza (here the user doesn't specify any time)

To do this I use this custom intent:

<action intentName="custom.actions.intent.BAKE_SOMETHING" queryPatterns="@array/ExampleQueries">
    <!-- Define parameters -->
    <parameter name="text1" type="https://schema.org/Text" />
    <parameter name="number1" type="https://schema.org/Number" />

    <!-- Define fulfillment -->
    <fulfillment urlTemplate="https://my.app.com/{?item_name,number_of_minutes}">
        <parameter-mapping intentParameter="text1" urlParameter="item_name" />
        <parameter-mapping intentParameter="number1" urlParameter="number_of_minutes" />
    </fulfillment>
</action>

And this is the ExampleQueries:

<string-array name="ExampleQueries">
    <item>bake a $text1</item>
    <item>bake a $text1 for $number1 minutes</item>
</string-array>

If I just say "open MyCookingApp to bake a Pizza" then I get item_name="Pizza" and number_of_minutes=null, which is correct!!

But if I say "open MyCookingApp to bake a Pizza for 15 minutes" then I get item_name="Pizza for 15 minutes" and number_of_minutes=15, which is WRONG!! Why do I get "Pizza for 15 minutes" as the the first parameter?

I have tried to have 2 different custom intents. One for only the item "bake a $text1" and another one for the item "bake a $text1 for $number1 minutes" but I get same results. It seems like the Assistant takes the "easiest" way. I mean, if "bake a $text1" is provided, then everything after "bake a" will be considered a string. But in this case why do I get a real value for number_of_minutes? It should be null, right?

Any body can show some light here. Basically I need to ask the users for a first string value, and then an optional number.

0

There are 0 answers