Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update OnConversationUpdate actions #1794

Merged
merged 6 commits into from
Dec 30, 2019
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
50 changes: 34 additions & 16 deletions Composer/packages/lib/shared/src/dialogFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { appschema } from './appschema';
import { copyAdaptiveAction } from './copyUtils';
import { deleteAdaptiveAction, deleteAdaptiveActionList } from './deleteUtils';
import { MicrosoftIDialog } from './types';

import { SDKTypes } from './types';
interface DesignerAttributes {
name: string;
description: string;
Expand All @@ -23,30 +23,48 @@ const initialInputDialog = {
};

const initialDialogShape = {
'Microsoft.AdaptiveDialog': {
$type: 'Microsoft.AdaptiveDialog',
[SDKTypes.AdaptiveDialog]: {
$type: SDKTypes.AdaptiveDialog,
triggers: [
{
$type: 'Microsoft.OnBeginDialog',
$designer: {
name: 'BeginDialog',
},
$type: SDKTypes.OnBeginDialog,
...getNewDesigner('BeginDialog', ''),
},
],
},
'Microsoft.OnConversationUpdateActivity': {
[SDKTypes.OnConversationUpdateActivity]: {
$type: 'Microsoft.OnConversationUpdateActivity',
condition: "toLower(turn.Activity.membersAdded[0].name) != 'bot'",
actions: [
{
$type: SDKTypes.Foreach,
...getNewDesigner('Loop: for each item', ''),
itemsProperty: 'turn.Activity.membersAdded',
actions: [
{
$type: SDKTypes.IfCondition,
...getNewDesigner('Branch: if/else', ''),
condition: 'string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)',
actions: [
{
$type: SDKTypes.SendActivity,
...getNewDesigner('Send a response', ''),
activity: '',
},
],
},
],
},
],
},
'Microsoft.SendActivity': {
[SDKTypes.SendActivity]: {
activity: '',
},
'Microsoft.AttachmentInput': initialInputDialog,
'Microsoft.ChoiceInput': initialInputDialog,
'Microsoft.ConfirmInput': initialInputDialog,
'Microsoft.DateTimeInput': initialInputDialog,
'Microsoft.NumberInput': initialInputDialog,
'Microsoft.TextInput': initialInputDialog,
[SDKTypes.AttachmentInput]: initialInputDialog,
[SDKTypes.ChoiceInput]: initialInputDialog,
[SDKTypes.ConfirmInput]: initialInputDialog,
[SDKTypes.DateTimeInput]: initialInputDialog,
[SDKTypes.NumberInput]: initialInputDialog,
[SDKTypes.TextInput]: initialInputDialog,
};

export function getNewDesigner(name: string, description: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,34 @@
"name": "Greeting (ConversationUpdate)",
"id": "954390"
},
"constraint": "toLower(turn.Activity.membersAdded[0].name) != 'bot'",
"actions": [
{
"$type": "Microsoft.SendActivity",
"$type": "Microsoft.Foreach",
"$designer": {
"id": "640616"
"id": "518944",
"name": "Loop: for each item"
},
"activity": "@{bfdactivity-640616()}"
"itemsProperty": "turn.Activity.membersAdded",
"actions": [
{
"$type": "Microsoft.IfCondition",
"$designer": {
"id": "641773",
"name": "Branch: if/else"
},
"condition": "string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)",
"actions": [
{
"$type": "Microsoft.SendActivity",
"$designer": {
"id": "640616",
"name": "Send a response"
},
"activity": "@{bfdactivity-640616()}"
}
]
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"unrecognizedPrompt": "I need a yes or no.",
"maxTurnCount": 3,
"alwaysPrompt": true,
"allowInterruptions": false,
"allowInterruptions": "false",
"defaultLocale": "en-us",
"style": "Auto",
"choiceOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"invalidPrompt": "Please enter a date.",
"maxTurnCount": 2,
"alwaysPrompt": true,
"allowInterruptions": false,
"allowInterruptions": "false",
"defaultLocale": "en-us"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,32 @@
"triggers": [
{
"$type": "Microsoft.OnConversationUpdateActivity",
"condition": "toLower(turn.Activity.membersAdded[0].name) != 'bot'",
"actions": [
{
"$type": "Microsoft.SendActivity",
"activity": "@{help()}"
"$type": "Microsoft.Foreach",
"$designer": {
"id": "518944",
"name": "Loop: for each item"
},
"itemsProperty": "turn.Activity.membersAdded",
"actions": [
{
"$type": "Microsoft.IfCondition",
"$designer": {
"id": "641773",
"name": "Branch: if/else"
},
"condition": "string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)",
"actions": [
{
"$type": "Microsoft.SendActivity",
"activity": "@{help()}"
}
]
}
]
}
],
"$designer": {
"id": "690456"
}
]
},
{
"$type": "Microsoft.OnIntent",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"invalidPrompt": "Please input a number.",
"maxTurnCount": 2,
"alwaysPrompt": true,
"allowInterruptions": false,
"allowInterruptions": "false",
"defaultLocale": "en-us"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,34 @@
"name": "Greeting (ConversationUpdate)",
"id": "791275"
},
"condition": "toLower(turn.Activity.membersAdded[0].name) != 'bot'",
"actions": [
{
"$type": "Microsoft.SendActivity",
"$type": "Microsoft.Foreach",
"$designer": {
"name": "Send an Activity",
"id": "859266"
"id": "518944",
"name": "Loop: for each item"
},
"activity": "@{help()}"
"itemsProperty": "turn.Activity.membersAdded",
"actions": [
{
"$type": "Microsoft.IfCondition",
"$designer": {
"id": "641773",
"name": "Branch: if/else"
},
"condition": "string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)",
"actions": [
{
"$type": "Microsoft.SendActivity",
"$designer": {
"id": "859266",
"name": "Send a response"
},
"activity": "@{help()}"
}
]
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"unrecognizedPrompt": "I need a yes or no.",
"maxTurnCount": 3,
"alwaysPrompt": true,
"allowInterruptions": false,
"allowInterruptions": "false",
"defaultLocale": "en-us",
"style": "Auto",
"choiceOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,26 @@
"$designer": {
"id": "376720"
},
"condition": "toLower(turn.Activity.membersAdded[0].name) != 'bot'"
"actions": [
{
"$type": "Microsoft.Foreach",
"$designer": {
"id": "518944",
"name": "Loop: for each item"
},
"itemsProperty": "turn.Activity.membersAdded",
"actions": [
{
"$type": "Microsoft.IfCondition",
"$designer": {
"id": "641773",
"name": "Branch: if/else"
},
"condition": "string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)"
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,32 @@
"description": "<Fill in the description of your bot here>"
},
"generator": "common.lg",
"recognizer": "Main.lu",
"triggers": [
{
"$type": "Microsoft.OnConversationUpdateActivity",
"$designer": {
"id": "376720"
},
"condition": "toLower(turn.Activity.membersAdded[0].name) != 'bot'"
"actions": [
{
"$type": "Microsoft.Foreach",
"$designer": {
"id": "518944",
"name": "Loop: for each item"
},
"itemsProperty": "turn.Activity.membersAdded",
"actions": [
{
"$type": "Microsoft.IfCondition",
"$designer": {
"id": "641773",
"name": "Branch: if/else"
},
"condition": "string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)"
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,34 @@
"id": "376720",
"name": "Welcome user"
},
"condition": "toLower(turn.Activity.membersAdded[0].name) != 'bot'",
"actions": [
{
"$type": "Microsoft.SendActivity",
"$type": "Microsoft.Foreach",
"$designer": {
"name": "Send an Activity",
"id": "753396"
"id": "518944",
"name": "Loop: for each item"
},
"activity": "@{bfdactivity-753396()}"
"itemsProperty": "turn.Activity.membersAdded",
"actions": [
{
"$type": "Microsoft.IfCondition",
"$designer": {
"id": "641773",
"name": "Branch: if/else"
},
"condition": "string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)",
"actions": [
{
"$type": "Microsoft.SendActivity",
"$designer": {
"id": "753396",
"name": "Send a response"
},
"activity": "@{bfdactivity-753396()}"
}
]
}
]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,34 @@
"id": "376720",
"name": "Welcome message"
},
"condition": "toLower(turn.Activity.membersAdded[0].name) != 'bot'",
"actions": [
{
"$type": "Microsoft.SendActivity",
"$type": "Microsoft.Foreach",
"$designer": {
"id": "266608",
"name": "Send a response"
"id": "518944",
"name": "Loop: for each item"
},
"activity": "@{bfdactivity-266608()}"
"itemsProperty": "turn.Activity.membersAdded",
"actions": [
{
"$type": "Microsoft.IfCondition",
"$designer": {
"id": "641773",
"name": "Branch: if/else"
},
"condition": "string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)",
"actions": [
{
"$type": "Microsoft.SendActivity",
"$designer": {
"id": "266608",
"name": "Send a response"
},
"activity": "@{bfdactivity-266608()}"
}
]
}
]
}
]
},
Expand Down
Loading