Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ public BeginSkill([CallerFilePath] string callerPath = "", [CallerLineNumber] in
[JsonProperty("activity")]
public ITemplate<Activity> Activity { get; set; }

/// <summary>
/// Gets or sets interruption policy.
/// </summary>
/// <value>
/// Bool or expression which evaluates to bool.
/// </value>
[JsonProperty("allowInterruptions")]
public BoolExpression AllowInterruptions { get; set; }

public override async Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default)
{
if (Disabled != null && Disabled.GetValue(dc.State))
Expand Down Expand Up @@ -208,6 +217,28 @@ protected override string OnComputeId()
return $"{GetType().Name}['{appId}','{activity}']";
}

protected override async Task<bool> OnPreBubbleEventAsync(DialogContext dc, DialogEvent e, CancellationToken cancellationToken)
{
if (e.Name == DialogEvents.ActivityReceived && dc.Context.Activity.Type == ActivityTypes.Message)
{
// Ask parent to perform recognition
await dc.Parent.EmitEventAsync(AdaptiveEvents.RecognizeUtterance, value: dc.Context.Activity, bubble: false, cancellationToken: cancellationToken).ConfigureAwait(false);

// Should we allow interruptions
var canInterrupt = true;
if (this.AllowInterruptions != null)
{
var (allowInterruptions, error) = this.AllowInterruptions.TryGetValue(dc.State);
canInterrupt = error == null && allowInterruptions;
}

// Stop bubbling if interruptions ar NOT allowed
return !canInterrupt;
}

return false;
}

/// <summary>
/// Regenerates the <see cref="SkillDialog.DialogOptions"/> based on the values used during the BeingDialog call.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@
"$kind": "Microsoft.IActivityTemplate",
"title": "Activity",
"description": "The activity to send to the skill."
},
"allowInterruptions": {
"$ref": "schema:#/definitions/booleanExpression",
"title": "Allow Interruptions",
"description": "A boolean expression that determines whether the parent should be allowed to interrupt the skill.",
"default": true,
"examples": [
true,
"=user.xyz"
]
}

}
}