diff --git a/CSharp/cards-CarouselCards/CarouselCardsDialog.cs b/CSharp/cards-CarouselCards/CarouselCardsDialog.cs index 596eb70bc1..aacc4b9a29 100644 --- a/CSharp/cards-CarouselCards/CarouselCardsDialog.cs +++ b/CSharp/cards-CarouselCards/CarouselCardsDialog.cs @@ -34,7 +34,7 @@ private static IList GetCardsAttachments() "Azure Storage", "Offload the heavy lifting of data center management", "Store and help protect your data. Get durable, highly available data storage across the globe and pay only for what you use.", - new CardImage(url: "https://docs.microsoft.com/en-us/azure/storage/media/storage-introduction/storage-concepts.png"), + new CardImage(url: "https://docs.microsoft.com/en-us/aspnet/aspnet/overview/developing-apps-with-windows-azure/building-real-world-cloud-apps-with-windows-azure/data-storage-options/_static/image5.png"), new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/storage/")), GetThumbnailCard( "DocumentDB", @@ -46,13 +46,13 @@ private static IList GetCardsAttachments() "Azure Functions", "Process events with a serverless code architecture", "An event-based serverless compute experience to accelerate your development. It can scale based on demand and you pay only for the resources you consume.", - new CardImage(url: "https://azurecomcdn.azureedge.net/cvt-5daae9212bb433ad0510fbfbff44121ac7c759adc284d7a43d60dbbf2358a07a/images/page/services/functions/01-develop.png"), + new CardImage(url: "https://msdnshared.blob.core.windows.net/media/2016/09/fsharp-functions2.png"), new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/functions/")), GetThumbnailCard( "Cognitive Services", "Build powerful intelligence into your applications to enable natural and contextual interactions", "Enable natural and contextual interaction with tools that augment users' experiences using the power of machine-based intelligence. Tap into an ever-growing collection of powerful artificial intelligence algorithms for vision, speech, language, and knowledge.", - new CardImage(url: "https://azurecomcdn.azureedge.net/cvt-68b530dac63f0ccae8466a2610289af04bdc67ee0bfbc2d5e526b8efd10af05a/images/page/services/cognitive-services/cognitive-services.png"), + new CardImage(url: "https://msdnshared.blob.core.windows.net/media/2017/03/Azure-Cognitive-Services-e1489079006258.png"), new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/cognitive-services/")), }; } diff --git a/Node/blog-LUISActionBinding/LUIS_MODEL.json b/Node/blog-LUISActionBinding/LUIS_MODEL.json index 7a8df0238f..21155260f4 100644 --- a/Node/blog-LUISActionBinding/LUIS_MODEL.json +++ b/Node/blog-LUISActionBinding/LUIS_MODEL.json @@ -45,13 +45,13 @@ { "name": "Checkin", "children": [ - "datetime" + "datetimev2" ] }, { "name": "Checkout", "children": [ - "datetime" + "datetimev2" ] }, { @@ -63,7 +63,7 @@ ], "closedLists": [], "bing_entities": [ - "datetime", + "datetimev2", "geography" ], "actions": [], diff --git a/Node/blog-LUISActionBinding/core/package.json b/Node/blog-LUISActionBinding/core/package.json index 5056312a2f..125b36bb29 100644 --- a/Node/blog-LUISActionBinding/core/package.json +++ b/Node/blog-LUISActionBinding/core/package.json @@ -21,7 +21,7 @@ }, "dependencies": { "bluebird": "^3.5.0", - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "lodash": "^4.17.4", "schema-inspector": "^1.6.8" } diff --git a/Node/blog-LUISActionBinding/samples/package.json b/Node/blog-LUISActionBinding/samples/package.json index 865dc30e15..8f5355dacd 100644 --- a/Node/blog-LUISActionBinding/samples/package.json +++ b/Node/blog-LUISActionBinding/samples/package.json @@ -5,7 +5,7 @@ "author": "Microsoft Corp.", "license": "MIT", "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "jsonpath": "^0.2.10", "lodash": "^4.17.4", diff --git a/Node/blog-customChannelData/package.json b/Node/blog-customChannelData/package.json index 5c98e0d2b5..a14ad038cf 100644 --- a/Node/blog-customChannelData/package.json +++ b/Node/blog-customChannelData/package.json @@ -4,7 +4,7 @@ "description": "Microsoft Bot Framework bot written in NodeJS to test issues.", "main": "node_bot.js", "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^2.0.0", "express": "^4.14.1", "request-promise": "^4.1.1", diff --git a/Node/capability-SimpleTaskAutomation/README.md b/Node/capability-SimpleTaskAutomation/README.md index c34dcdf0f6..82b6db04c3 100644 --- a/Node/capability-SimpleTaskAutomation/README.md +++ b/Node/capability-SimpleTaskAutomation/README.md @@ -34,7 +34,7 @@ A bots dialogs can be expressed using a variety of forms: Allows for the creation of custom dialogs that are based on a simple closure. This is useful for cases where you want a dynamic conversation flow or you have a situation that just doesn't map very well to using a waterfall. -In this sample we start with a dialog that prompts the user to choose the action the bot must do: +In this sample we start with a dialog that prompts the user to choose the action the bot must do: ````JavaScript const ChangePasswordOption = 'Change Password'; @@ -109,17 +109,24 @@ const PhoneRegex = new RegExp(/^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4 const library = new builder.Library('validators'); library.dialog('phonenumber', - builder.DialogAction.validatedPrompt(builder.PromptType.text, (response) => - PhoneRegex.test(response))); + new builder.IntentDialog() + .onBegin(function (session, args) { + session.dialogData.retryPrompt = args.retryPrompt; + session.send(args.prompt); + }).matches(PhoneRegex, function (session) { + session.endDialogWithResult({ response: session.message.text }); + }).onDefault(function (session) { + session.send(session.dialogData.retryPrompt); + })); module.exports = library; module.exports.PhoneRegex = PhoneRegex; -```` +```` And this is how you can call the validator from your existing code: ````JavaScript -// +// library.dialog('/', [ function (session) { session.beginDialog('validators:phonenumber', { @@ -147,7 +154,7 @@ library.dialog('/', [ > It is worth noting that calling other dialogs within your library don't need to be prefixed with the library's id. It is only when crossing from one library context to another that you need to include the library name prefix on your `session.beginDialog()` calls. -> To limit the times the user will reprompt when the response is not valid, the [maxRetries](https://docs.botframework.com/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.ipromptargs.html#maxretries) can be specified. If the maximum number of retries are reached the next dialog is called with the [args.resumed](https://docs.botframework.com/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.ipromptresult.html#resumed) set in [notCompleted](https://docs.botframework.com/en-us/node/builder/chat-reference/enums/_botbuilder_d_.resumereason.html#notcompleted). +> To limit the times the user will reprompt when the response is not valid, the [maxRetries](https://docs.botframework.com/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.ipromptargs.html#maxretries) can be specified. If the maximum number of retries are reached the next dialog is called with the [args.resumed](https://docs.botframework.com/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.ipromptresult.html#resumed) set in [notCompleted](https://docs.botframework.com/en-us/node/builder/chat-reference/enums/_botbuilder_d_.resumereason.html#notcompleted). The message the bot will send when an no valid user input was received is customizable with the [retryPrompt](https://docs.botframework.com/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.ipromptargs.html#retryprompt). ### Outcome diff --git a/Node/capability-SimpleTaskAutomation/package.json b/Node/capability-SimpleTaskAutomation/package.json index 4a652873c6..4964d074c1 100644 --- a/Node/capability-SimpleTaskAutomation/package.json +++ b/Node/capability-SimpleTaskAutomation/package.json @@ -9,7 +9,7 @@ "author": "", "license": "ISC", "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "restify": "^4.3.0", "uuid": "^3.0.1" }, diff --git a/Node/capability-SimpleTaskAutomation/validators.js b/Node/capability-SimpleTaskAutomation/validators.js index 0b4ced9a33..557a4705d0 100644 --- a/Node/capability-SimpleTaskAutomation/validators.js +++ b/Node/capability-SimpleTaskAutomation/validators.js @@ -5,8 +5,15 @@ const PhoneRegex = new RegExp(/^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4 const library = new builder.Library('validators'); library.dialog('phonenumber', - builder.DialogAction.validatedPrompt(builder.PromptType.text, (response) => - PhoneRegex.test(response))); + new builder.IntentDialog() + .onBegin(function (session, args) { + session.dialogData.retryPrompt = args.retryPrompt; + session.send(args.prompt); + }).matches(PhoneRegex, function (session) { + session.endDialogWithResult({ response: session.message.text }); + }).onDefault(function (session) { + session.send(session.dialogData.retryPrompt); + })); module.exports = library; module.exports.PhoneRegex = PhoneRegex; \ No newline at end of file diff --git a/Node/capability-middlewareLogging/package.json b/Node/capability-middlewareLogging/package.json index 6581c1700c..56573f4e97 100644 --- a/Node/capability-middlewareLogging/package.json +++ b/Node/capability-middlewareLogging/package.json @@ -9,7 +9,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^2.0.0", "restify": "^4.3.0" } diff --git a/Node/cards-AdaptiveCards/package.json b/Node/cards-AdaptiveCards/package.json index e0a99660c3..6098ea964d 100644 --- a/Node/cards-AdaptiveCards/package.json +++ b/Node/cards-AdaptiveCards/package.json @@ -23,7 +23,7 @@ }, "dependencies": { "bluebird": "^3.5.0", - "botbuilder": "^3.8.3", + "botbuilder": "^3.13.1", "dotenv-extended": "^2.0.0", "lodash": "^4.17.4", "restify": "^4.3.0" diff --git a/Node/cards-CarouselCards/app.js b/Node/cards-CarouselCards/app.js index 1535834c28..b5be498f3b 100644 --- a/Node/cards-CarouselCards/app.js +++ b/Node/cards-CarouselCards/app.js @@ -36,7 +36,7 @@ function getCardsAttachments(session) { .subtitle('Offload the heavy lifting of data center management') .text('Store and help protect your data. Get durable, highly available data storage across the globe and pay only for what you use.') .images([ - builder.CardImage.create(session, 'https://docs.microsoft.com/en-us/azure/storage/media/storage-introduction/storage-concepts.png') + builder.CardImage.create(session, 'https://docs.microsoft.com/en-us/aspnet/aspnet/overview/developing-apps-with-windows-azure/building-real-world-cloud-apps-with-windows-azure/data-storage-options/_static/image5.png') ]) .buttons([ builder.CardAction.openUrl(session, 'https://azure.microsoft.com/en-us/services/storage/', 'Learn More') @@ -58,7 +58,7 @@ function getCardsAttachments(session) { .subtitle('Process events with a serverless code architecture') .text('An event-based serverless compute experience to accelerate your development. It can scale based on demand and you pay only for the resources you consume.') .images([ - builder.CardImage.create(session, 'https://azurecomcdn.azureedge.net/cvt-5daae9212bb433ad0510fbfbff44121ac7c759adc284d7a43d60dbbf2358a07a/images/page/services/functions/01-develop.png') + builder.CardImage.create(session, 'https://msdnshared.blob.core.windows.net/media/2016/09/fsharp-functions2.png') ]) .buttons([ builder.CardAction.openUrl(session, 'https://azure.microsoft.com/en-us/services/functions/', 'Learn More') @@ -69,7 +69,7 @@ function getCardsAttachments(session) { .subtitle('Build powerful intelligence into your applications to enable natural and contextual interactions') .text('Enable natural and contextual interaction with tools that augment users\' experiences using the power of machine-based intelligence. Tap into an ever-growing collection of powerful artificial intelligence algorithms for vision, speech, language, and knowledge.') .images([ - builder.CardImage.create(session, 'https://azurecomcdn.azureedge.net/cvt-68b530dac63f0ccae8466a2610289af04bdc67ee0bfbc2d5e526b8efd10af05a/images/page/services/cognitive-services/cognitive-services.png') + builder.CardImage.create(session, 'https://msdnshared.blob.core.windows.net/media/2017/03/Azure-Cognitive-Services-e1489079006258.png') ]) .buttons([ builder.CardAction.openUrl(session, 'https://azure.microsoft.com/en-us/services/cognitive-services/', 'Learn More') diff --git a/Node/cards-CarouselCards/package.json b/Node/cards-CarouselCards/package.json index 3b49ceb662..7ebe3ab483 100644 --- a/Node/cards-CarouselCards/package.json +++ b/Node/cards-CarouselCards/package.json @@ -21,8 +21,8 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", - "restify": "^4.3.0", - "dotenv-extended": "^1.0.4" + "botbuilder": "^3.13.1", + "dotenv-extended": "^1.0.4", + "restify": "^4.3.0" } } diff --git a/Node/cards-RichCards/package.json b/Node/cards-RichCards/package.json index a4ca22462a..20c8cac179 100644 --- a/Node/cards-RichCards/package.json +++ b/Node/cards-RichCards/package.json @@ -21,8 +21,8 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", - "restify": "^4.3.0", - "dotenv-extended": "^1.0.4" + "botbuilder": "^3.13.1", + "dotenv-extended": "^1.0.4", + "restify": "^4.3.0" } } diff --git a/Node/core-AppInsights/app.js b/Node/core-AppInsights/app.js index 031510418c..a28be4d1db 100644 --- a/Node/core-AppInsights/app.js +++ b/Node/core-AppInsights/app.js @@ -8,7 +8,7 @@ var telemetryModule = require('./telemetry-module.js'); var appInsights = require('applicationinsights'); appInsights.setup(process.env.APPINSIGHTS_INSTRUMENTATION_KEY).start(); -var appInsightsClient = appInsights.getClient(); +var appInsightsClient = new appInsights.TelemetryClient(); // Setup Restify Server var server = restify.createServer(); @@ -40,9 +40,9 @@ var bot = new builder.UniversalBot(connector, function (session) { session.send('Welcome to the Search City bot. I\'m currently configured to search for things in %s', session.conversationData[CityKey]); } - appInsightsClient.trackTrace('start', telemetry); + appInsightsClient.trackTrace({ message: 'start', properties: telemetry }); - // is user's name set? + // is user's name set? var userName = session.userData[UserNameKey]; if (!userName) { return session.beginDialog('greet'); @@ -56,11 +56,10 @@ var bot = new builder.UniversalBot(connector, function (session) { } } catch (error) { var exceptionTelemetry = telemetryModule.createTelemetry(session); - exceptionTelemetry.exception = error.toString(); - appInsightsClient.trackException(exceptionTelemetry); + appInsightsClient.trackException({ exception: error, properties: exceptionTelemetry }); } finally { var resumeAfterPromptTelemetry = telemetryModule.createTelemetry(session); - appInsightsClient.trackTrace('resumeAfterPrompt', resumeAfterPromptTelemetry); + appInsightsClient.trackTrace({ message: 'resumeAfterPrompt', properties: resumeAfterPromptTelemetry }); } session.beginDialog('search'); @@ -82,14 +81,13 @@ bot.dialog('search', function (session, args, next) { session.send('%s, wait a few seconds. Searching for \'%s\' in \'%s\'...', userName, messageText, city); session.send('https://www.bing.com/search?q=%s', encodeURIComponent(messageText + ' in ' + city)); } catch (error) { - measuredEventTelemetry.exception = error.toString(); - appInsightsClient.trackException('search', t); + appInsightsClient.trackException({ exception: error, properties: measuredEventTelemetry }); } finally { var timerEnd = process.hrtime(timerStart); measuredEventTelemetry.metrics = (timerEnd[0], timerEnd[1] / 1000000); - appInsightsClient.trackEvent('timeTaken', measuredEventTelemetry); + appInsightsClient.trackEvent({ name: 'timeTaken', properties: measuredEventTelemetry }); } - + session.endDialog(); }); @@ -102,7 +100,7 @@ bot.dialog('reset', function (session) { delete session.privateConversationData[UserWelcomedKey]; var telemetry = telemetryModule.createTelemetry(session); - appInsightsClient.trackEvent('reset', telemetry); + appInsightsClient.trackEvent({ name: 'reset', properties: telemetry }); session.endDialog('Ups... I\'m suffering from a memory loss...'); }).triggerAction({ matches: /^reset/i }); @@ -122,7 +120,7 @@ bot.dialog('printCurrentCity', function (session) { } var telemetry = telemetryModule.createTelemetry(session); - appInsightsClient.trackEvent('current city', telemetry); + appInsightsClient.trackEvent({ name: 'current city', properties: telemetry }); session.endDialog(); }).triggerAction({ matches: /^current city/i }); @@ -135,7 +133,7 @@ bot.dialog('changeCurrentCity', function (session, args) { var userName = session.userData[UserNameKey]; var telemetry = telemetryModule.createTelemetry(session); - appInsightsClient.trackEvent('change city to', telemetry); + appInsightsClient.trackEvent({ name: 'change city to', properties: telemetry }); session.endDialog('All set %s. From now on, all my searches will be for things in %s.', userName, newCity); }).triggerAction({ matches: /^change city to (.*)/i }); @@ -148,7 +146,7 @@ bot.dialog('changeMyCurrentCity', function (session, args) { var userName = session.userData[UserNameKey]; var telemetry = telemetryModule.createTelemetry(session); - appInsightsClient.trackEvent('change my city to', telemetry); + appInsightsClient.trackEvent({ name: 'change my city to', properties: telemetry }); session.endDialog('All set %s. I have overridden the city to %s just for you', userName, newCity); }).triggerAction({ matches: /^change my city to (.*)/i }); @@ -161,7 +159,7 @@ bot.dialog('greet', new builder.SimpleDialog(function (session, results) { var telemetry = telemetryModule.createTelemetry(session); telemetry.userName = results.response; // You can add properties after-the-fact as well - appInsightsClient.trackEvent('new user', telemetry); + appInsightsClient.trackEvent({ name: 'new user', properties: telemetry }); return session.endDialog('Welcome %s! %s', results.response, HelpMessage); } diff --git a/Node/core-AppInsights/package.json b/Node/core-AppInsights/package.json index fb61c6be12..c9372364ac 100644 --- a/Node/core-AppInsights/package.json +++ b/Node/core-AppInsights/package.json @@ -21,8 +21,8 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "applicationinsights": "^0.17.2", - "botbuilder": "^3.8.2", + "applicationinsights": "^1.0.1", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "restify": "^4.3.0" } diff --git a/Node/core-ChannelData/package.json b/Node/core-ChannelData/package.json index ebce01a18d..d036c5acf7 100644 --- a/Node/core-ChannelData/package.json +++ b/Node/core-ChannelData/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "restify": "^4.3.0" } diff --git a/Node/core-CreateNewConversation/package.json b/Node/core-CreateNewConversation/package.json index ddc214db4c..438983c2d0 100644 --- a/Node/core-CreateNewConversation/package.json +++ b/Node/core-CreateNewConversation/package.json @@ -21,8 +21,8 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", - "restify": "^4.3.0", - "dotenv-extended": "^1.0.4" + "botbuilder": "^3.13.1", + "dotenv-extended": "^1.0.4", + "restify": "^4.3.0" } } diff --git a/Node/core-CustomState/package.json b/Node/core-CustomState/package.json index ba8ed7d584..ed523ab4a1 100644 --- a/Node/core-CustomState/package.json +++ b/Node/core-CustomState/package.json @@ -21,8 +21,8 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", - "botbuilder-azure": "^3.0.2", + "botbuilder": "^3.13.1", + "botbuilder-azure": "^3.0.4", "dotenv-extended": "^1.0.4", "restify": "^4.3.0" } diff --git a/Node/core-DirectLine/DirectLineBot/package.json b/Node/core-DirectLine/DirectLineBot/package.json index 2b215e5d6a..9eaf2c311a 100644 --- a/Node/core-DirectLine/DirectLineBot/package.json +++ b/Node/core-DirectLine/DirectLineBot/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "restify": "^4.3.0" } diff --git a/Node/core-DirectLine/DirectLineClient/app.js b/Node/core-DirectLine/DirectLineClient/app.js index 065e57ae25..10a0184346 100644 --- a/Node/core-DirectLine/DirectLineClient/app.js +++ b/Node/core-DirectLine/DirectLineClient/app.js @@ -4,7 +4,7 @@ var rp = require('request-promise'); // config items var pollInterval = 1000; -var directLineSecret = 'DIRECTLINE_SECRET'; +var directLineSecret = '4LKVFeUN-JE.cwA.qho.Aj1UU4gwBvbfKWnvqS-_qSmJCWsvzojoUo8iOCbnm8A'; var directLineClientName = 'DirectLineClient'; var directLineSpecUrl = 'https://docs.botframework.com/en-us/restapi/directline3/swagger.json'; @@ -25,7 +25,7 @@ var directLineClient = rp(directLineSpecUrl) console.error('Error initializing DirectLine client', err); }); -// once the client is ready, create a new conversation +// once the client is ready, create a new conversation directLineClient.then(function (client) { client.Conversations.Conversations_StartConversation() // create conversation .then(function (response) { @@ -34,6 +34,9 @@ directLineClient.then(function (client) { .then(function (conversationId) { sendMessagesFromConsole(client, conversationId); // start watching console input for sending new messages to bot pollMessages(client, conversationId); // start polling messages from bot + }) + .catch(function (err) { + console.error('Error starting conversation', err); }); }); @@ -78,7 +81,7 @@ function pollMessages(client, conversationId) { setInterval(function () { client.Conversations.Conversations_GetActivities({ conversationId: conversationId, watermark: watermark }) .then(function (response) { - watermark = response.obj.watermark; // use watermark so subsequent requests skip old messages + watermark = response.obj.watermark; // use watermark so subsequent requests skip old messages return response.obj.activities; }) .then(printMessages); diff --git a/Node/core-DirectLine/README.md b/Node/core-DirectLine/README.md index 0afc24b789..9fcb1165b9 100644 --- a/Node/core-DirectLine/README.md +++ b/Node/core-DirectLine/README.md @@ -17,7 +17,7 @@ The minimum prerequisites to run this sample are: #### Direct Line API Credentials for the Direct Line API must be obtained from the Bot Framework developer portal, and will only allow the caller to connect to the bot for which they were generated. -In the Bot Framework developer portal, enable Direct Line in the channels list and then, configure the Direct Line secret and update its value in [DirectLineClient's app.js](DirectLineClient/app.js#L7) (`directLineSecret` variable). Make sure that the checkbox for version 3.0 [PREVIEW] is checked. +In the Bot Framework developer portal, enable Direct Line in the channels list and then, configure the Direct Line secret and update its value in [DirectLineClient's app.js](DirectLineClient/app.js#L7) (`directLineSecret` variable). Make sure that the checkbox for version 3.0 [PREVIEW] is checked. Refer to [this](https://docs.microsoft.com/en-us/bot-framework/portal-configure-channels) for more information on how to configure channels. ![Configure Direct Line](images/outcome-configure.png) @@ -54,10 +54,10 @@ var directLineClient = rp(directLineSpecUrl) ```` Each conversation on the Direct Line channel must be explicitly started using the `client.Conversations.Conversations_StartConversation()` function. -Check out the client's [app.js createConversation](DirectLineClient/app.js#L28-L38) function which creates a new conversation. +Check out the client's [app.js createConversation](DirectLineClient/app.js#L28-L41) function which creates a new conversation. ````JavaScript -// once the client is ready, create a new conversation +// once the client is ready, create a new conversation directLineClient.then(function (client) { client.Conversations.Conversations_StartConversation() // create conversation .then(function (response) { @@ -66,6 +66,9 @@ directLineClient.then(function (client) { .then(function (conversationId) { sendMessagesFromConsole(client, conversationId); // start watching console input for sending new messages to bot pollMessages(client, conversationId); // start polling messages from bot + }) + .catch(function (err) { + console.error('Error starting conversation', err); }); }); ```` @@ -92,22 +95,22 @@ client.Conversations.Conversations_PostActivity( }); ```` -Messages from the Bot are continually polled from the API using an interval. Check out the client's [app.js](DirectLineClient/app.js#L77-L85) usage of `client.Conversations.Conversations_GetActivities` function which retrieves conversation messages newer than the stored watermark. Messages are then filtered from anyone but our own client using the [`printMessages`](DirectLineClient/app.js#L89-L104) function. +Messages from the Bot are continually polled from the API using an interval. Check out the client's [app.js](DirectLineClient/app.js#L80-L88) usage of `client.Conversations.Conversations_GetActivities` function which retrieves conversation messages newer than the stored watermark. Messages are then filtered from anyone but our own client using the [`printMessages`](DirectLineClient/app.js#L92-L107) function. ````JavaScript var watermark = null; setInterval(function () { client.Conversations.Conversations_GetActivities({ conversationId: conversationId, watermark: watermark }) .then(function (response) { - watermark = response.obj.watermark; // use watermark so subsequent requests skip old messages + watermark = response.obj.watermark; // use watermark so subsequent requests skip old messages return response.obj.activities; }) .then(printMessages); }, pollInterval); ```` -DirectLine v3.0 (unlike version 1.1) has supports for Attachments (see [Send and receive attachments](https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-send-receive-attachments) for more information about attachments). -Check out the [`printMessage`](DirectLineClient/app.js#L106-L125) function to see how the Attachments are retrieved and rendered appropriately based on their type. +DirectLine v3.0 (unlike version 1.1) has supports for Attachments (see [Send and receive attachments](https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-send-receive-attachments) for more information about attachments). +Check out the [`printMessage`](DirectLineClient/app.js#L109-L128) function to see how the Attachments are retrieved and rendered appropriately based on their type. ````JavaScript function printMessage(activity) { @@ -142,7 +145,7 @@ To run the sample, you'll need to run both Bot and Client apps. * Running Client app 1. Open a CMD console and CD to sample's `DirectLineClient` directory 2. Run `node app.js` - + To test the ChannelData custom messages type in the Client's console `show me a hero card` or `send me a botframework image` and you should see the following outcome. ![Sample Outcome](images/outcome.png) diff --git a/Node/core-DirectLineWebSockets/DirectLineBot/package.json b/Node/core-DirectLineWebSockets/DirectLineBot/package.json index 2b215e5d6a..9eaf2c311a 100644 --- a/Node/core-DirectLineWebSockets/DirectLineBot/package.json +++ b/Node/core-DirectLineWebSockets/DirectLineBot/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "restify": "^4.3.0" } diff --git a/Node/core-GetConversationMembers/package.json b/Node/core-GetConversationMembers/package.json index 8437cfa220..a5b07d770d 100644 --- a/Node/core-GetConversationMembers/package.json +++ b/Node/core-GetConversationMembers/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "restify": "^4.3.0", "swagger-client": "^2.1.26" diff --git a/Node/core-MultiDialogs/package.json b/Node/core-MultiDialogs/package.json index 28aaa7c4e8..6c9510457a 100644 --- a/Node/core-MultiDialogs/package.json +++ b/Node/core-MultiDialogs/package.json @@ -22,8 +22,8 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.8.2", - "restify": "^4.3.0", - "dotenv-extended": "^1.0.4" + "botbuilder": "^3.13.1", + "dotenv-extended": "^1.0.4", + "restify": "^4.3.0" } } diff --git a/Node/core-ProgressDialog/package.json b/Node/core-ProgressDialog/package.json index 93347912f9..3b0f5e64e8 100644 --- a/Node/core-ProgressDialog/package.json +++ b/Node/core-ProgressDialog/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "restify": "^4.3.0" } } diff --git a/Node/core-ReceiveAttachment/package.json b/Node/core-ReceiveAttachment/package.json index 869fa5d65a..08a38419ea 100644 --- a/Node/core-ReceiveAttachment/package.json +++ b/Node/core-ReceiveAttachment/package.json @@ -22,10 +22,10 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", + "dotenv-extended": "^1.0.4", "request": "^2.79.0", "request-promise": "^4.1.1", - "restify": "^4.3.0", - "dotenv-extended": "^1.0.4" + "restify": "^4.3.0" } } diff --git a/Node/core-SendAttachment/package.json b/Node/core-SendAttachment/package.json index d661083966..3a05572322 100644 --- a/Node/core-SendAttachment/package.json +++ b/Node/core-SendAttachment/package.json @@ -22,9 +22,9 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", + "dotenv-extended": "^1.0.4", "restify": "^4.3.0", - "swagger-client": "^2.1.32", - "dotenv-extended": "^1.0.4" + "swagger-client": "^2.1.32" } } diff --git a/Node/core-State/package.json b/Node/core-State/package.json index bccae1d96e..09a3779e1c 100644 --- a/Node/core-State/package.json +++ b/Node/core-State/package.json @@ -21,8 +21,8 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", - "restify": "^4.3.0", - "dotenv-extended": "^1.0.4" + "botbuilder": "^3.13.1", + "dotenv-extended": "^1.0.4", + "restify": "^4.3.0" } } diff --git a/Node/core-basicMultiDialog/package.json b/Node/core-basicMultiDialog/package.json index 403c89916c..a1599cfb23 100644 --- a/Node/core-basicMultiDialog/package.json +++ b/Node/core-basicMultiDialog/package.json @@ -2,8 +2,8 @@ "name": "core-basic-multidialog", "version": "1.0.0", "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^2.0.0", "restify": "^4.3.0" } -} \ No newline at end of file +} diff --git a/Node/core-globalMessageHandlers/package.json b/Node/core-globalMessageHandlers/package.json index d1ea4c1113..da4ca71545 100644 --- a/Node/core-globalMessageHandlers/package.json +++ b/Node/core-globalMessageHandlers/package.json @@ -2,7 +2,7 @@ "name": "core-globalmessagehandlers", "version": "1.0.0", "dependencies": { - "botbuilder": "^3.8.4", + "botbuilder": "^3.13.1", "dotenv-extended": "^2.0.0", "restify": "^4.3.0" } diff --git a/Node/core-proactiveMessages/simpleSendMessage/package.json b/Node/core-proactiveMessages/simpleSendMessage/package.json index 656385ed80..faf825fc33 100644 --- a/Node/core-proactiveMessages/simpleSendMessage/package.json +++ b/Node/core-proactiveMessages/simpleSendMessage/package.json @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/MicrosoftDX/botFramework-proactiveMessages#readme", "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "restify": "^4.3.0" } } diff --git a/Node/core-proactiveMessages/startNewDialog/botadapter.js b/Node/core-proactiveMessages/startNewDialog/botadapter.js deleted file mode 100644 index 4cc90f88a5..0000000000 --- a/Node/core-proactiveMessages/startNewDialog/botadapter.js +++ /dev/null @@ -1,122 +0,0 @@ -'use strict'; - -var builder = require('botbuilder'); - -function _clone(obj) { - var cpy = {}; - if (obj) { - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - cpy[key] = obj[key]; - } - } - } - return cpy; -} - -function loadSession(address, opts, cb) { - - var _consts = { - Data : { - SessionState: 'BotBuilder.Data.SessionState' - } - }; - - var _this = this; - this.lookupUser(address, (user) => { - _this.ensureConversation(address, function (address) { - - var storageCtx = { - userId: user.id, - conversationId: address.conversation ? address.conversation.id : null, - address: address, - persistUserData: _this.settings.persistUserData, - persistConversationData: _this.settings.persistConversationData - }; - - var loadedData; - _this.getStorageData(storageCtx, function (data) { - if (!_this.localizer) { - var defaultLocale = _this.settings.localizerSettings ? _this.settings.localizerSettings.defaultLocale : null; - _this.localizer = new DefaultLocalizer_1.DefaultLocalizer(_this.lib, defaultLocale); - } - var session = new builder.Session({ - localizer: _this.localizer, - autoBatchDelay: _this.settings.autoBatchDelay, - library: _this.lib, - actions: _this.actions, - middleware: _this.mwSession, - dialogId: opts.dialogId, - dialogArgs: opts.dialogArgs, - dialogErrorMessage: _this.settings.dialogErrorMessage, - onSave: function (cb) { - var finish = _this.errorLogger(cb); - loadedData.userData = _clone(session.userData); - loadedData.conversationData = _clone(session.conversationData); - loadedData.privateConversationData = _clone(session.privateConversationData); - loadedData.privateConversationData[_consts.Data.SessionState] = session.sessionState; - _this.saveStorageData(storageCtx, loadedData, finish, finish); - }, - onSend: function (messages, cb) { - _this.send(messages, cb); - } - }); - session.on('error', function (err) { return _this.emitError(err); }); - var sessionState; - session.userData = data.userData || {}; - session.conversationData = data.conversationData || {}; - session.privateConversationData = data.privateConversationData || {}; - if (session.privateConversationData.hasOwnProperty(_consts.Data.SessionState)) { - sessionState = session.privateConversationData[_consts.Data.SessionState]; - delete session.privateConversationData[_consts.Data.SessionState]; - } - - // Do the important things route/dispatch would have done - session.sessionState = sessionState; - var cur = session.curDialog(); - session.dialogData = cur ? cur.state : {}; - session.message = {address : address}; - - loadedData = data; - cb(null, session); - - }, (err) => { _this.errorLogger(err); cb(err); }) - }, (err) => { _this.errorLogger(err); cb(err); }) - }, (err) => { _this.errorLogger(err); cb(err); }) -} - -function beginDialog(address, dialogId, dialogArgs, opts, done) { - if (typeof opts === 'function') { - done = opts; - opts = {}; - } - - if (opts.resume) { - this.loadSession(address, { dialogId:dialogId, dialogArgs:dialogArgs }, - (err, session) => { - if (!err) { - session.beginDialog(dialogId, dialogArgs); - if (done) { - done(null); - } - } - else { - if (done) { - done(err); - } - } - }); - } - else { - this.beginDialog(address, dialogId, dialogArgs, done); - } -} - -function patch(bot) { - bot.beginDialog = beginDialog; - bot.loadSession = loadSession; - return bot; -} - -exports.patch = patch; - diff --git a/Node/core-proactiveMessages/startNewDialog/package.json b/Node/core-proactiveMessages/startNewDialog/package.json index c6cf41fe13..28db0d7b57 100644 --- a/Node/core-proactiveMessages/startNewDialog/package.json +++ b/Node/core-proactiveMessages/startNewDialog/package.json @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/MicrosoftDX/botFramework-proactiveMessages#readme", "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "restify": "^4.3.0" } } diff --git a/Node/core-proactiveMessages/startNewDialogWithPrompt/package.json b/Node/core-proactiveMessages/startNewDialogWithPrompt/package.json index c6cf41fe13..28db0d7b57 100644 --- a/Node/core-proactiveMessages/startNewDialogWithPrompt/package.json +++ b/Node/core-proactiveMessages/startNewDialogWithPrompt/package.json @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/MicrosoftDX/botFramework-proactiveMessages#readme", "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "restify": "^4.3.0" } } diff --git a/Node/demo-ContosoFlowers/README.md b/Node/demo-ContosoFlowers/README.md index cce5653555..e4c3e23aaa 100644 --- a/Node/demo-ContosoFlowers/README.md +++ b/Node/demo-ContosoFlowers/README.md @@ -20,7 +20,7 @@ The minimum prerequisites to run this sample are: #### Integration with Express.js BotBuilder is implemented as a REST API, basically a web endpoint where all your bot messages will be routed to. This is done through the ChatConnector's [listen()](https://docs.botframework.com/en-us/node/builder/chat-reference/classes/_botbuilder_d_.chatconnector.html#listen) function and it is hooked to your existing [express.js](https://expressjs.com/) or [restify.js](http://restify.com/) application, thus leveraging your web application scalability. If the scaling requirements of your bot are different than your web application, you can opt to host it separatly. -The simplest way to hook your bot with your express.js app is to use express.js routing as follows: +The simplest way to hook your bot with your express.js app is to use express.js routing as follows: ````JavaScript server.post('/api/messages', connector.listen()); ```` @@ -35,7 +35,7 @@ var connectorListener = connector.listen(); function listen() { return function (req, res) { // Capture the url for the hosted application - // We'll later need this url to create the checkout link + // We'll later need this url to create the checkout link var url = req.protocol + '://' + req.get('host'); siteUrl.save(url); connectorListener(req, res); @@ -48,7 +48,7 @@ module.exports.listen = listen; // Then, register the hook from your express.js application: var bot = require('./bot'); app.post('/api/messages', bot.listen()); -```` +```` #### Welcome Message @@ -78,7 +78,7 @@ Each of these dialogs are implemented as a [BotBuilder Library](https://docs.bot These are the more important ones related to the shopping experience: * [**Shop Dialog**](bot/dialogs/shop.js) - + Handles the main flow of the shopping experience. Calls other dialogs to capture information like the selected product, delivery address, recipient information and triggers the checkout flow. * [**Address Dialogs**](bot/dialogs/address.js) @@ -153,7 +153,7 @@ lib.dialog('email', module.exports.createLibrary = function () { return lib.clone(); }; -```` +```` And this is how you can call the validator from your existing code: @@ -177,7 +177,7 @@ And this is how you can call the validator from your existing code: > It is worth noting that calling other dialogs within your library don't need to be prefixed with the library's id. It is only when crossing from one library context to another that you need to include the library name prefix on your `session.beginDialog()` calls. Another example of a reusable library is the [BotBuilder's Location picker control](https://github.com/Microsoft/BotBuilder-Location). Once the module is added to your project dependencies, you can register it with your bot and start using it. -Checkout the [address dialog](bot/dialogs/address.js#L6-L30) to see its usage within Contoso Flowers. +Checkout the [address dialog](bot/dialogs/address.js#L6-L31) to see its usage within Contoso Flowers. ````JavaScript var lib = new builder.Library('address'); @@ -194,6 +194,7 @@ lib.dialog('/', [ useNativeControl: true, reverseGeocode: true, skipConfirmationAsk: true, + skipFavorites: true, requiredFields: locationDialog.LocationRequiredFields.streetAddress | locationDialog.LocationRequiredFields.locality | @@ -209,7 +210,7 @@ lib.dialog('/', [ |----------|-------|----------| |![Bing Location Control](images/bing-location-emulator.png)|![Bing Location Control](images/bing-location-facebook.png)|![Bing Location Control](images/bing-location-skype.png)| -#### Rich Cards +#### Rich Cards Many messaging channels provide the ability to attach richer objects. The Bot Framework has the ability to render rich cards as attachments. @@ -301,7 +302,7 @@ var DefaultCategory = 'Flower 2'; bot.dialog('/', [ function (session, args, next) { - // Create dialog function + // Create dialog function var displayProducts = CarouselPagination.create( // getPageFunc(pageNumber: number, pageSize: number):Promise function (pageNumber, pageSize) { return Products.getProducts(DefaultCategory, pageNumber, pageSize); }, @@ -325,8 +326,8 @@ bot.dialog('/', [ unknownOption: 'I couldn\'t understand your selection. Please try again.' }); - // Invoke dialog function - // It will handle product selection, pagination call or product list display + // Invoke dialog function + // It will handle product selection, pagination call or product list display displayProducts(session, args, next); }, @@ -486,12 +487,12 @@ bot.use({ botbuilder: function (session, next) { var text = session.message.text; if (settingsRegex.test(text)) { - // interrupt and trigger 'settings' dialog + // interrupt and trigger 'settings' dialog return session.beginDialog('settings:/'); } else if (supportRegex.test(text)) { // interrupt and trigger 'help' dialog return session.beginDialog('help:/'); - } + } // continue normal flow next(); @@ -589,7 +590,7 @@ bot.set('localizerSettings', { }); ```` -The default localization system for Bot Builder is file based and lets a bot support multiple languages using JSON files stored on disk. By default, the localization system will search for the bots prompts in the ./locale/[IETF TAG]/index.json file where [IETF TAG] is a valid [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) representing the preferred locale to use the prompts for. +The default localization system for Bot Builder is file based and lets a bot support multiple languages using JSON files stored on disk. By default, the localization system will search for the bots prompts in the ./locale/[IETF TAG]/index.json file where [IETF TAG] is a valid [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) representing the preferred locale to use the prompts for. You can see in the previous code snippet that we are providing a locale path to inform the SDK where to look for language files. Each file in [the locale folder](bot/locale/en) corresponds to a another file in the [bot's dialogs folder](bot/dialogs). They contain the resource strings used by each dialog. E.g.: @@ -668,11 +669,11 @@ To get more information about how to get started in Bot Builder for Node review * [LUIS](https://docs.botframework.com/en-us/node/builder/guides/understanding-natural-language/) -> **Limitations** +> **Limitations** > The functionality provided by the Bot Framework Activity can be used across many channels. Moreover, some special channel features can be unleashed using the [Message.sourceEvent](https://docs.botframework.com/en-us/node/builder/chat-reference/classes/_botbuilder_d_.message.html#sourceevent) method. -> +> > The Bot Framework does its best to support the reuse of your Bot in as many channels as you want. However, due to the very nature of some of these channels, some features are not fully portable. -> +> > The features used in this sample are fully supported in the following channels: > - Skype > - Facebook @@ -680,11 +681,11 @@ To get more information about how to get started in Bot Builder for Node review > - DirectLine > - WebChat > - GroupMe -> +> > They are also supported, with some limitations, in the following channel: > - Microsoft Teams (Receipt card not supported) > - Email -> +> > On the other hand, they are not supported and the sample won't work as expected in the following channels: > - Telegram > - SMS diff --git a/Node/demo-ContosoFlowers/bot/dialogs/address.js b/Node/demo-ContosoFlowers/bot/dialogs/address.js index a1d10e24b1..c3be835484 100644 --- a/Node/demo-ContosoFlowers/bot/dialogs/address.js +++ b/Node/demo-ContosoFlowers/bot/dialogs/address.js @@ -19,6 +19,7 @@ lib.dialog('/', [ prompt: promptMessage, useNativeControl: true, reverseGeocode: true, + skipFavorites: true, skipConfirmationAsk: true, requiredFields: locationDialog.LocationRequiredFields.streetAddress | @@ -32,7 +33,7 @@ lib.dialog('/', [ if (results.response) { // Return selected address to previous dialog in stack var place = results.response; - var address = locationDialog.getFormattedAddressFromPlace(place, ', '); + var address = getFormattedAddressFromPlace(place, ', '); session.endDialogWithResult({ address: address }); @@ -43,7 +44,7 @@ lib.dialog('/', [ }]); // Request Billing Address -// Prompt/Save selected address. Uses previous dialog to request and validate address. +// Prompt/Save selected address. Uses previous dialog to request and validate address. var UseSavedInfoChoices = { Home: 'home_address', Work: 'work_address', @@ -118,7 +119,7 @@ lib.dialog('billing', [ session.userData.billingAddresses[args.response.entity] = billingAddress; } - // Return address + // Return address session.endDialogWithResult({ billingAddress: billingAddress }); } ]); @@ -138,6 +139,11 @@ function createAddressCard(session, buttonTitle, address) { ]); } +function getFormattedAddressFromPlace(place, separator) { + var addressParts = [place.streetAddress, place.locality, place.region, place.postalCode, place.country]; + return addressParts.filter(i => i).join(separator); +} + module.exports.UseSavedInfoChoices = UseSavedInfoChoices; // Export createLibrary() function diff --git a/Node/demo-ContosoFlowers/bot/dialogs/checkout.js b/Node/demo-ContosoFlowers/bot/dialogs/checkout.js index 399e87cd53..caae460a7c 100644 --- a/Node/demo-ContosoFlowers/bot/dialogs/checkout.js +++ b/Node/demo-ContosoFlowers/bot/dialogs/checkout.js @@ -91,10 +91,10 @@ lib.dialog('completed', function (session, args, next) { builder.Fact.create(session, offuscateNumber(order.paymentDetails.creditcardNumber), 'payment_method') ]) .items([ - builder.ReceiptItem.create(session, order.selection.price, order.selection.name) + builder.ReceiptItem.create(session, order.selection.price.toString(), order.selection.name) .image(builder.CardImage.create(session, order.selection.imageUrl)) ]) - .total(order.selection.price) + .total(order.selection.price.toString()) .buttons([ builder.CardAction.openUrl(session, 'https://dev.botframework.com/', 'more_information') ]); diff --git a/Node/demo-ContosoFlowers/package.json b/Node/demo-ContosoFlowers/package.json index 221ae15b83..396fb45e45 100644 --- a/Node/demo-ContosoFlowers/package.json +++ b/Node/demo-ContosoFlowers/package.json @@ -23,11 +23,10 @@ "dependencies": { "bluebird": "^3.4.7", "body-parser": "^1.15.2", - "botbuilder": "^3.8.2", - "botbuilder-location": "^1.1.0", + "botbuilder": "^3.13.1", + "botbuilder-location": "^2.0.0", "dotenv-extended": "^1.0.4", "express": "^4.14.0", - "geobing": "^0.1.3", "lodash": "^4.17.4", "pug": "^2.0.0-beta6", "serve-favicon": "^2.3.2", diff --git a/Node/demo-RollerSkill/package.json b/Node/demo-RollerSkill/package.json index fcc9f21269..a523c252de 100644 --- a/Node/demo-RollerSkill/package.json +++ b/Node/demo-RollerSkill/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^2.0.0", "restify": "^4.3.0" } diff --git a/Node/demo-Search/SearchDialogLibrary/package.json b/Node/demo-Search/SearchDialogLibrary/package.json index ea7cd29c7f..9d8c4427f0 100644 --- a/Node/demo-Search/SearchDialogLibrary/package.json +++ b/Node/demo-Search/SearchDialogLibrary/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "lodash": "^4.17.4" } } diff --git a/Node/demo-Search/package.json b/Node/demo-Search/package.json index 9bf5c66eb9..caf9f304e2 100644 --- a/Node/demo-Search/package.json +++ b/Node/demo-Search/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "lodash": "^4.17.4", "lorem-ipsum": "^1.0.3", diff --git a/Node/intelligence-ImageCaption/.env b/Node/intelligence-ImageCaption/.env index 84fb625347..812a5b157e 100644 --- a/Node/intelligence-ImageCaption/.env +++ b/Node/intelligence-ImageCaption/.env @@ -3,7 +3,7 @@ MICROSOFT_APP_ID= MICROSOFT_APP_PASSWORD= -# This is a free trial Microsoft Cognitive service key with limited QPS. -# Please subscribe to Vision API services to try it out further. +# Subscribe to Cognitive Services Computer Vision API to obtain a Trial Key. # Subscription URL: https://www.microsoft.com/cognitive-services/en-us/subscriptions -MICROSOFT_VISION_API_KEY=c84d0e1aaaff482b9014a570927bdbf2 \ No newline at end of file +MICROSOFT_VISION_API_KEY= +MICROSOFT_VISION_API_ENDPOINT=https://westus.api.cognitive.microsoft.com/vision/v1.0 \ No newline at end of file diff --git a/Node/intelligence-ImageCaption/README.md b/Node/intelligence-ImageCaption/README.md index cf98f07893..930d12f84f 100644 --- a/Node/intelligence-ImageCaption/README.md +++ b/Node/intelligence-ImageCaption/README.md @@ -12,14 +12,13 @@ A sample bot that illustrates how to use the Microsoft Cognitive Services Comput The minimum prerequisites to run this sample are: * Latest Node.js with NPM. Download it from [here](https://nodejs.org/en/download/). * The Bot Framework Emulator. To install the Bot Framework Emulator, download it from [here](https://emulator.botframework.com/). Please refer to [this documentation article](https://github.com/microsoft/botframework-emulator/wiki/Getting-Started) to know more about the Bot Framework Emulator. -* Computer Vision App ID. You can obtain one from [Microsoft Cognitive Services Subscriptions Page](https://www.microsoft.com/cognitive-services/en-us/subscriptions?productId=/products/54d873dd5eefd00dc474a0f4). * **[Recommended]** Visual Studio Code for IntelliSense and debugging, download it from [here](https://code.visualstudio.com/) for free. -* This sample currently uses a free trial Microsoft Cognitive service key with limited QPS. Please subscribe to Vision API services [here](https://www.microsoft.com/cognitive-services/en-us/subscriptions) and update the `MICROSOFT_VISION_API_KEY` key in [.env](.env) file to try it out further. +* Subscribe to Cognitive Services Computer Vision API from [here](https://www.microsoft.com/cognitive-services/en-us/subscriptions) to obtain a Trial API Key and update the `MICROSOFT_VISION_API_KEY` and `MICROSOFT_VISION_API_ENDPOINT` keys in [.env](.env) file to try it out further. ### Code Highlights -Microsoft Computer Vision API provides a number of methods that allows you to analyze an image. Check out [Computer Vision API - v1.0](https://westus.dev.cognitive.microsoft.com/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fa) for a complete reference of the methods available. In this sample we are using the 'analyze' endpoint with the 'visualFeatures' parameter set to 'Description' `https://westus.api.cognitive.microsoft.com/vision/v1.0/analyze?visualFeatures=Description` +Microsoft Computer Vision API provides a number of methods that allows you to analyze an image. Check out [Computer Vision API - v1.0](https://westus.dev.cognitive.microsoft.com/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fa) for a complete reference of the methods available. In this sample we are using the 'analyze' endpoint with the 'visualFeatures' parameter set to 'Description' `https://westus.api.cognitive.microsoft.com/vision/v1.0/analyze?visualFeatures=Description` The main components are: @@ -38,32 +37,35 @@ if (hasImageAttachment(session)) { } ```` -And here is the implementation of `captionService.getCaptionFromStream(stream)` in [caption-service.js](caption-service.js#L15). +And here is the implementation of `captionService.getCaptionFromStream(stream)` in [caption-service.js](caption-service.js#L13). ````JavaScript -/** +/** * Gets the caption of the image from an image stream * @param {stream} stream The stream to an image. * @return {Promise} Promise with caption string if succeeded, error otherwise */ exports.getCaptionFromStream = function (stream) { + var apiUrl = process.env.MICROSOFT_VISION_API_ENDPOINT + '/analyze?visualFeatures=Description' return new Promise( function (resolve, reject) { var requestData = { - url: VISION_URL, + url: apiUrl, encoding: 'binary', - headers: { 'content-type': 'application/octet-stream' } + json: true, + headers: { + 'Ocp-Apim-Subscription-Key': process.env.MICROSOFT_VISION_API_KEY, + 'content-type': 'application/octet-stream' + } }; stream.pipe(request.post(requestData, function (error, response, body) { if (error) { reject(error); - } - else if (response.statusCode !== 200) { + } else if (response.statusCode !== 200) { reject(body); - } - else { - resolve(extractCaption(JSON.parse(body))); + } else { + resolve(extractCaption(body)); } })); } diff --git a/Node/intelligence-ImageCaption/caption-service.js b/Node/intelligence-ImageCaption/caption-service.js index 1af1fe137e..e3f8fc1a79 100644 --- a/Node/intelligence-ImageCaption/caption-service.js +++ b/Node/intelligence-ImageCaption/caption-service.js @@ -5,18 +5,17 @@ var request = require('request').defaults({ encoding: null }); -var VISION_URL = 'https://westus.api.cognitive.microsoft.com/vision/v1.0/analyze?visualFeatures=Description'; - -/** +/** * Gets the caption of the image from an image stream * @param {stream} stream The stream to an image. * @return {Promise} Promise with caption string if succeeded, error otherwise */ exports.getCaptionFromStream = function (stream) { + var apiUrl = process.env.MICROSOFT_VISION_API_ENDPOINT + '/analyze?visualFeatures=Description' return new Promise( function (resolve, reject) { var requestData = { - url: VISION_URL, + url: apiUrl, encoding: 'binary', json: true, headers: { @@ -31,24 +30,29 @@ exports.getCaptionFromStream = function (stream) { } else if (response.statusCode !== 200) { reject(body); } else { - resolve(extractCaption(JSON.parse(body))); + resolve(extractCaption(body)); } })); } ); }; -/** +/** * Gets the caption of the image from an image URL * @param {string} url The URL to an image. * @return {Promise} Promise with caption string if succeeded, error otherwise */ exports.getCaptionFromUrl = function (url) { + var apiUrl = process.env.MICROSOFT_VISION_API_ENDPOINT + '/analyze?visualFeatures=Description' return new Promise( function (resolve, reject) { var requestData = { - url: VISION_URL, - json: { 'url': url } + url: apiUrl, + json: { 'url': url }, + headers: { + 'Ocp-Apim-Subscription-Key': process.env.MICROSOFT_VISION_API_KEY, + 'content-type': 'application/json' + } }; request.post(requestData, function (error, response, body) { diff --git a/Node/intelligence-ImageCaption/package.json b/Node/intelligence-ImageCaption/package.json index 5ea77f68de..90eedda175 100644 --- a/Node/intelligence-ImageCaption/package.json +++ b/Node/intelligence-ImageCaption/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "needle": "^1.4.3", "request": "^2.79.0", diff --git a/Node/intelligence-LUIS/.env b/Node/intelligence-LUIS/.env index f13d06e6c2..dc491180fe 100644 --- a/Node/intelligence-LUIS/.env +++ b/Node/intelligence-LUIS/.env @@ -5,10 +5,10 @@ MICROSOFT_APP_PASSWORD= # This Url can be obtained by uploading or creating your model from the LUIS portal: https://www.luis.ai/ LUIS_MODEL_URL= -# This is a free trial Microsoft Bing Spell Check key with limited QPS. -# Please subscribe to create your own key and try it out further. -# Subscription URL: https://www.microsoft.com/cognitive-services/en-us/subscriptions?productId=/products/56ec2df6dbe2d91324586008 -BING_SPELL_CHECK_API_KEY=8ae90e80bc4346d59c0f07529dadaa4e - # Boolean value to enable correcting the text before processing it IS_SPELL_CORRECTION_ENABLED=false + +# Subscribe to Cognitive Services Bing Spell Check API to obtain a Trial Key. +# Subscription URL: https://azure.microsoft.com/en-us/try/cognitive-services/?api=spellcheck-api +BING_SPELL_CHECK_API_KEY= +BING_SPELL_CHECK_API_ENDPOINT=https://api.cognitive.microsoft.com/bing/v7.0/spellcheck diff --git a/Node/intelligence-LUIS/README.md b/Node/intelligence-LUIS/README.md index d3903c2c75..0f519c089c 100644 --- a/Node/intelligence-LUIS/README.md +++ b/Node/intelligence-LUIS/README.md @@ -34,7 +34,7 @@ In the LUIS application's dashboard, click the "Publish App" button in the left ### Code Highlights -One of the key problems in human-computer interactions is the ability of the computer to understand what a person wants, and to find the pieces of information that are relevant to their intent. In the LUIS application, you will bundle together the intents and entities that are important to your task. Read more about [Planning an Application](https://docs.microsoft.com/en-us/azure/cognitive-services/LUIS/plan-your-app) in the LUIS Help +One of the key problems in human-computer interactions is the ability of the computer to understand what a person wants, and to find the pieces of information that are relevant to their intent. In the LUIS application, you will bundle together the intents and entities that are important to your task. Read more about [Planning an Application](https://docs.microsoft.com/en-us/azure/cognitive-services/LUIS/plan-your-app) in the LUIS Help #### Intent Recognizers @@ -92,7 +92,7 @@ Another LUIS Model Feature used is Phrase List Features, for instance, the model ![Phrase List Feature](images/highlights-phrase.png) -In our sample, we are using a [waterfall dialog](https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-waterfall) for the hotel search. This is a common pattern that you'll likely use for most of your intent handlers. The way waterfalls work in Bot Builder is the very first step of the waterfall is called when a dialog (or in this case intent handler) is triggered. The step then does some work and continues execution of the waterfall by either calling another dialog (like a built-in prompt) or calling the optional `next()` function passed in. When a dialog is called in a step, any result returned from the dialog will be passed as input to the results parameter for the next step. +In our sample, we are using a [waterfall dialog](https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-waterfall) for the hotel search. This is a common pattern that you'll likely use for most of your intent handlers. The way waterfalls work in Bot Builder is the very first step of the waterfall is called when a dialog (or in this case intent handler) is triggered. The step then does some work and continues execution of the waterfall by either calling another dialog (like a built-in prompt) or calling the optional `next()` function passed in. When a dialog is called in a step, any result returned from the dialog will be passed as input to the results parameter for the next step. Our bot tries to check if an entity of city or airport type were [matched and forwards it](app.js#L37-L44) to the next step. If that's not the case, the user is [prompted with a destination](app.js#L47). The [next step](app.js#L50) will receive the destination or airport code in the `results` argument. @@ -181,11 +181,11 @@ bot.dialog('ShowHotelsReviews', function (session, args) { If you want to enable spelling correction, set the `IS_SPELL_CORRECTION_ENABLED` key to `true` in the [.env](.env#L14) file. -Microsoft Bing Spell Check API provides a module that allows you to to correct the spelling of the text. Check out the [reference](https://dev.cognitive.microsoft.com/docs/services/56e73033cf5ff80c2008c679/operations/56e73036cf5ff81048ee6727) to know more about the modules available. +Microsoft Bing Spell Check API provides a module that allows you to to correct the spelling of the text. Check out the [reference](https://dev.cognitive.microsoft.com/docs/services/56e73033cf5ff80c2008c679/operations/56e73036cf5ff81048ee6727) to know more about the modules available. [spell-service.js](spell-service.js) is the core component illustrating how to call the Bing Spell Check RESTful API. -In this sample we added spell correction as a middleware. Check out the middleware in [app.js](app.js#L109-L125). +In this sample we added spell correction as a middleware. Check out the middleware in [app.js](app.js#L109-L126). ````JavaScript if (process.env.IS_SPELL_CORRECTION_ENABLED === 'true') { @@ -194,6 +194,7 @@ if (process.env.IS_SPELL_CORRECTION_ENABLED === 'true') { spellService .getCorrectedText(session.message.text) .then(function (text) { + console.log('Text corrected to "' + text + '"'); session.message.text = text; next(); }) @@ -224,11 +225,11 @@ To get more information about how to get started in Bot Builder for Node and LUI * [Alarm Bot in Node](https://github.com/Microsoft/BotBuilder/tree/master/Node/examples/basics-naturalLanguage) * [Microsoft Bing Spell Check API](https://www.microsoft.com/cognitive-services/en-us/bing-spell-check-api) -> **Limitations** +> **Limitations** > The functionality provided by the Bot Framework Activity can be used across many channels. Moreover, some special channel features can be unleashed using the [Message.sourceEvent](https://docs.botframework.com/en-us/node/builder/chat-reference/classes/_botbuilder_d_.message.html#sourceevent) method. -> +> > The Bot Framework does its best to support the reuse of your Bot in as many channels as you want. However, due to the very nature of some of these channels, some features are not fully portable. -> +> > The features used in this sample are fully supported in the following channels: > - Skype > - Facebook @@ -238,10 +239,10 @@ To get more information about how to get started in Bot Builder for Node and LUI > - Slack > - GroupMe > - Telegram -> +> > They are also supported, with some limitations, in the following channels: > - Kik > - Email -> +> > On the other hand, they are not supported and the sample won't work as expected in the following channel: > - SMS diff --git a/Node/intelligence-LUIS/app.js b/Node/intelligence-LUIS/app.js index f092632ad2..71dd684d4d 100644 --- a/Node/intelligence-LUIS/app.js +++ b/Node/intelligence-LUIS/app.js @@ -113,6 +113,7 @@ if (process.env.IS_SPELL_CORRECTION_ENABLED === 'true') { spellService .getCorrectedText(session.message.text) .then(function (text) { + console.log('Text corrected to "' + text + '"'); session.message.text = text; next(); }) diff --git a/Node/intelligence-LUIS/package.json b/Node/intelligence-LUIS/package.json index 3f5c59ba87..ff85625262 100644 --- a/Node/intelligence-LUIS/package.json +++ b/Node/intelligence-LUIS/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "request": "^2.79.0", "restify": "^4.3.0" diff --git a/Node/intelligence-LUIS/spell-service.js b/Node/intelligence-LUIS/spell-service.js index 27a49151f2..83bf6cc43e 100644 --- a/Node/intelligence-LUIS/spell-service.js +++ b/Node/intelligence-LUIS/spell-service.js @@ -3,7 +3,7 @@ // https://dev.cognitive.microsoft.com/docs/services/56e73033cf5ff80c2008c679/operations/56e73036cf5ff81048ee6727 var request = require('request'); -var SPELL_CHECK_API_URL = 'https://api.cognitive.microsoft.com/bing/v5.0/spellcheck/?form=BCSSCK', +var SPELL_CHECK_API_URL = process.env.BING_SPELL_CHECK_API_ENDPOINT; SPELL_CHECK_API_KEY = process.env.BING_SPELL_CHECK_API_KEY; /** diff --git a/Node/intelligence-SimilarProducts/.env b/Node/intelligence-SimilarProducts/.env index 49f9c35b30..99a4fca3d4 100644 --- a/Node/intelligence-SimilarProducts/.env +++ b/Node/intelligence-SimilarProducts/.env @@ -2,7 +2,6 @@ MICROSOFT_APP_ID= MICROSOFT_APP_PASSWORD= -# This is a free trial Microsoft Bing Search key with limited QPS. -# Please subscribe to create your own key and try it out further. -# Subscription URL: https://www.microsoft.com/cognitive-services/en-us/subscriptions -BING_SEARCH_API_KEY=ee4e28574f514ce7b687236b01a07432 \ No newline at end of file +# Subscribe to Bing Search API to obtain a Trial API Key and update the `BING_SEARCH_API_KEY` +# Subscription URL: https://azure.microsoft.com/en-us/try/cognitive-services/my-apis/?apiSlug=search-api-v7 +BING_SEARCH_API_KEY= \ No newline at end of file diff --git a/Node/intelligence-SimilarProducts/README.md b/Node/intelligence-SimilarProducts/README.md index 7d4407c2f4..2dab0f8988 100644 --- a/Node/intelligence-SimilarProducts/README.md +++ b/Node/intelligence-SimilarProducts/README.md @@ -13,12 +13,14 @@ The minimum prerequisites to run this sample are: * Latest Node.js with NPM. Download it from [here](https://nodejs.org/en/download/). * The Bot Framework Emulator. To install the Bot Framework Emulator, download it from [here](https://emulator.botframework.com/). Please refer to [this documentation article](https://github.com/microsoft/botframework-emulator/wiki/Getting-Started) to know more about the Bot Framework Emulator. * **[Recommended]** Visual Studio Code for IntelliSense and debugging, download it from [here](https://code.visualstudio.com/) for free. +* Subscribe to Bing Search API from [here](https://azure.microsoft.com/en-us/try/cognitive-services/my-apis/?apiSlug=search-api-v7) to obtain a Trial API Key and update the `BING_SEARCH_API_KEY` key in [.env](.env) file to try it out further. + * This sample currently uses a free trial Microsoft Bing Search API key with limited QPS. Please subscribe [here](https://www.microsoft.com/cognitive-services/en-us/subscriptions) to obtain your own key and update the `BING_SEARCH_API_KEY` key in [.env](.env) file to try it out further. ### Code Highlights -Microsoft Bing Image Search API provides a number of modules that allows you to search by image. Check out the [reference](https://msdn.microsoft.com/en-us/library/dn760791.aspx) to know more about the modules available. In this sample we are using the 'SimilarProducts' module to get similar products to an image. We set the 'modulesRequested' parameter to 'SimilarProducts' `https://api.cognitive.microsoft.com/bing/v5.0/images/search?modulesRequested=SimilarProducts` +Microsoft Bing Image Search API provides a number of modules that allows you to search by image. Check out the [reference](https://msdn.microsoft.com/en-us/library/dn760791.aspx) to know more about the modules available. In this sample we are using the 'SimilarProducts' module to get similar products to an image. We set the 'modulesRequested' parameter to 'SimilarProducts' `https://api.cognitive.microsoft.com/bing/v5.0/images/search?modulesRequested=SimilarProducts` The main components are: @@ -40,7 +42,7 @@ if (hasImageAttachment(session)) { And here is the implementation of `imageService.getSimilarProductsFromStream(stream)` in [image-service.js](image-service.js) ````JavaScript -/** +/** * Gets the similar products of the image from an image stream * @param {stream} stream The stream to an image. * @return {Promise} Promise with visuallySimilarProducts array if succeeded, error otherwise diff --git a/Node/intelligence-SimilarProducts/image-service.js b/Node/intelligence-SimilarProducts/image-service.js index c677f44ae8..d94b7e863f 100644 --- a/Node/intelligence-SimilarProducts/image-service.js +++ b/Node/intelligence-SimilarProducts/image-service.js @@ -3,11 +3,10 @@ // https://msdn.microsoft.com/en-us/library/dn760791.aspx var request = require('request').defaults({ encoding: null }); -var BING_API_URL = 'https://api.cognitive.microsoft.com/bing/v5.0/images/search?modulesRequested=SimilarProducts&mkt=en-us&form=BCSPRD'; - +var BING_SEARCH_API_ENDPOINT = 'https://api.cognitive.microsoft.com/bing/v7.0/images/details?modules=SimilarProducts&mkt=en-us' var BING_SEARCH_API_KEY = process.env.BING_SEARCH_API_KEY; -/** +/** * Gets the similar products of the image from an image stream * @param {stream} stream The stream to an image. * @return {Promise} Promise with visuallySimilarProducts array if succeeded, error otherwise @@ -16,13 +15,14 @@ exports.getSimilarProductsFromStream = function (stream) { return new Promise( function (resolve, reject) { var requestData = { - url: BING_API_URL, - encoding: 'binary', + url: BING_SEARCH_API_ENDPOINT, + json: true, formData: { file: stream }, headers: { - 'Ocp-Apim-Subscription-Key': BING_SEARCH_API_KEY + 'Ocp-Apim-Subscription-Key': BING_SEARCH_API_KEY, + 'Content-Type': 'multipart/form-data', } }; @@ -34,14 +34,14 @@ exports.getSimilarProductsFromStream = function (stream) { reject(body); } else { - resolve(JSON.parse(body).visuallySimilarProducts); + resolve((body.visuallySimilarProducts && body.visuallySimilarProducts.value) || []); } }); } ); }; -/** +/** * Gets the similar products of the image from an image URL * @param {string} url The URL to an image. * @return {Promise} Promise with visuallySimilarProducts array if succeeded, error otherwise @@ -50,7 +50,7 @@ exports.getSimilarProductsFromUrl = function (url) { return new Promise( function (resolve, reject) { var requestData = { - url: BING_API_URL + '&imgurl=' + url, + url: BING_SEARCH_API_ENDPOINT + '&imgurl=' + encodeURIComponent(url), headers: { 'Ocp-Apim-Subscription-Key': BING_SEARCH_API_KEY }, @@ -65,7 +65,7 @@ exports.getSimilarProductsFromUrl = function (url) { reject(body); } else { - resolve(body.visuallySimilarProducts); + resolve((body.visuallySimilarProducts && body.visuallySimilarProducts.value) || []); } }); } diff --git a/Node/intelligence-SimilarProducts/package.json b/Node/intelligence-SimilarProducts/package.json index 4d2f152d16..14ffa89af9 100644 --- a/Node/intelligence-SimilarProducts/package.json +++ b/Node/intelligence-SimilarProducts/package.json @@ -8,7 +8,7 @@ "author": "Microsoft Corp.", "license": "MIT", "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "request": "^2.79.0", "restify": "^4.3.0", diff --git a/Node/intelligence-SpeechToText/.env b/Node/intelligence-SpeechToText/.env index e1dae9e7ea..f3e894a41e 100644 --- a/Node/intelligence-SpeechToText/.env +++ b/Node/intelligence-SpeechToText/.env @@ -3,7 +3,6 @@ MICROSOFT_APP_ID= MICROSOFT_APP_PASSWORD= -# This is a free trial Microsoft Cognitive service key with limited QPS. -# Please subscribe to Bing Speech API to try it out further. -# Subscription URL: https://www.microsoft.com/cognitive-services/en-us/subscriptions -MICROSOFT_SPEECH_API_KEY=f2da0a19f4d94875880e9fbaceabc97d \ No newline at end of file +# Subscribe to Bing Speech API to obtain a Trial API Key. +# Subscription URL: https://azure.microsoft.com/en-us/services/cognitive-services/speech/ +MICROSOFT_SPEECH_API_KEY= \ No newline at end of file diff --git a/Node/intelligence-SpeechToText/README.md b/Node/intelligence-SpeechToText/README.md index f0d308e1c4..4ebb625517 100644 --- a/Node/intelligence-SpeechToText/README.md +++ b/Node/intelligence-SpeechToText/README.md @@ -14,7 +14,7 @@ The minimum prerequisites to run this sample are: * The Bot Framework Emulator. To install the Bot Framework Emulator, download it from [here](https://emulator.botframework.com/). Please refer to [this documentation article](https://github.com/microsoft/botframework-emulator/wiki/Getting-Started) to know more about the Bot Framework Emulator. * Bing Speech Api Key. You can obtain one from [Microsoft Cognitive Services Subscriptions Page](https://www.microsoft.com/cognitive-services/en-us/subscriptions?productId=/products/Bing.Speech.Preview). * **[Recommended]** Visual Studio Code for IntelliSense and debugging, download it from [here](https://code.visualstudio.com/) for free. -* This sample currently uses a free trial Microsoft Cognitive service key with limited QPS. Please subscribe to Bing Speech Api services [here](https://www.microsoft.com/cognitive-services/en-us/subscriptions) and update the `MICROSOFT_SPEECH_API_KEY` key in [.env](.env) file to try it out further. +* Subscribe to Bing Speech API from [here](https://azure.microsoft.com/en-us/services/cognitive-services/speech/) to obtain a Trial API Key and update the `MICROSOFT_SPEECH_API_KEY` key in [.env](.env) file to try it out further. ### Usage diff --git a/Node/intelligence-SpeechToText/package.json b/Node/intelligence-SpeechToText/package.json index ce1520f520..52b5169f45 100644 --- a/Node/intelligence-SpeechToText/package.json +++ b/Node/intelligence-SpeechToText/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "needle": "^1.4.3", "node-uuid": "^1.4.7", diff --git a/Node/intelligence-Zummer/.env b/Node/intelligence-Zummer/.env index fdbc3022e6..99a4fca3d4 100644 --- a/Node/intelligence-Zummer/.env +++ b/Node/intelligence-Zummer/.env @@ -2,6 +2,6 @@ MICROSOFT_APP_ID= MICROSOFT_APP_PASSWORD= - -BING_SEARCH_API_KEY=d23e97be84fc4c2d841b3fc4c42d617a -BING_SUMMARIZER_API_KEY=dfeb69a40d2743e39a87e8d54eb31b91 \ No newline at end of file +# Subscribe to Bing Search API to obtain a Trial API Key and update the `BING_SEARCH_API_KEY` +# Subscription URL: https://azure.microsoft.com/en-us/try/cognitive-services/my-apis/?apiSlug=search-api-v7 +BING_SEARCH_API_KEY= \ No newline at end of file diff --git a/Node/intelligence-Zummer/README.md b/Node/intelligence-Zummer/README.md index eb4231f4d7..303e464c2e 100644 --- a/Node/intelligence-Zummer/README.md +++ b/Node/intelligence-Zummer/README.md @@ -47,7 +47,7 @@ Zummer bot is trained to understand the following intents:   -1. **Sign in and Create an application** on [www.luis.ai](http://www.luis.ai/) +1. **Sign in and Create an application** on [www.luis.ai](http://www.luis.ai/) **Note:** You can either import the LUIS application JSON file “ZummerLuisApp.json” found in the sample folder @@ -113,11 +113,11 @@ Fetching Wikipedia articles on a topic using Bing Web Search API 1. Create a free tier “Key” that will be used for calling the Bing APIs on [Microsoft Cognitive Service subscriptions](https://www.microsoft.com/cognitive-services/en-US/subscriptions) - + 2. Bing Web Search API request format details can be found at [Bing Web API reference](https://dev.cognitive.microsoft.com/docs/services/56b43eeccf5ff8098cef3807/operations/56b4447dcf5ff8098cef380d) - page + page This tutorial implements communication with Bing Web Search API service and mainpulating the user's query to get response with only Wikipedia articles through "** *** *findsArticles" in bing-search-service.js @@ -125,15 +125,14 @@ Fetching Wikipedia articles on a topic using Bing Web Search API ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ c# var apiHandler = require('./api-handler-service'); - const BING_SEARCH_API_URL = "https://api.cognitive.microsoft.com/bing/v5.0/search/", + const BING_SEARCH_API_URL = "https://api.cognitive.microsoft.com/bing/v7.0/search/", BING_SEARCH_API_KEY = process.env.BING_SEARCH_API_KEY; var headers = { "Ocp-Apim-Subscription-Key": BING_SEARCH_API_KEY } module.exports = { findArticles: (query) => { - return apiHandler.getResponse(BING_SEARCH_API_URL, { "q": query + " site:wikipedia.org" }, headers) - .then(result => { return JSON.parse(result); }, err => { return err }); + return apiHandler.getResponse(BING_SEARCH_API_URL, { "q": query + " site:wikipedia.org" }, headers); } } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -211,11 +210,14 @@ You will see the following when connecting the Bot to the Emulator: More Information ---------------- -To get more information about how to get started in Bot Builder for .NET, +To get more information about how to get started in Bot Builder for .NET, Bing Web Search API and LUIS please review the -following resources: \* [Bot Builder for -Node.js](https://docs.microsoft.com/en-us/bot-framework/nodejs/) \* [Bing Web +following resources: + +* [Bot Builder for +Node.js](https://docs.microsoft.com/en-us/bot-framework/nodejs/) +* [Bing Web Search -API](https://www.microsoft.com/cognitive-services/en-us/bing-web-search-api) \* -[Language Understanding Intelligent Services +API](https://www.microsoft.com/cognitive-services/en-us/bing-web-search-api) +* [Language Understanding Intelligent Services (LUIS)](https://www.microsoft.com/cognitive-services/en-us/language-understanding-intelligent-service-luis) diff --git a/Node/intelligence-Zummer/api-handler-service.js b/Node/intelligence-Zummer/api-handler-service.js index cebcd2a6c9..c9060be969 100644 --- a/Node/intelligence-Zummer/api-handler-service.js +++ b/Node/intelligence-Zummer/api-handler-service.js @@ -6,7 +6,8 @@ exports.getResponse = function (url, requestParameters, headers) { if (url && requestParameters && headers) { const requestData = { url: url + constructRequestParams(requestParameters), - headers: headers + headers: headers, + json: true } request.get(requestData, (error, response, body) => { diff --git a/Node/intelligence-Zummer/bing-search-service.js b/Node/intelligence-Zummer/bing-search-service.js index 5863da2306..bab62eac0e 100644 --- a/Node/intelligence-Zummer/bing-search-service.js +++ b/Node/intelligence-Zummer/bing-search-service.js @@ -1,13 +1,12 @@ var apiHandler = require('./api-handler-service'); -const BING_SEARCH_API_URL = "https://api.cognitive.microsoft.com/bing/v5.0/search/", +const BING_SEARCH_API_URL = "https://api.cognitive.microsoft.com/bing/v7.0/search/", BING_SEARCH_API_KEY = process.env.BING_SEARCH_API_KEY; var headers = { "Ocp-Apim-Subscription-Key": BING_SEARCH_API_KEY } module.exports = { findArticles: (query) => { - return apiHandler.getResponse(BING_SEARCH_API_URL, { "q": query + " site:wikipedia.org", "form": "BTCSWR" }, headers) - .then(result => { return JSON.parse(result); }, err => { return err }); + return apiHandler.getResponse(BING_SEARCH_API_URL, { "q": query + " site:wikipedia.org" }, headers) } } \ No newline at end of file diff --git a/Node/intelligence-Zummer/package.json b/Node/intelligence-Zummer/package.json index 4310bfd67d..33c218651e 100644 --- a/Node/intelligence-Zummer/package.json +++ b/Node/intelligence-Zummer/package.json @@ -7,7 +7,7 @@ }, "author": "mmoussa", "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "memory-cache": "^0.1.6", "restify": "^4.3.0", diff --git a/Node/sample-knowledgeBot/config.js b/Node/sample-knowledgeBot/config.js index a2687eb69f..2c63483c03 100644 --- a/Node/sample-knowledgeBot/config.js +++ b/Node/sample-knowledgeBot/config.js @@ -3,6 +3,6 @@ module.exports = function () { global.searchName = process.env.AZURE_SEARCH_NAME ? process.env.AZURE_SEARCH_NAME : ""; global.indexName = process.env.INDEX_NAME ? process.env.AZURE_SEARCH_NAME : ""; global.searchKey = process.env.INDEX_NAME ? process.env.AZURE_SEARCH_KEY : ""; - - global. queryString = 'https://' + searchName + '.search.windows.net/indexes/' + indexName + '/docs?api-key=' + searchKey + '&api-version=2015-02-28&'; + + global.queryString = 'https://' + searchName + '.search.windows.net/indexes/' + indexName + '/docs?api-key=' + searchKey + '&api-version=2015-02-28&'; } \ No newline at end of file diff --git a/Node/sample-knowledgeBot/package.json b/Node/sample-knowledgeBot/package.json index 3ad1e88189..31d563ea31 100644 --- a/Node/sample-knowledgeBot/package.json +++ b/Node/sample-knowledgeBot/package.json @@ -9,7 +9,7 @@ "author": "", "license": "ISC", "dependencies": { - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^2.0.0", "request": "^2.78.0", "restify": "^4.2.0" diff --git a/Node/sample-payments/package.json b/Node/sample-payments/package.json index a01d322236..02393d37d8 100644 --- a/Node/sample-payments/package.json +++ b/Node/sample-payments/package.json @@ -23,7 +23,7 @@ "dependencies": { "base64url": "^2.0.0", "bluebird": "^3.5.0", - "botbuilder": "^3.8.2", + "botbuilder": "^3.13.1", "dotenv-extended": "^1.0.4", "lodash": "^4.17.4", "restify": "^4.3.0",