Microsoft.Bot.Builder.Calling/Models/Contracts/Recognize.cs
1 using System.Collections.Generic;
3 using Newtonsoft.Json;
4 
5 namespace Microsoft.Bot.Builder.Calling.ObjectModel.Contracts
6 {
10  [JsonObject(MemberSerialization.OptOut)]
11  public class Recognize : ActionBase
12  {
18  [JsonProperty(Required = Required.Default)]
19  public PlayPrompt PlayPrompt { get; set; }
20 
24  [JsonProperty(Required = Required.Default)]
25  public bool? BargeInAllowed { get; set; }
26 
30  [JsonProperty(Required = Required.Default)]
31  public Culture? Culture { get; set; }
32 
41  [JsonProperty(Required = Required.Default)]
42  public double? InitialSilenceTimeoutInSeconds { get; set; }
43 
49  [JsonProperty(Required = Required.Default)]
50  public double? InterdigitTimeoutInSeconds { get; set; }
51 
55  [JsonProperty(Required = Required.Default)]
56  public IEnumerable<RecognitionOption> Choices { get; set; }
57 
63  [JsonProperty(Required = Required.Default)]
64  public CollectDigits CollectDigits { get; set; }
65 
66  public Recognize()
67  {
68  this.Action = ValidActions.RecognizeAction;
69  }
70 
71  public override void Validate()
72  {
73  base.Validate();
74 
75  if (this.PlayPrompt != null)
76  {
77  this.PlayPrompt.Validate();
78  }
79 
80  if (this.InitialSilenceTimeoutInSeconds.HasValue)
81  {
82  Utils.AssertArgument(this.InitialSilenceTimeoutInSeconds.Value >= MinValues.InitialSilenceTimeout.TotalSeconds && this.InitialSilenceTimeoutInSeconds.Value <= MaxValues.InitialSilenceTimeout.TotalSeconds,
83  "InitialSilenceTimeoutinSeconds has to be specified in the range of {0} - {1} secs", MinValues.InitialSilenceTimeout.TotalSeconds, MaxValues.InitialSilenceTimeout.TotalSeconds);
84  }
85 
86  if (this.InterdigitTimeoutInSeconds.HasValue)
87  {
88  Utils.AssertArgument(this.InterdigitTimeoutInSeconds.Value >= MinValues.InterdigitTimeout.TotalSeconds && this.InterdigitTimeoutInSeconds.Value <= MaxValues.InterDigitTimeout.TotalSeconds,
89  "InterDigitTimeoutInSeconds has to be specified in the range of {0} - {1} secs", MinValues.InterdigitTimeout.TotalSeconds, MaxValues.InterDigitTimeout.TotalSeconds);
90  }
91 
92  bool choicesSpecified = (this.Choices != null);
93  bool collectDigitsSpecified = (this.CollectDigits != null);
94 
96  (choicesSpecified && !collectDigitsSpecified) || (collectDigitsSpecified && !choicesSpecified),
97  "Either of RecognitionOption or CollectDigits must be specified");
98 
99  if (choicesSpecified)
100  {
101  RecognitionOption.Validate(this.Choices);
102  }
103  else if (collectDigitsSpecified)
104  {
105  this.CollectDigits.Validate();
106  }
107  }
108  }
109 }
static readonly TimeSpan InitialSilenceTimeout
Maximum initial silence allowed from the time we start the operation before we timeout and fail the o...
Definition: MaxValues.cs:27
static void AssertArgument(bool condition, string format, params object[] args)
Argument checker
This is a helper class for validating actions specified by customers
Definition: ValidActions.cs:11
static readonly TimeSpan InterdigitTimeout
Mamimum allowed time between digits if we are doing dtmf based choice recognition or CollectDigits re...
Definition: MinValues.cs:27
This is the action which customers can specify to indicate that the server call agent should perform ...
This is the action which customers can specify to indicate that the server call agent should play/tts...
Definition: PlayPrompt.cs:10
This is part of the "recognize" action. If the customer wants to collect digits - this needs to be sp...
static readonly TimeSpan InitialSilenceTimeout
Minimum initial silence allowed from the time we start the operation before we timeout and fail the o...
Definition: MinValues.cs:22
This is part of the "recognize" action. If the customer wants to speech/dtmf choice based recognition...
Root namespace for the Microsoft Bot Builder Calling SDK.
static readonly TimeSpan InterDigitTimeout
Mamimum allowed time between digits if we are doing dtmf based choice recognition or CollectDigits re...
Definition: MaxValues.cs:32
Culture
Cultures we support for recognition or prompt playing
Definition: Culture.cs:10
Root namespace for the Microsoft Bot Builder SDK.