diff --git a/CSharp/demo-ContosoFlowers/ContosoFlowers/Dialogs/RootDialog.cs b/CSharp/demo-ContosoFlowers/ContosoFlowers/Dialogs/RootDialog.cs index 174145fd9e..62484b53e5 100644 --- a/CSharp/demo-ContosoFlowers/ContosoFlowers/Dialogs/RootDialog.cs +++ b/CSharp/demo-ContosoFlowers/ContosoFlowers/Dialogs/RootDialog.cs @@ -77,7 +77,7 @@ private async Task OnOptionSelected(IDialogContext context, IAwaitable(string.Format(CultureInfo.CurrentCulture, Resources.RootDialog_DeliveryAddress_Prompt, message.From.Name)); + var addressDialog = this.dialogFactory.Create(string.Format(CultureInfo.CurrentCulture, Resources.RootDialog_DeliveryAddress_Prompt, message.From.Name ?? "User")); context.Call(addressDialog, this.AfterDeliveryAddress); } else if (message.Text == Resources.RootDialog_Welcome_Support) diff --git a/CSharp/demo-Search/JobListingBot/azuredeploy.json b/CSharp/demo-Search/JobListingBot/azuredeploy.json index 979b7cc066..e7db4259b2 100644 --- a/CSharp/demo-Search/JobListingBot/azuredeploy.json +++ b/CSharp/demo-Search/JobListingBot/azuredeploy.json @@ -46,18 +46,6 @@ }, "MicrosoftAppPassword": { "type": "string" - }, - "SearchDialogsServiceName": { - "type": "string", - "defaultValue": "azs-playground" - }, - "SearchDialogsServiceKey": { - "type": "string", - "defaultValue": "512C4FBA9EED64A31A1052CFE3F7D3DB" - }, - "SearchDialogsIndexName": { - "type": "string", - "defaultValue": "nycjobs" } }, "resources": [ @@ -109,10 +97,6 @@ { "name": "MicrosoftAppPassword", "value": "[parameters('MicrosoftAppPassword')]" - }, - { - "name": "MicrosoftBingMapsKey", - "value": "[parameters('MicrosoftBingMapsKey')]" } ] } diff --git a/CSharp/demo-Search/RealEstateBot/azuredeploy.json b/CSharp/demo-Search/RealEstateBot/azuredeploy.json index 6e4d944ddc..d2fe2985fa 100644 --- a/CSharp/demo-Search/RealEstateBot/azuredeploy.json +++ b/CSharp/demo-Search/RealEstateBot/azuredeploy.json @@ -46,18 +46,6 @@ }, "MicrosoftAppPassword": { "type": "string" - }, - "SearchDialogsServiceName": { - "type": "string", - "defaultValue": "realestate" - }, - "SearchDialogsServiceKey": { - "type": "string", - "defaultValue": "82BCF03D2FC9AC7F4E9D7DE1DF3618A5" - }, - "SearchDialogsIndexName": { - "type": "string", - "defaultValue": "listings" } }, "resources": [ @@ -109,10 +97,6 @@ { "name": "MicrosoftAppPassword", "value": "[parameters('MicrosoftAppPassword')]" - }, - { - "name": "MicrosoftBingMapsKey", - "value": "[parameters('MicrosoftBingMapsKey')]" } ] } diff --git a/Node/core-CreateNewConversation/README.md b/Node/core-CreateNewConversation/README.md index b428478928..02e4cc559a 100644 --- a/Node/core-CreateNewConversation/README.md +++ b/Node/core-CreateNewConversation/README.md @@ -21,15 +21,8 @@ Any current conversation between the bot and user will be replaced with a new di Alternatively, [bot.send()](https://docs.botframework.com/en-us/node/builder/chat-reference/classes/_botbuilder_d_.universalbot.html#send) can be used to send a message without starting a dialog. ````JavaScript -// minimal information copied from the address of a previous message -// this is the obj we should persist if we want to create a new conversation anytime later -var address = { - channelId: msg.address.channelId, - serviceUrl: msg.address.serviceUrl, - user: msg.address.user, - bot: msg.address.bot, - useAuth: true -}; +// this is the object we should persist if we want to create a new conversation anytime later +var address = session.message.address; // then... on another scope diff --git a/Node/core-CreateNewConversation/app.js b/Node/core-CreateNewConversation/app.js index e0c8d22af7..dccd821405 100644 --- a/Node/core-CreateNewConversation/app.js +++ b/Node/core-CreateNewConversation/app.js @@ -34,18 +34,7 @@ bot.dialog('/', function (session) { var msg = session.message; // store user's address - - // minimal information copied from the address of a previous message - // we should persist this object if we want to create a new conversation anytime later - var address = { - channelId: msg.address.channelId, - serviceUrl: msg.address.serviceUrl, - user: msg.address.user, - bot: msg.address.bot, - useAuth: true - }; - - // store address + var address = msg.address; userStore.push(address); // end current dialog diff --git a/Node/core-DirectLine/DirectLineClient/app.js b/Node/core-DirectLine/DirectLineClient/app.js index 35ca3b518b..5bccf17360 100644 --- a/Node/core-DirectLine/DirectLineClient/app.js +++ b/Node/core-DirectLine/DirectLineClient/app.js @@ -88,7 +88,10 @@ function printMessages(messages) { } function printMessage(message) { - console.log(message.text); + if(message.text) { + console.log(message.text); + } + if (message.channelData) { switch (message.channelData.contentType) { case "application/vnd.microsoft.card.hero": diff --git a/Node/core-GetConversationMembers/app.js b/Node/core-GetConversationMembers/app.js index 831cecaa9f..7badb67ec8 100644 --- a/Node/core-GetConversationMembers/app.js +++ b/Node/core-GetConversationMembers/app.js @@ -27,57 +27,52 @@ var connectorApiClient = new Swagger( bot.on('conversationUpdate', function (message) { - if (message.address.conversation.isGroup) { - - if (message.membersAdded) { - var membersAdded = message.membersAdded - .map((m) => { - var isSelf = m.id === message.address.bot.id; - return (isSelf ? message.address.bot.name : m.name) + ' (Id: ' + m.id + ')'; - }) - .join(', '); - - var reply = new builder.Message() - .address(message.address) - .text('Welcome ' + membersAdded); - bot.send(reply); - } - - if (message.membersRemoved) { - var membersRemoved = message.membersRemoved - .map((m) => { - var isSelf = m.id === message.address.bot.id; - return (isSelf ? message.address.bot.name : m.name) + ' (Id: ' + m.id + ')'; - }) - .join(', '); + if (message.membersAdded && message.membersAdded.length > 0) { + var membersAdded = message.membersAdded + .map((m) => { + var isSelf = m.id === message.address.bot.id; + return (isSelf ? message.address.bot.name : m.name) || '' + ' (Id: ' + m.id + ')'; + }) + .join(', '); + + var reply = new builder.Message() + .address(message.address) + .text('Welcome ' + membersAdded); + bot.send(reply); + } - var reply = new builder.Message() - .address(message.address) - .text('The following members ' + membersRemoved + ' were removed or left the conversation :('); - bot.send(reply); - } + if (message.membersRemoved && message.membersRemoved.length > 0) { + var membersRemoved = message.membersRemoved + .map((m) => { + var isSelf = m.id === message.address.bot.id; + return (isSelf ? message.address.bot.name : m.name) || '' + ' (Id: ' + m.id + ')'; + }) + .join(', '); + + var reply = new builder.Message() + .address(message.address) + .text('The following members ' + membersRemoved + ' were removed or left the conversation :('); + bot.send(reply); } }); bot.dialog('/', function (session) { var message = session.message; - if (message.address.conversation.isGroup) { - var conversationId = message.address.conversation.id; - - // when a group conversation message is recieved, - // get the conversation members using the REST API and print it on the conversation. - - // 1. inject the JWT from the connector to the client on every call - addTokenToClient(connector, connectorApiClient).then((client) => { - // 2. override API client host (api.botframework.com) with channel's serviceHost (e.g.: slack.botframework.com) - var serviceHost = url.parse(message.address.serviceUrl).host; - client.setHost(serviceHost); - // 3. GET /v3/conversations/{conversationId}/members - client.Conversations.Conversations_GetConversationMembers({ conversationId: conversationId }) - .then((res) => printMembersInChannel(message.address, res.obj)) - .catch((error) => console.log('Error retrieving conversation members: ' + error.statusText)); - }); - } + var conversationId = message.address.conversation.id; + + // when a group conversation message is recieved, + // get the conversation members using the REST API and print it on the conversation. + + // 1. inject the JWT from the connector to the client on every call + addTokenToClient(connector, connectorApiClient).then((client) => { + // 2. override API client host (api.botframework.com) with channel's serviceHost (e.g.: slack.botframework.com) + var serviceHost = url.parse(message.address.serviceUrl).host; + client.setHost(serviceHost); + // 3. GET /v3/conversations/{conversationId}/members + client.Conversations.Conversations_GetConversationMembers({ conversationId: conversationId }) + .then((res) => printMembersInChannel(message.address, res.obj)) + .catch((error) => console.log('Error retrieving conversation members: ' + error.statusText)); + }); }); // Helper methods @@ -96,6 +91,8 @@ function addTokenToClient(connector, clientPromise) { // Create a message with the member list and send it to the conversationAddress function printMembersInChannel(conversationAddress, members) { + if(!members || members.length == 0) return; + var memberList = members.map((m) => '* ' + m.name + ' (Id: ' + m.id + ')') .join('\n '); diff --git a/Node/demo-ContosoFlowers/bot/dialogs/shop.js b/Node/demo-ContosoFlowers/bot/dialogs/shop.js index 530b858be2..0b857f01d6 100644 --- a/Node/demo-ContosoFlowers/bot/dialogs/shop.js +++ b/Node/demo-ContosoFlowers/bot/dialogs/shop.js @@ -7,7 +7,7 @@ library.dialog('/', [ // Ask for delivery address using 'address' library session.beginDialog('address:/', { - promptMessage: util.format('%s, please enter the delivery address for these flowers. Include apartment # if needed.', session.message.user.name) + promptMessage: util.format('%s, please enter the delivery address for these flowers. Include apartment # if needed.', session.message.user.name || "User") }); }, function (session, args) { diff --git a/Node/demo-ContosoFlowers/bot/utils.js b/Node/demo-ContosoFlowers/bot/utils.js index 8857f9029e..32bae2a11e 100644 --- a/Node/demo-ContosoFlowers/bot/utils.js +++ b/Node/demo-ContosoFlowers/bot/utils.js @@ -3,14 +3,6 @@ var algo = 'aes-256-ctr'; var password = 'itsasecret!'; function serializeAddress(address) { - var addressCore = { - channelId: address.channelId, - serviceUrl: address.serviceUrl, - user: address.user, - bot: address.bot, - useAuth: true - }; - return JSON.stringify(address); } diff --git a/Node/demo-Search/JobListingBot/.vscode/launch.json b/Node/demo-Search/.vscode/launch.json similarity index 100% rename from Node/demo-Search/JobListingBot/.vscode/launch.json rename to Node/demo-Search/.vscode/launch.json diff --git a/Node/demo-Search/README.md b/Node/demo-Search/README.md index efc24f1ff1..d50b4ec8b5 100644 --- a/Node/demo-Search/README.md +++ b/Node/demo-Search/README.md @@ -7,14 +7,9 @@ These samples illustrate how to approach dialogs that need to help the user navi Content is modeled as a catalog of items where each item has several attributes that may be used for navigation, keyword search or display. -| Real Estate Sample | Job Listing Sample| -|--------------------|-------------------| -|[![Deploy to Azure][Deploy Button]][Deploy Node/Search/RealEstateBot]|[![Deploy to Azure][Deploy Button]][Deploy Node/Search/JobListingBot]| - - +[![Deploy to Azure][Deploy Button]][Deploy Search/Node] [Deploy Button]: https://azuredeploy.net/deploybutton.png -[Deploy Node/Search/RealEstateBot]: https://azuredeploy.net/?repository=https://github.com/microsoft/BotBuilder-Samples/tree/master/Node/demo-Search/RealEstateBot -[Deploy Node/Search/JobListingBot]: https://azuredeploy.net/?repository=https://github.com/microsoft/BotBuilder-Samples/tree/master/Node/demo-Search/JobListingBot +[Deploy Search/Node]: https://azuredeploy.net ### Prerequisites diff --git a/Node/demo-Search/RealEstateBot/.vscode/launch.json b/Node/demo-Search/RealEstateBot/.vscode/launch.json deleted file mode 100644 index 2735658711..0000000000 --- a/Node/demo-Search/RealEstateBot/.vscode/launch.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Launch", - "type": "node", - "request": "launch", - "program": "${workspaceRoot}/app.js", - "stopOnEntry": false, - "args": [], - "cwd": "${workspaceRoot}", - "preLaunchTask": null, - "runtimeExecutable": null, - "runtimeArgs": [ - "--nolazy" - ], - "env": { - "NODE_ENV": "development", - "MICROSOFT_APP_ID": "", - "MICROSOFT_APP_PASSWORD": "" - }, - "externalConsole": false, - "sourceMaps": false, - "outDir": null - } - ] -} \ No newline at end of file diff --git a/Node/demo-Search/RealEstateBot/azuredeploy.json b/Node/demo-Search/RealEstateBot/azuredeploy.json deleted file mode 100644 index a2b6b7fb79..0000000000 --- a/Node/demo-Search/RealEstateBot/azuredeploy.json +++ /dev/null @@ -1,129 +0,0 @@ -{ - "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "siteName": { - "defaultValue": "BotBuilder-Samples", - "type": "string" - }, - "hostingPlanName": { - "type": "string" - }, - "siteLocation": { - "type": "string" - }, - "sku": { - "type": "string", - "allowedValues": [ - "Free", - "Shared", - "Basic", - "Standard" - ], - "defaultValue": "Free" - }, - "workerSize": { - "type": "string", - "allowedValues": [ - "0", - "1", - "2" - ], - "defaultValue": "0" - }, - "repoUrl": { - "type": "string" - }, - "branch": { - "type": "string" - }, - "Project": { - "type": "string", - "defaultValue": "Node/demo-Search/RealEstateBot" - }, - "WEBSITE_NODE_DEFAULT_VERSION": { - "type": "string", - "defaultValue": "5.9.1" - }, - "MICROSOFT_APP_ID": { - "type": "string" - }, - "MICROSOFT_APP_PASSWORD": { - "type": "string" - } - }, - "resources": [ - { - "apiVersion": "2014-06-01", - "name": "[parameters('hostingPlanName')]", - "type": "Microsoft.Web/serverFarms", - "location": "[parameters('siteLocation')]", - "properties": { - "name": "[parameters('hostingPlanName')]", - "sku": "[parameters('sku')]", - "workerSize": "[parameters('workerSize')]", - "numberOfWorkers": 1 - } - }, - { - "apiVersion": "2014-06-01", - "name": "[parameters('siteName')]", - "type": "Microsoft.Web/Sites", - "location": "[parameters('siteLocation')]", - "dependsOn": [ - "[concat('Microsoft.Web/serverFarms/', parameters('hostingPlanName'))]" - ], - "tags": { - "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "empty" - }, - "properties": { - "name": "[parameters('siteName')]", - "serverFarm": "[parameters('hostingPlanName')]" - }, - "resources": [ - { - "apiVersion": "2014-04-01", - "type": "config", - "name": "web", - "dependsOn": [ - "[concat('Microsoft.Web/Sites/', parameters('siteName'))]" - ], - "properties": { - "appSettings": [ - { - "name": "Project", - "value": "[parameters('Project')]" - }, - { - "name": "WEBSITE_NODE_DEFAULT_VERSION", - "value": "[parameters('WEBSITE_NODE_DEFAULT_VERSION')]" - }, - { - "name": "MICROSOFT_APP_ID", - "value": "[parameters('MICROSOFT_APP_ID')]" - }, - { - "name": "MICROSOFT_APP_PASSWORD", - "value": "[parameters('MICROSOFT_APP_PASSWORD')]" - } - ] - } - }, - { - "apiVersion": "2014-04-01", - "name": "web", - "type": "sourcecontrols", - "dependsOn": [ - "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]", - "[concat('Microsoft.Web/Sites/', parameters('siteName'), '/config/web')]" - ], - "properties": { - "RepoUrl": "[parameters('repoUrl')]", - "branch": "[parameters('branch')]", - "IsManualIntegration": true - } - } - ] - } - ] -} \ No newline at end of file diff --git a/Node/demo-Search/app.js b/Node/demo-Search/app.js new file mode 100644 index 0000000000..4aa65f9cee --- /dev/null +++ b/Node/demo-Search/app.js @@ -0,0 +1,5 @@ +// This startup file is meant to be used only when deploying any of the samples to an Azure Website + +var botName = process.env.BOT || 'RealEstateBot'; +var botModule = './' + botName + '/app'; +require(botModule); \ No newline at end of file diff --git a/Node/demo-Search/JobListingBot/azuredeploy.json b/Node/demo-Search/azuredeploy.json similarity index 92% rename from Node/demo-Search/JobListingBot/azuredeploy.json rename to Node/demo-Search/azuredeploy.json index fdd229e9e6..51f688cb5c 100644 --- a/Node/demo-Search/JobListingBot/azuredeploy.json +++ b/Node/demo-Search/azuredeploy.json @@ -39,7 +39,14 @@ }, "Project": { "type": "string", - "defaultValue": "Node/demo-Search/JobListingBot" + "defaultValue": "Node/demo-Search/" + }, + "BOT": { + "type": "string", + "allowedValues": [ + "RealEstateBot", + "JobListingBot" + ] }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", @@ -105,6 +112,10 @@ { "name": "MICROSOFT_APP_PASSWORD", "value": "[parameters('MICROSOFT_APP_PASSWORD')]" + }, + { + "name": "BOT", + "value": "[parameters('BOT')]" } ] }