|
| 1 | +--- |
| 2 | +title: 'How to: Add a confirmation to a custom command (Preview)' |
| 3 | +titleSuffix: Azure Cognitive Services |
| 4 | +description: In this article, how to implements confirmations for a command in Custom Commands. |
| 5 | +services: cognitive-services |
| 6 | +author: encorona-ms |
| 7 | +manager: yetian |
| 8 | +ms.service: cognitive-services |
| 9 | +ms.subservice: speech-service |
| 10 | +ms.topic: conceptual |
| 11 | +ms.date: 12/05/2019 |
| 12 | +ms.author: encorona |
| 13 | +--- |
| 14 | + |
| 15 | +# How To: Add a confirmation to a Custom Command (Preview) |
| 16 | + |
| 17 | +In this article, you'll learn how to add a confirmation to a command. |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +You must have completed the steps in the following articles: |
| 22 | + |
| 23 | +- [Quickstart: Create a Custom Command (Preview)](./quickstart-custom-speech-commands-create-new.md) |
| 24 | +- [Quickstart: Create a Custom Command with Parameters (Preview)](./quickstart-custom-speech-commands-create-parameters.md) |
| 25 | + |
| 26 | +## Create a SetAlarm command |
| 27 | + |
| 28 | +To demonstrate validations, let's create a new Command allowing the user to set an alarm. |
| 29 | + |
| 30 | +1. Open your previously created Custom Commands application in [Speech Studio](https://speech.microsoft.com/) |
| 31 | +1. Create a new Command **SetAlarm** |
| 32 | +1. Add a parameter called DateTime |
| 33 | + |
| 34 | + | Setting | Suggested value | Description | |
| 35 | + | ----------------- | ---------------------------------------------------------| ------------------------------------------------------------------------------------------------ | |
| 36 | + | Name | DateTime | A descriptive name for your Command parameter | |
| 37 | + | Required | true | Checkbox indicating whether a value for this parameter is required before completing the Command | |
| 38 | + | Response template | "- What time?" | A prompt to ask for the value of this parameter when it isn't known | |
| 39 | + | Type | DateTime | The type of parameter, such as Number, String, or Date Time | |
| 40 | + | Date Defaults | If date is missing use today | | |
| 41 | + | Time Defaults | If time is missing use start of day | | |
| 42 | + |
| 43 | +1. Add some sample sentences |
| 44 | + |
| 45 | + ``` |
| 46 | + set an alarm for {DateTime} |
| 47 | + set alarm {DateTime} |
| 48 | + alarm for {DateTime} |
| 49 | + ``` |
| 50 | + |
| 51 | +1. Add a Completion rule to confirm result |
| 52 | + |
| 53 | + | Setting | Suggested value | Description | |
| 54 | + | ---------- | ------------------------------------------------------- | -------------------------------------------------- | |
| 55 | + | Rule Name | Set alarm | A name describing the purpose of the rule | |
| 56 | + | Actions | SpeechResponse - "- Ok, alarm set for {DateTime}" | The action to take when the rule condition is true | |
| 57 | + |
| 58 | +## Try it out |
| 59 | + |
| 60 | +Select the Test panel and try a few interactions. |
| 61 | + |
| 62 | +- Input: Set alarm for tomorrow at noon |
| 63 | +- Output: "Ok, alarm set for 12/06/2019 12:00:00" |
| 64 | + |
| 65 | +- Input: Set an alarm |
| 66 | +- Output: "What time?" |
| 67 | +- Input: 5pm |
| 68 | +- Output: "Ok, alarm set for 12/05/2019 17:00:00" |
| 69 | + |
| 70 | +## Add the advanced rules for confirmation |
| 71 | + |
| 72 | +1. Add an advanced rule for confirmation. |
| 73 | + |
| 74 | + This rule will ask the user to confirm the date and time of the alarm and is expecting a confirmation (yes/no) for the next turn. |
| 75 | + |
| 76 | + | Setting | Suggested value | Description | |
| 77 | + | --------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------- | |
| 78 | + | Rule Name | Confirm date time | A name describing the purpose of the rule | |
| 79 | + | Conditions | Required Parameter - DateTime | Conditions that determine when the rule can run | |
| 80 | + | Actions | SpeechResponse - "- Are you sure you want to set an alarm for {DateTime}?" | The action to take when the rule condition is true | |
| 81 | + | State after execution | Wait for input | State for the user after the turn | |
| 82 | + | Expectations | Confirmation | Expectation for the next turn | |
| 83 | + |
| 84 | +1. Add an advanced rule to handle a successful confirmation (user said yes) |
| 85 | + |
| 86 | + | Setting | Suggested value | Description | |
| 87 | + | --------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------- | |
| 88 | + | Rule Name | Accepted confirmation | A name describing the purpose of the rule | |
| 89 | + | Conditions | SuccessfulConfirmation & Required Parameter - DateTime | Conditions that determine when the rule can run | |
| 90 | + | State after execution | Ready for Completion | State of the user after the turn | |
| 91 | + |
| 92 | +1. Add an advanced rule to handle a confirmation denied (user said no) |
| 93 | + |
| 94 | + | Setting | Suggested value | Description | |
| 95 | + | --------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------- | |
| 96 | + | Rule Name | Denied confirm | A name describing the purpose of the rule | |
| 97 | + | Conditions | DeniedConfirmation & Required Parameter - DateTime | Conditions that determine when the rule can run | |
| 98 | + | Actions | ClearParameter - DateTime & SpeechResponse - "- No problem, what time then?" | The action to take when the rule condition is true | |
| 99 | + | State after execution | Wait for input | State of the user after the turn | |
| 100 | + | Expectations | ElicitParameters - DateTime | Expectation for the next turn | |
| 101 | + |
| 102 | +## Try it out |
| 103 | + |
| 104 | +Select the Test panel and try a few interactions. |
| 105 | + |
| 106 | +- Input: Set alarm for tomorrow at noon |
| 107 | +- Output: "Are you sure you want to set an alarm for 12/07/2019 12:00:00?" |
| 108 | +- Input: No |
| 109 | +- Output: "No problem, what time then?" |
| 110 | +- Input: 5pm |
| 111 | +- Output: "Are you sure you want to set an alarm for 12/06/2019 17:00:00?" |
| 112 | +- Input: Yes |
| 113 | +- Output: "Ok, alarm set for 12/06/2019 17:00:00" |
| 114 | + |
| 115 | +## Next steps |
| 116 | + |
| 117 | +> [!div class="nextstepaction"] |
| 118 | +> [How To: Add a one-step correction to a Custom Command (Preview)](./how-to-custom-speech-commands-one-step-correction.md) |
0 commit comments