Skip to content

Commit 31af94b

Browse files
authored
Add OnInstallationUpdateActivity in adaptive trigger conditions (#4629)
* add OnInstallationUpdateActivity and related tests * adjust comments * add schema for InstallationUpdate activity * update test.schema * update schema
1 parent b9a125b commit 31af94b

File tree

8 files changed

+181
-19
lines changed

8 files changed

+181
-19
lines changed

libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/AdaptiveComponentRegistration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public virtual IEnumerable<DeclarativeType> GetDeclarativeTypes(ResourceExplorer
5858
yield return new DeclarativeType<OnConversationUpdateActivity>(OnConversationUpdateActivity.Kind);
5959
yield return new DeclarativeType<OnEndOfConversationActivity>(OnEndOfConversationActivity.Kind);
6060
yield return new DeclarativeType<OnTypingActivity>(OnTypingActivity.Kind);
61+
yield return new DeclarativeType<OnInstallationUpdateActivity>(OnInstallationUpdateActivity.Kind);
6162
yield return new DeclarativeType<OnHandoffActivity>(OnHandoffActivity.Kind);
6263
yield return new DeclarativeType<OnChooseIntent>(OnChooseIntent.Kind);
6364
yield return new DeclarativeType<OnQnAMatch>(OnQnAMatch.Kind);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema",
3+
"$role": [ "implements(Microsoft.ITrigger)", "extends(Microsoft.OnCondition)" ],
4+
"title": "On InstallationUpdate activity",
5+
"description": "Actions to perform on receipt of an activity with type 'InstallationUpdate'.",
6+
"type": "object",
7+
"required": [
8+
"actions"
9+
]
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://schemas.botframework.com/schemas/ui/v1.0/ui.schema",
3+
"form": {
4+
"order": [
5+
"condition",
6+
"*"
7+
],
8+
"hidden": [
9+
"actions"
10+
],
11+
"label": "Installation updated",
12+
"subtitle": "Installation updated activity"
13+
}
14+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed under the MIT License.
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
4+
using System.Collections.Generic;
5+
using System.Runtime.CompilerServices;
6+
using Microsoft.Bot.Schema;
7+
using Newtonsoft.Json;
8+
9+
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Conditions
10+
{
11+
/// <summary>
12+
/// Actions triggered when a InstallationUpdateActivity is received.
13+
/// </summary>
14+
public class OnInstallationUpdateActivity : OnActivity
15+
{
16+
[JsonProperty("$kind")]
17+
public new const string Kind = "Microsoft.OnInstallationUpdateActivity";
18+
19+
[JsonConstructor]
20+
public OnInstallationUpdateActivity(List<Dialog> actions = null, string condition = null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
21+
: base(type: ActivityTypes.InstallationUpdate, actions: actions, condition: condition, callerPath: callerPath, callerLine: callerLine)
22+
{
23+
}
24+
}
25+
}

tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ConditionalsTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ public void OnConditionWithCondition()
7575
},
7676
$"((turn.activity.type == '{ActivityTypes.Typing}') && ((turn.dialogEvent.name == '{AdaptiveEvents.ActivityReceived}') && (turn.test == 1)))");
7777

78+
AssertExpression(
79+
new OnInstallationUpdateActivity()
80+
{
81+
Condition = "turn.test == 1"
82+
},
83+
$"((turn.activity.type == '{ActivityTypes.InstallationUpdate}') && ((turn.dialogEvent.name == '{AdaptiveEvents.ActivityReceived}') && (turn.test == 1)))");
84+
7885
AssertExpression(
7986
new OnEndOfConversationActivity()
8087
{

tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ConditionalsTests/ConditionalsTests_OnActivityTypes.test.dialog

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
}
4646
]
4747
},
48+
{
49+
"$kind": "Microsoft.OnInstallationUpdateActivity",
50+
"condition": "turn.activity.text == 'OnInstallationUpdateActivity'",
51+
"actions": [
52+
{
53+
"$kind": "Microsoft.SendActivity",
54+
"activity": "OnInstallationUpdateActivity"
55+
}
56+
]
57+
},
4858
{
4959
"$kind": "Microsoft.OnEndOfConversationActivity",
5060
"condition": "turn.activity.text == 'OnEndOfConversationActivity'",
@@ -165,6 +175,17 @@
165175
"$kind": "Microsoft.Test.AssertReply",
166176
"text": "OnTypingActivity"
167177
},
178+
{
179+
"$kind": "Microsoft.Test.UserActivity",
180+
"activity": {
181+
"type": "installationUpdate",
182+
"text": "OnInstallationUpdateActivity"
183+
}
184+
},
185+
{
186+
"$kind": "Microsoft.Test.AssertReply",
187+
"text": "OnInstallationUpdateActivity"
188+
},
168189
{
169190
"$kind": "Microsoft.Test.UserActivity",
170191
"activity": {

tests/tests.schema

Lines changed: 90 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@
211211
{
212212
"$ref": "#/definitions/Microsoft.OnHandoffActivity"
213213
},
214+
{
215+
"$ref": "#/definitions/Microsoft.OnInstallationUpdateActivity"
216+
},
214217
{
215218
"$ref": "#/definitions/Microsoft.OnIntent"
216219
},
@@ -3844,10 +3847,10 @@
38443847
"type": "string"
38453848
},
38463849
{
3847-
"$ref": "#/definitions/Microsoft.OrchestratorRecognizer"
3850+
"$ref": "#/definitions/Microsoft.OrchestratorRecognizer"
38483851
},
38493852
{
3850-
"$ref": "#/definitions/Microsoft.LuisRecognizer"
3853+
"$ref": "#/definitions/Microsoft.LuisRecognizer"
38513854
},
38523855
{
38533856
"$ref": "#/definitions/Microsoft.QnAMakerRecognizer"
@@ -3937,6 +3940,9 @@
39373940
{
39383941
"$ref": "#/definitions/Microsoft.OnHandoffActivity"
39393942
},
3943+
{
3944+
"$ref": "#/definitions/Microsoft.OnInstallationUpdateActivity"
3945+
},
39403946
{
39413947
"$ref": "#/definitions/Microsoft.OnIntent"
39423948
},
@@ -6126,6 +6132,71 @@
61266132
}
61276133
}
61286134
},
6135+
"Microsoft.OnInstallationUpdateActivity": {
6136+
"$role": [
6137+
"implements(Microsoft.ITrigger)",
6138+
"extends(Microsoft.OnCondition)"
6139+
],
6140+
"title": "On InstallationUpdate activity",
6141+
"description": "Actions to perform on receipt of an activity with type 'InstallationUpdate'.",
6142+
"type": "object",
6143+
"required": [
6144+
"actions",
6145+
"$kind"
6146+
],
6147+
"additionalProperties": false,
6148+
"patternProperties": {
6149+
"^\\$": {
6150+
"title": "Tooling property",
6151+
"description": "Open ended property for tooling."
6152+
}
6153+
},
6154+
"properties": {
6155+
"condition": {
6156+
"$ref": "#/definitions/condition",
6157+
"title": "Condition",
6158+
"description": "Condition (expression).",
6159+
"examples": [
6160+
"user.vip == true"
6161+
]
6162+
},
6163+
"actions": {
6164+
"type": "array",
6165+
"title": "Actions",
6166+
"description": "Sequence of actions to execute.",
6167+
"items": {
6168+
"$kind": "Microsoft.IDialog",
6169+
"$ref": "#/definitions/Microsoft.IDialog"
6170+
}
6171+
},
6172+
"priority": {
6173+
"$ref": "#/definitions/integerExpression",
6174+
"title": "Priority",
6175+
"description": "Priority for trigger with 0 being the highest and < 0 ignored."
6176+
},
6177+
"runOnce": {
6178+
"$ref": "#/definitions/booleanExpression",
6179+
"title": "Run Once",
6180+
"description": "True if rule should run once per unique conditions",
6181+
"examples": [
6182+
true,
6183+
"=f(x)"
6184+
]
6185+
},
6186+
"$kind": {
6187+
"title": "Kind of dialog object",
6188+
"description": "Defines the valid properties for the component you are configuring (from a dialog .schema file)",
6189+
"type": "string",
6190+
"pattern": "^[a-zA-Z][a-zA-Z0-9.]*$",
6191+
"const": "Microsoft.OnInstallationUpdateActivity"
6192+
},
6193+
"$designer": {
6194+
"title": "Designer information",
6195+
"type": "object",
6196+
"description": "Extra information for the Bot Framework Composer."
6197+
}
6198+
}
6199+
},
61296200
"Microsoft.OnIntent": {
61306201
"$role": [
61316202
"implements(Microsoft.ITrigger)",
@@ -7090,23 +7161,23 @@
70907161
]
70917162
},
70927163
"strictFiltersCompoundOperationType": {
7093-
"$ref": "#/definitions/stringExpression",
7094-
"title": "StrictFiltersCompoundOperationType",
7095-
"description": "Join operator for Strict Filters.",
7096-
"oneOf": [
7097-
{
7098-
"title": "StrictFilters CompoundOperation Type",
7099-
"description": "Value of Join Operator to be used as Conjunction with Strict Filter Value.",
7100-
"enum": [
7101-
"AND",
7102-
"OR"
7103-
],
7104-
"default": "AND"
7105-
},
7106-
{
7107-
"$ref": "#/definitions/equalsExpression"
7108-
}
7109-
]
7164+
"$ref": "#/definitions/stringExpression",
7165+
"title": "strictFiltersCompoundOperationType",
7166+
"description": "Join operator for Strict Filters.",
7167+
"oneOf": [
7168+
{
7169+
"title": "StrictFilters CompoundOperation Type",
7170+
"description": "Value of Join Operator to be used as Conjunction with Strict Filter Value.",
7171+
"enum": [
7172+
"AND",
7173+
"OR"
7174+
],
7175+
"default": "AND"
7176+
},
7177+
{
7178+
"$ref": "#/definitions/equalsExpression"
7179+
}
7180+
]
71107181
},
71117182
"$kind": {
71127183
"title": "Kind of dialog object",

tests/tests.uischema

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,19 @@
446446
"subtitle": "Handoff activity"
447447
}
448448
},
449+
"Microsoft.OnInstallationUpdateActivity": {
450+
"form": {
451+
"hidden": [
452+
"actions"
453+
],
454+
"label": "Installation updated",
455+
"order": [
456+
"condition",
457+
"*"
458+
],
459+
"subtitle": "Installation updated activity"
460+
}
461+
},
449462
"Microsoft.OnIntent": {
450463
"form": {
451464
"hidden": [

0 commit comments

Comments
 (0)