diff --git a/Node/blog-LUISActionBinding/core/package.json b/Node/blog-LUISActionBinding/core/package.json index c5b80bdfe4..5056312a2f 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.7.0", + "botbuilder": "^3.8.2", "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 130a4dd061..865dc30e15 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.7.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "jsonpath": "^0.2.10", "lodash": "^4.17.4", diff --git a/Node/blog-customChannelData/.env b/Node/blog-customChannelData/.env new file mode 100644 index 0000000000..b0e3340b17 --- /dev/null +++ b/Node/blog-customChannelData/.env @@ -0,0 +1,3 @@ +# Bot Framework Variables +MSFT_APP_ID= +MSFT_APP_PW= diff --git a/Node/blog-customChannelData/node_custom_channel.js b/Node/blog-customChannelData/node_custom_channel.js index 68def93ff1..9202aa6911 100644 --- a/Node/blog-customChannelData/node_custom_channel.js +++ b/Node/blog-customChannelData/node_custom_channel.js @@ -1,3 +1,6 @@ +//load environment variables from the .env file +require('dotenv-extended').load(); + //loading modules var express = require("express"); var restify = require("restify"); @@ -10,8 +13,9 @@ const MSFT_APP_PW = process.env.MSFT_APP_PW; //create an express server var app = express(); -app.listen( process.env.PORT || 3000, function(){ - console.log("Express app listening on port: " + process.env.PORT || 3000); +var port = process.env.PORT || 3978; +app.listen(port, function () { + console.log("Express app listening on port: " + port); }); //create a chat connector for the bot @@ -24,31 +28,31 @@ var connector = new botbuilder.ChatConnector({ var bot = new botbuilder.UniversalBot(connector); //hook up bot endpoint -app.post("/messages/receive", connector.listen()); +app.post("/api/messages", connector.listen()); //root dialog -bot.dialog("/", function(session){ +bot.dialog("/", function (session) { console.log("-------------------------------------------------"); console.log("Bot Received Message at '/' dialogue endpoint: "); //detect Facebook Messenger message here - if(session.message.address.channelId == "facebook"){ + if (session.message.address.channelId == "facebook") { session.send("Facebook message recognized!"); - session.beginDialog("/send_share_button"); + session.beginDialog("/send_share_button"); } else session.send("Channel other than Facebook recognized."); }); //where we create a facebook share button using sourceEvent -bot.dialog("/send_share_button", function(session){ +bot.dialog("/send_share_button", function (session) { //construct a new message with the current session context var msg = new botbuilder.Message(session).sourceEvent({ //specify the channel facebook: { - //format according to channel's requirements - //(in our case, the above JSON required by Facebook) - attachment: { + //format according to channel's requirements + //(in our case, the above JSON required by Facebook) + attachment: { type: "template", payload: { template_type: "generic", diff --git a/Node/blog-customChannelData/package.json b/Node/blog-customChannelData/package.json index c9516e5d29..5c98e0d2b5 100644 --- a/Node/blog-customChannelData/package.json +++ b/Node/blog-customChannelData/package.json @@ -4,7 +4,8 @@ "description": "Microsoft Bot Framework bot written in NodeJS to test issues.", "main": "node_bot.js", "dependencies": { - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", + "dotenv-extended": "^2.0.0", "express": "^4.14.1", "request-promise": "^4.1.1", "restify": "^4.3.0" diff --git a/Node/capability-SimpleTaskAutomation/package.json b/Node/capability-SimpleTaskAutomation/package.json index e8df0dd880..4a652873c6 100644 --- a/Node/capability-SimpleTaskAutomation/package.json +++ b/Node/capability-SimpleTaskAutomation/package.json @@ -9,7 +9,7 @@ "author": "", "license": "ISC", "dependencies": { - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0", "uuid": "^3.0.1" }, diff --git a/Node/capability-middlewareLogging/package.json b/Node/capability-middlewareLogging/package.json index b02826fde2..d827d91e3e 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.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0" } } diff --git a/Node/cards-CarouselCards/azuredeploy.json b/Node/cards-CarouselCards/azuredeploy.json index fe0be5d2f2..301c3f7fd4 100644 --- a/Node/cards-CarouselCards/azuredeploy.json +++ b/Node/cards-CarouselCards/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/cards-CarouselCards/package.json b/Node/cards-CarouselCards/package.json index 71513964c8..3b49ceb662 100644 --- a/Node/cards-CarouselCards/package.json +++ b/Node/cards-CarouselCards/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0", "dotenv-extended": "^1.0.4" } diff --git a/Node/cards-RichCards/azuredeploy.json b/Node/cards-RichCards/azuredeploy.json index 2882230487..bb702ef996 100644 --- a/Node/cards-RichCards/azuredeploy.json +++ b/Node/cards-RichCards/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/cards-RichCards/package.json b/Node/cards-RichCards/package.json index 881b2575c1..a4ca22462a 100644 --- a/Node/cards-RichCards/package.json +++ b/Node/cards-RichCards/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0", "dotenv-extended": "^1.0.4" } diff --git a/Node/core-AppInsights/azuredeploy.json b/Node/core-AppInsights/azuredeploy.json index 8ab18665d1..f88f34f16e 100644 --- a/Node/core-AppInsights/azuredeploy.json +++ b/Node/core-AppInsights/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-AppInsights/package.json b/Node/core-AppInsights/package.json index 98bf43672a..fb61c6be12 100644 --- a/Node/core-AppInsights/package.json +++ b/Node/core-AppInsights/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "applicationinsights": "^0.17.2", - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "restify": "^4.3.0" } diff --git a/Node/core-ChannelData/azuredeploy.json b/Node/core-ChannelData/azuredeploy.json index 1937022ebc..ad9bcd2cb5 100644 --- a/Node/core-ChannelData/azuredeploy.json +++ b/Node/core-ChannelData/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-ChannelData/package.json b/Node/core-ChannelData/package.json index fde6a338ce..ebce01a18d 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.7.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "restify": "^4.3.0" } diff --git a/Node/core-CreateNewConversation/azuredeploy.json b/Node/core-CreateNewConversation/azuredeploy.json index d869d7f0df..58e6bd605a 100644 --- a/Node/core-CreateNewConversation/azuredeploy.json +++ b/Node/core-CreateNewConversation/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-CreateNewConversation/package.json b/Node/core-CreateNewConversation/package.json index 35bd8a6e81..ddc214db4c 100644 --- a/Node/core-CreateNewConversation/package.json +++ b/Node/core-CreateNewConversation/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0", "dotenv-extended": "^1.0.4" } diff --git a/Node/core-CustomState/azuredeploy.json b/Node/core-CustomState/azuredeploy.json index 5ccf876bfd..bc9a30d7b8 100644 --- a/Node/core-CustomState/azuredeploy.json +++ b/Node/core-CustomState/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-CustomState/package.json b/Node/core-CustomState/package.json index 51d7a47a39..ba8ed7d584 100644 --- a/Node/core-CustomState/package.json +++ b/Node/core-CustomState/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "botbuilder-azure": "^3.0.2", "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 1bc6c97ee7..2b215e5d6a 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.7.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "restify": "^4.3.0" } diff --git a/Node/core-DirectLine/README.md b/Node/core-DirectLine/README.md index d27631bd79..0afc24b789 100644 --- a/Node/core-DirectLine/README.md +++ b/Node/core-DirectLine/README.md @@ -12,7 +12,7 @@ A sample bot and a custom client communicating to each other using the Direct Li 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. -* Register your bot with the Microsoft Bot Framework. Please refer to [this](https://docs.microsoft.com/en-us/bot-framework/portal-register-bot) for the instructions. Once you complete the registration, update your bot configuration with the registered config values (See [Debugging locally using ngrok](https://docs.botframework.com/en-us/node/builder/guides/core-concepts/#debugging-locally-using-ngrok) or [Deploying to Azure](https://docs.microsoft.com/en-us/bot-framework/publish-bot-overview) +* Register your bot with the Microsoft Bot Framework. Please refer to [this](https://docs.microsoft.com/en-us/bot-framework/portal-register-bot) for the instructions. Once you complete the registration, update your bot configuration with the registered config values (See [Debugging locally using ngrok](https://docs.microsoft.com/en-us/bot-framework/debug-bots-emulator) or [Deploying to Azure](https://docs.microsoft.com/en-us/bot-framework/publish-bot-overview) * **[Recommended]** Visual Studio Code for IntelliSense and debugging, download it from [here](https://code.visualstudio.com/) for free. #### Direct Line API @@ -156,4 +156,4 @@ To get more information about how to get started in Bot Builder for Node and Dir * [Direct Line Swagger file - v3.0](https://docs.botframework.com/en-us/restapi/directline3/swagger.json) * [Swagger-JS](https://github.com/swagger-api/swagger-js) * [Send and receive attachments](https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-send-receive-attachments) -* [Debugging locally using ngrok](https://docs.botframework.com/en-us/node/builder/guides/core-concepts/#debugging-locally-using-ngrok) +* [Debugging locally using ngrok](https://docs.microsoft.com/en-us/bot-framework/debug-bots-emulator) diff --git a/Node/core-DirectLine/azuredeploy.json b/Node/core-DirectLine/azuredeploy.json index fb548fa42a..9ddb893a0a 100644 --- a/Node/core-DirectLine/azuredeploy.json +++ b/Node/core-DirectLine/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-DirectLineWebSockets/DirectLineBot/package.json b/Node/core-DirectLineWebSockets/DirectLineBot/package.json index 1bc6c97ee7..2b215e5d6a 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.7.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "restify": "^4.3.0" } diff --git a/Node/core-DirectLineWebSockets/DirectLineClient/app.js b/Node/core-DirectLineWebSockets/DirectLineClient/app.js index 1abc524524..9cfc136023 100644 --- a/Node/core-DirectLineWebSockets/DirectLineClient/app.js +++ b/Node/core-DirectLineWebSockets/DirectLineClient/app.js @@ -30,19 +30,23 @@ var directLineClient = rp(directLineSpecUrl) }) .then(function (client) { // Obtain a token using the Direct Line secret - // First, add the Direct Line Secret to the client's auth header - client.clientAuthorizations.add('AuthorizationBotConnector', new Swagger.ApiKeyAuthorization('Authorization', 'Bearer ' + directLineSecret, 'header')); - - // Second, request a token for a new conversation - return client.Tokens.Tokens_GenerateTokenForNewConversation().then(function (response) { + return rp({ + url: 'https://directline.botframework.com/v3/directline/tokens/generate', + method: 'POST', + headers: { + 'Authorization': 'Bearer ' + directLineSecret + }, + json: true + }).then(function (response) { // Then, replace the client's auth secret with the new token - var token = response.obj.token; + var token = response.token; client.clientAuthorizations.add('AuthorizationBotConnector', new Swagger.ApiKeyAuthorization('Authorization', 'Bearer ' + token, 'header')); - return client; + return client; }); }) .catch(function (err) { console.error('Error initializing DirectLine client', err); + throw err; }); // Once the client is ready, create a new conversation diff --git a/Node/core-DirectLineWebSockets/README.md b/Node/core-DirectLineWebSockets/README.md index 66682754bc..67db9221d9 100644 --- a/Node/core-DirectLineWebSockets/README.md +++ b/Node/core-DirectLineWebSockets/README.md @@ -16,7 +16,7 @@ A sample bot and a custom client communicating to each other using the Direct Li 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. -* Register your bot with the Microsoft Bot Framework. Please refer to [this](https://docs.microsoft.com/en-us/bot-framework/portal-register-bot) for the instructions. Once you complete the registration, update your bot configuration with the registered config values (See [Debugging locally using ngrok](https://docs.botframework.com/en-us/node/builder/guides/core-concepts/#debugging-locally-using-ngrok) or [Deploying to Azure](https://docs.microsoft.com/en-us/bot-framework/publish-bot-overview)) +* Register your bot with the Microsoft Bot Framework. Please refer to [this](https://docs.microsoft.com/en-us/bot-framework/portal-register-bot) for the instructions. Once you complete the registration, update your bot configuration with the registered config values (See [Debugging locally using ngrok](https://docs.microsoft.com/en-us/bot-framework/debug-bots-emulator) or [Deploying to Azure](https://docs.microsoft.com/en-us/bot-framework/publish-bot-overview) * **[Recommended]** Visual Studio Code for IntelliSense and debugging, download it from [here](https://code.visualstudio.com/) for free. #### Direct Line API @@ -27,14 +27,14 @@ Refer to [this](https://docs.microsoft.com/en-us/bot-framework/portal-configure- ![Configure Direct Line](images/outcome-configure.png) #### Publish -Also, in order to be able to run and test this sample you must [publish your bot, for example to Azure](https://docs.microsoft.com/en-us/bot-framework/publish-bot-overview). Alternatively, you can [Debug locally using ngrok](https://docs.botframework.com/en-us/node/builder/guides/core-concepts/#debugging-locally-using-ngrok). +Also, in order to be able to run and test this sample you must [publish your bot, for example to Azure](https://docs.microsoft.com/en-us/bot-framework/publish-bot-overview). Alternatively, you can [Debug locally using ngrok](https://docs.microsoft.com/en-us/bot-framework/debug-bots-emulator). Remember to update the environment variables with the `MICROSOFT_APP_ID` and `MICROSOFT_APP_PASSWORD` on the [.env](DirectLineBot/.env) file. ### Code Highlights The Direct Line API is a simple REST API for connecting directly to a single bot. This API is intended for developers writing their own client applications, web chat controls, or mobile apps that will talk to their bot. In this sample, we are using the [Direct Line Swagger file](https://docs.botframework.com/en-us/restapi/directline3/swagger.json) and [Swagger JS](https://github.com/swagger-api/swagger-js) to create a client for Node that will simplify access to the underlying REST API. Check out the client's [app.js](DirectLineClient/app.js#L22-L46) to see the client setup & initialization. -You'll see that we are using the Direct Line secret to [obtain a token](DirectLineClient/app.js#L32-L42). This step is optional, but prevents clients from accessing conversations they aren't participating in. +You'll see that we are using the Direct Line secret to [obtain a token](DirectLineClient/app.js#L32-L45). This step is optional, but prevents clients from accessing conversations they aren't participating in. After the token is obtained, the client's auth secret is replaced with this new token. ````JavaScript @@ -49,24 +49,28 @@ var directLineClient = rp(directLineSpecUrl) }) .then(function (client) { // Obtain a token using the Direct Line secret - // First, add the Direct Line Secret to the client's auth header - client.clientAuthorizations.add('AuthorizationBotConnector', new Swagger.ApiKeyAuthorization('Authorization', 'Bearer ' + directLineSecret, 'header')); - - // Second, request a token for a new conversation - return client.Tokens.Tokens_GenerateTokenForNewConversation().then(function (response) { + return rp({ + url: 'https://directline.botframework.com/v3/directline/tokens/generate', + method: 'POST', + headers: { + 'Authorization': 'Bearer ' + directLineSecret + }, + json: true + }).then(function (response) { // Then, replace the client's auth secret with the new token - var token = response.obj.token; + var token = response.token; client.clientAuthorizations.add('AuthorizationBotConnector', new Swagger.ApiKeyAuthorization('Authorization', 'Bearer ' + token, 'header')); - return client; + return client; }); }) .catch(function (err) { console.error('Error initializing DirectLine client', err); + throw err; }); ```` Each conversation on the Direct Line channel must be explicitly started using the `client.Conversations.Conversations_StartConversation()` function. -Check out the client's following [function call](DirectLineClient/app.js#L49-L65) which creates a new conversation. +Check out the client's following [function call](DirectLineClient/app.js#L53-L69) which creates a new conversation. ````JavaScript directLineClient.then(function (client) { @@ -112,11 +116,11 @@ client.Conversations.Conversations_PostActivity( Messages from the Bot are being received using the WebSocket protocol (actually WSS). For this, after the conversation was created a `streamUrl` is also returned and it will be the target for the WebSocket connection. -Check out the client's [startReceivingWebSocketClient](DirectLineClient/app.js#L100-L128) and [startReceivingW3CWebSocketClient](DirectLineClient/app.js#L130-L155) functions which create WebSocket clients hitting the `streamUrl` value returned when the conversation was created (one or other will be called dependening on the `w3c` optional flag when running the console app). Messages are then filtered from anyone but our own client using the [`printMessages`](DirectLineClient/app.js#L160-L175 ) function. +Check out the client's [startReceivingWebSocketClient](DirectLineClient/app.js#L104-L133) and [startReceivingW3CWebSocketClient](DirectLineClient/app.js#L135-L161) functions which create WebSocket clients hitting the `streamUrl` value returned when the conversation was created (one or other will be called dependening on the `w3c` optional flag when running the console app). Messages are then filtered from anyone but our own client using the [`printMessages`](DirectLineClient/app.js#L164-L179) function. Each of these functions showcase the two ways you can connect to the `streamUrl` using WebSockets (first one using a custom Node.js implementation, while the second one uses W3C one). If you look closely they are very similar and within the `on message` event handler the bot's response is being parsed to JSON in order to print it. -For `startReceivingWebSocketClient` we have the following [handler](DirectLineClient/app.js#L117-L125): +For `startReceivingWebSocketClient` we have the following [handler](DirectLineClient/app.js#L121-L129): ````JavaScript connection.on('message', function (message) { @@ -129,7 +133,7 @@ connection.on('message', function (message) { }); ```` -And for `startReceivingW3CWebSocketClient` we have the following [handler](DirectLineClient/app.js#L148-L156): +And for `startReceivingW3CWebSocketClient` we have the following [handler](DirectLineClient/app.js#L152-L160): ````JavaScript ws.onmessage = function (e) { @@ -146,7 +150,7 @@ ws.onmessage = function (e) { Direct Line 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#L177-L196) function to see how the Attachments are retrieved and rendered appropriately based on their type. +Check out the [`printMessage`](DirectLineClient/app.js#L181-L200) function to see how the Attachments are retrieved and rendered appropriately based on their type. ````JavaScript function printMessage(activity) { @@ -196,4 +200,4 @@ To get more information about how to get started in Bot Builder for Node and Dir * [Direct Line Swagger file - v3.0](https://docs.botframework.com/en-us/restapi/directline3/swagger.json) * [Swagger-JS](https://github.com/swagger-api/swagger-js) * [Send and receive attachments](https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-send-receive-attachments) -* [Debugging locally using ngrok](https://docs.botframework.com/en-us/node/builder/guides/core-concepts/#debugging-locally-using-ngrok) +* [Debugging locally using ngrok](https://docs.microsoft.com/en-us/bot-framework/debug-bots-emulator) diff --git a/Node/core-DirectLineWebSockets/azuredeploy.json b/Node/core-DirectLineWebSockets/azuredeploy.json index 7f5121cb4e..76d14189c3 100644 --- a/Node/core-DirectLineWebSockets/azuredeploy.json +++ b/Node/core-DirectLineWebSockets/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-GetConversationMembers/azuredeploy.json b/Node/core-GetConversationMembers/azuredeploy.json index 01d7bf5f36..36a1e1f963 100644 --- a/Node/core-GetConversationMembers/azuredeploy.json +++ b/Node/core-GetConversationMembers/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-GetConversationMembers/package.json b/Node/core-GetConversationMembers/package.json index 6bfe17c8a8..8437cfa220 100644 --- a/Node/core-GetConversationMembers/package.json +++ b/Node/core-GetConversationMembers/package.json @@ -22,9 +22,9 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", + "dotenv-extended": "^1.0.4", "restify": "^4.3.0", - "swagger-client": "^2.1.26", - "dotenv-extended": "^1.0.4" + "swagger-client": "^2.1.26" } } diff --git a/Node/core-MultiDialogs/azuredeploy.json b/Node/core-MultiDialogs/azuredeploy.json index 6accc54de7..f69a1e502b 100644 --- a/Node/core-MultiDialogs/azuredeploy.json +++ b/Node/core-MultiDialogs/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-MultiDialogs/package.json b/Node/core-MultiDialogs/package.json index b555a4a1d1..28aaa7c4e8 100644 --- a/Node/core-MultiDialogs/package.json +++ b/Node/core-MultiDialogs/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0", "dotenv-extended": "^1.0.4" } diff --git a/Node/core-ProgressDIalog/app.js b/Node/core-ProgressDIalog/app.js index e186baaff4..0a3761c47c 100644 --- a/Node/core-ProgressDIalog/app.js +++ b/Node/core-ProgressDIalog/app.js @@ -67,6 +67,8 @@ function progress(session, options, asyncFn) { } bot.dialog('progressDialog', function (session, args) { + if(!args) return; + var asyncFn = args.asyncFn; var options = args.options; diff --git a/Node/core-ProgressDIalog/azuredeploy.json b/Node/core-ProgressDIalog/azuredeploy.json index 3bae64eac2..8617447fb6 100644 --- a/Node/core-ProgressDIalog/azuredeploy.json +++ b/Node/core-ProgressDIalog/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-ProgressDIalog/package.json b/Node/core-ProgressDIalog/package.json index 55a95a9ff5..93347912f9 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.0-beta2", + "botbuilder": "^3.8.2", "restify": "^4.3.0" } } diff --git a/Node/core-ReceiveAttachment/azuredeploy.json b/Node/core-ReceiveAttachment/azuredeploy.json index ea7ae87e2e..073d6cbb9d 100644 --- a/Node/core-ReceiveAttachment/azuredeploy.json +++ b/Node/core-ReceiveAttachment/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-ReceiveAttachment/package.json b/Node/core-ReceiveAttachment/package.json index 616e592b50..869fa5d65a 100644 --- a/Node/core-ReceiveAttachment/package.json +++ b/Node/core-ReceiveAttachment/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "request": "^2.79.0", "request-promise": "^4.1.1", "restify": "^4.3.0", diff --git a/Node/core-SendAttachment/azuredeploy.json b/Node/core-SendAttachment/azuredeploy.json index 2c4e4259cd..bfcd5a3ae7 100644 --- a/Node/core-SendAttachment/azuredeploy.json +++ b/Node/core-SendAttachment/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-SendAttachment/package.json b/Node/core-SendAttachment/package.json index 4cb718a1dd..d661083966 100644 --- a/Node/core-SendAttachment/package.json +++ b/Node/core-SendAttachment/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0", "swagger-client": "^2.1.32", "dotenv-extended": "^1.0.4" diff --git a/Node/core-State/azuredeploy.json b/Node/core-State/azuredeploy.json index 4af0e96409..188ebd0089 100644 --- a/Node/core-State/azuredeploy.json +++ b/Node/core-State/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/core-State/package.json b/Node/core-State/package.json index f85133f23b..bccae1d96e 100644 --- a/Node/core-State/package.json +++ b/Node/core-State/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0", "dotenv-extended": "^1.0.4" } diff --git a/Node/core-basicMultiDialog/package.json b/Node/core-basicMultiDialog/package.json index 4c5fdb488d..1a78b8e451 100644 --- a/Node/core-basicMultiDialog/package.json +++ b/Node/core-basicMultiDialog/package.json @@ -1,7 +1,7 @@ { - "name": "core-basicMultiDialog", + "name": "botbuilder-sample-basicmultidialog", "dependencies": { - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "dotenv": "^2.0.0", "restify": "^4.3.0" }, diff --git a/Node/core-globalMessageHandlers/package.json b/Node/core-globalMessageHandlers/package.json index 4c5fdb488d..e3dfff0555 100644 --- a/Node/core-globalMessageHandlers/package.json +++ b/Node/core-globalMessageHandlers/package.json @@ -1,12 +1,12 @@ { - "name": "core-basicMultiDialog", - "dependencies": { - "botbuilder": "^3.7.0", - "dotenv": "^2.0.0", - "restify": "^4.3.0" - }, - "devDependencies": { - "@types/node": "^6.0.52", - "@types/restify": "^2.0.35" - } -} \ No newline at end of file + "name": "core-basicmultidialog", + "dependencies": { + "botbuilder": "^3.8.4", + "dotenv": "^2.0.0", + "restify": "^4.3.0" + }, + "devDependencies": { + "@types/node": "^6.0.52", + "@types/restify": "^2.0.35" + } +} diff --git a/Node/core-proactiveMessages/simpleSendMessage/.jshintrc b/Node/core-proactiveMessages/simpleSendMessage/.jshintrc deleted file mode 100644 index ebe59fd733..0000000000 --- a/Node/core-proactiveMessages/simpleSendMessage/.jshintrc +++ /dev/null @@ -1,41 +0,0 @@ -{ - "globals": { - "jasmine": false, - "spyOn": false, - "it": false, - "console": false, - "describe": false, - "expect": false, - "beforeEach": false, - "waits": false, - "waitsFor": false, - "runs": false - }, - - "node" : true, - "esversion" : 6, - "browser" : true, - - "boss" : false, - "curly": false, - "debug": false, - "devel": false, - "eqeqeq": true, - "evil": true, - "forin": false, - "immed": true, - "laxbreak": false, - "newcap": true, - "noarg": true, - "noempty": false, - "nonew": false, - "nomen": false, - "onevar": true, - "plusplus": false, - "regexp": false, - "undef": true, - "sub": true, - "strict": false, - "white": true, - "unused": true -} diff --git a/Node/core-proactiveMessages/simpleSendMessage/package.json b/Node/core-proactiveMessages/simpleSendMessage/package.json index 61773db177..656385ed80 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.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0" } } diff --git a/Node/core-proactiveMessages/startNewDialog/package.json b/Node/core-proactiveMessages/startNewDialog/package.json index 3f822c3008..c6cf41fe13 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.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0" } } diff --git a/Node/core-proactiveMessages/startNewDialogWithPrompt/package.json b/Node/core-proactiveMessages/startNewDialogWithPrompt/package.json index 3f822c3008..c6cf41fe13 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.7.0", + "botbuilder": "^3.8.2", "restify": "^4.3.0" } } diff --git a/Node/demo-ContosoFlowers/README.md b/Node/demo-ContosoFlowers/README.md index 7bd0585441..cce5653555 100644 --- a/Node/demo-ContosoFlowers/README.md +++ b/Node/demo-ContosoFlowers/README.md @@ -139,9 +139,15 @@ var EmailRegex = new RegExp(/[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/ var lib = new builder.Library('validators'); lib.dialog('email', - builder.DialogAction.validatedPrompt(builder.PromptType.text, function (response) { - return EmailRegex.test(response); - })); + new builder.IntentDialog() + .onBegin(function (session, args) { + session.dialogData.retryPrompt = args.retryPrompt; + session.send(args.prompt); + }).matches(EmailRegex, function (session) { + session.endDialogWithResult({ response: session.message.text }); + }).onDefault(function (session) { + session.send(session.dialogData.retryPrompt); + })); // Export createLibrary() function module.exports.createLibrary = function () { diff --git a/Node/demo-ContosoFlowers/azuredeploy.json b/Node/demo-ContosoFlowers/azuredeploy.json index fe63b85fd7..a652ef180c 100644 --- a/Node/demo-ContosoFlowers/azuredeploy.json +++ b/Node/demo-ContosoFlowers/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/demo-ContosoFlowers/bot/dialogs/details.js b/Node/demo-ContosoFlowers/bot/dialogs/details.js index 4c4ecf47cd..56782b0c89 100644 --- a/Node/demo-ContosoFlowers/bot/dialogs/details.js +++ b/Node/demo-ContosoFlowers/bot/dialogs/details.js @@ -16,16 +16,14 @@ lib.dialog('/', [ session.dialogData.recipientLastName = args.response; session.beginDialog('validators:phonenumber', { prompt: session.gettext('ask_recipient_phone_number'), - retryPrompt: session.gettext('invalid_phone_number'), - maxRetries: Number.MAX_VALUE + retryPrompt: session.gettext('invalid_phone_number') }); }, function (session, args) { session.dialogData.recipientPhoneNumber = args.response; session.beginDialog('validators:notes', { prompt: session.gettext('ask_note'), - retryPrompt: session.gettext('invalid_note'), - maxRetries: Number.MAX_VALUE + retryPrompt: session.gettext('invalid_note') }); }, function (session, args) { @@ -84,8 +82,7 @@ lib.dialog('sender', [ } session.beginDialog('validators:email', { prompt: session.gettext('ask_email'), - retryPrompt: session.gettext('invalid_email'), - maxRetries: Number.MAX_VALUE + retryPrompt: session.gettext('invalid_email') }); }, function (session, args, next) { @@ -95,8 +92,7 @@ lib.dialog('sender', [ session.dialogData.email = args.response; session.beginDialog('validators:phonenumber', { prompt: session.gettext('ask_phone_number'), - retryPrompt: session.gettext('invalid_phone_number'), - maxRetries: Number.MAX_VALUE + retryPrompt: session.gettext('invalid_phone_number') }); }, function (session, args, next) { diff --git a/Node/demo-ContosoFlowers/bot/validators.js b/Node/demo-ContosoFlowers/bot/validators.js index 8e620eab79..795327b3f1 100644 --- a/Node/demo-ContosoFlowers/bot/validators.js +++ b/Node/demo-ContosoFlowers/bot/validators.js @@ -5,20 +5,40 @@ var EmailRegex = new RegExp(/[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/ var lib = new builder.Library('validators'); -lib.dialog('notes', - builder.DialogAction.validatedPrompt(builder.PromptType.text, function (response) { - return response && response.length <= 200; - })); - -lib.dialog('phonenumber', - builder.DialogAction.validatedPrompt(builder.PromptType.text, function (response) { - return PhoneRegex.test(response); - })); - -lib.dialog('email', - builder.DialogAction.validatedPrompt(builder.PromptType.text, function (response) { - return EmailRegex.test(response); - })); +lib.dialog('notes', basicPrompterWithExpression(function (input) { + return input && input.length <= 200; +})); + +lib.dialog('phonenumber', basicPrompterWithRegex(PhoneRegex)); + +lib.dialog('email', basicPrompterWithRegex(EmailRegex)); + +function basicPrompterWithRegex(regex) { + return new builder.IntentDialog() + .onBegin(function (session, args) { + session.dialogData.retryPrompt = args.retryPrompt; + session.send(args.prompt); + }).matches(regex, function (session) { + session.endDialogWithResult({ response: session.message.text }); + }).onDefault(function (session) { + session.send(session.dialogData.retryPrompt); + }); +} + +function basicPrompterWithExpression(expression) { + return new builder.IntentDialog() + .onBegin(function (session, args) { + session.dialogData.retryPrompt = args.retryPrompt; + session.send(args.prompt); + }).onDefault(function (session) { + var input = session.message.text; + if (expression(input)) { + session.endDialogWithResult({ response: input }); + } else { + session.send(session.dialogData.retryPrompt); + } + }); +} // Export createLibrary() function module.exports.createLibrary = function () { diff --git a/Node/demo-ContosoFlowers/data/orders.json b/Node/demo-ContosoFlowers/data/orders.json index 2b113c77aa..0637a088a0 100644 --- a/Node/demo-ContosoFlowers/data/orders.json +++ b/Node/demo-ContosoFlowers/data/orders.json @@ -1 +1 @@ -[{"selection":{"name":"Bouquet 7™","imageUrl":"https://placeholdit.imgix.net/~text?txtsize=48&txt=Bouquet%207&w=640&h=330","price":90.99},"delivery":{"date":"2017-02-25T00:25:58.683Z","address":"3 de Febrero 2274, Buenos Aires, Argentina"},"details":{"recipient":{"firstName":"Romina","lastName":"Roux","phoneNumber":"111 222 3334"},"note":"TE AMO!","sender":{"email":"sixdemons@gmail.com","phoneNumber":"222 333 4445"}},"billingAddress":"3 de Febrero 2274, Buenos Aires City, Buenos Aires Autonomous City, 1428, Argentina","id":"e81ef3f0-fa27-11e6-b3a7-cb0d0ff30fae","payed":true,"paymentDetails":{"creditcardNumber":"1111 111","creditcardHolder":"asdasd"}}] \ No newline at end of file +[] \ No newline at end of file diff --git a/Node/demo-ContosoFlowers/package.json b/Node/demo-ContosoFlowers/package.json index e7c690fb8e..221ae15b83 100644 --- a/Node/demo-ContosoFlowers/package.json +++ b/Node/demo-ContosoFlowers/package.json @@ -23,7 +23,7 @@ "dependencies": { "bluebird": "^3.4.7", "body-parser": "^1.15.2", - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "botbuilder-location": "^1.1.0", "dotenv-extended": "^1.0.4", "express": "^4.14.0", diff --git a/Node/demo-RollerSkill/app.js b/Node/demo-RollerSkill/app.js index 919b2cf943..809c4fa8e1 100644 --- a/Node/demo-RollerSkill/app.js +++ b/Node/demo-RollerSkill/app.js @@ -2,6 +2,7 @@ Roller is a dice rolling skill that's been optimized for speech. -----------------------------------------------------------------------------*/ +require('dotenv-extended').load(); var restify = require('restify'); var builder = require('botbuilder'); var ssml = require('./ssml'); @@ -71,7 +72,7 @@ bot.dialog('CreateGameDialog', [ { value: '8', action: { title: '8 Sides' }, synonyms: 'eight|8 sided|8 sides' }, { value: '10', action: { title: '10 Sides' }, synonyms: 'ten|10 sided|10 sides' }, { value: '12', action: { title: '12 Sides' }, synonyms: 'twelve|12 sided|12 sides' }, - { value: '20', action: { title: '20 Sides' }, synonyms: 'twenty|20 sided|20 sides' }, + { value: '20', action: { title: '20 Sides' }, synonyms: 'twenty|20 sided|20 sides' } ]; builder.Prompts.choice(session, 'choose_sides', choices, { speak: speak(session, 'choose_sides_ssml') @@ -171,9 +172,9 @@ bot.dialog('PlayGameDialog', function (session, args) { var min = game.count; var max = game.count * game.sides; var score = total/max; - if (score == 1.0) { + if (score === 1.0) { reaction = 'best'; - } else if (score == 0) { + } else if (score === 0) { reaction = 'worst'; } else if (score <= 0.3) { reaction = 'bad'; @@ -182,7 +183,7 @@ bot.dialog('PlayGameDialog', function (session, args) { } // Check for special craps rolls - if (game.type == 'craps') { + if (game.type === 'craps') { switch (total) { case 2: case 3: @@ -203,7 +204,7 @@ bot.dialog('PlayGameDialog', function (session, args) { // Build up spoken response var spoken = ''; - if (game.turn == 0) { + if (game.turn === 0) { spoken += session.gettext('start_' + game.type + '_game_ssml') + ' '; } spoken += session.gettext(reaction + '_roll_reaction_ssml'); @@ -241,7 +242,7 @@ bot.customAction({ // to make sure we end that task. session.clearDialogStack().beginDialog('PlayGameDialog', { game: { type: 'craps', sides: 6, count: 2, turn: 0 } - }) + }); } }); diff --git a/Node/demo-RollerSkill/azuredeploy.json b/Node/demo-RollerSkill/azuredeploy.json index 044b78421d..23d9992473 100644 --- a/Node/demo-RollerSkill/azuredeploy.json +++ b/Node/demo-RollerSkill/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/demo-RollerSkill/package.json b/Node/demo-RollerSkill/package.json index ce12e68725..fcc9f21269 100644 --- a/Node/demo-RollerSkill/package.json +++ b/Node/demo-RollerSkill/package.json @@ -21,7 +21,8 @@ "url": "https://github.com/Microsoft/BotBuilder-Samples.git" }, "dependencies": { - "botbuilder": "^3.8.0-beta2", + "botbuilder": "^3.8.2", + "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 dca8e1feca..ea7cd29c7f 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.5.1", + "botbuilder": "^3.8.2", "lodash": "^4.17.4" } } diff --git a/Node/demo-Search/azuredeploy.json b/Node/demo-Search/azuredeploy.json index 51f688cb5c..cce841cf3d 100644 --- a/Node/demo-Search/azuredeploy.json +++ b/Node/demo-Search/azuredeploy.json @@ -50,7 +50,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" diff --git a/Node/demo-Search/package.json b/Node/demo-Search/package.json index a293aae0f3..9bf5c66eb9 100644 --- a/Node/demo-Search/package.json +++ b/Node/demo-Search/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "lodash": "^4.17.4", "lorem-ipsum": "^1.0.3", diff --git a/Node/intelligence-ImageCaption/README.md b/Node/intelligence-ImageCaption/README.md index 9f1a821217..cf98f07893 100644 --- a/Node/intelligence-ImageCaption/README.md +++ b/Node/intelligence-ImageCaption/README.md @@ -19,7 +19,7 @@ The minimum prerequisites to run this sample are: ### 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://dev.projectoxford.ai/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://api.projectoxford.ai/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: diff --git a/Node/intelligence-ImageCaption/app.js b/Node/intelligence-ImageCaption/app.js index 9e08940fab..105dca24af 100644 --- a/Node/intelligence-ImageCaption/app.js +++ b/Node/intelligence-ImageCaption/app.js @@ -131,6 +131,11 @@ function handleSuccessResponse(session, caption) { } function handleErrorResponse(session, error) { - session.send('Oops! Something went wrong. Try again later.'); + var clientErrorMessage = 'Oops! Something went wrong. Try again later.'; + if (error.message && error.message.indexOf('Access denied') > -1) { + clientErrorMessage += "\n" + error.message; + } + console.error(error); + session.send(clientErrorMessage); } \ No newline at end of file diff --git a/Node/intelligence-ImageCaption/azuredeploy.json b/Node/intelligence-ImageCaption/azuredeploy.json index 2c6446573a..435eaeae03 100644 --- a/Node/intelligence-ImageCaption/azuredeploy.json +++ b/Node/intelligence-ImageCaption/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MicrosoftAppId": { "type": "string" diff --git a/Node/intelligence-ImageCaption/caption-service.js b/Node/intelligence-ImageCaption/caption-service.js index 19c046e42e..1af1fe137e 100644 --- a/Node/intelligence-ImageCaption/caption-service.js +++ b/Node/intelligence-ImageCaption/caption-service.js @@ -5,7 +5,7 @@ var request = require('request').defaults({ encoding: null }); -var VISION_URL = 'https://api.projectoxford.ai/vision/v1.0/analyze/?visualFeatures=Description&form=BCSIMG&subscription-key=' + process.env.MICROSOFT_VISION_API_KEY; +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 @@ -18,17 +18,19 @@ exports.getCaptionFromStream = function (stream) { var requestData = { url: VISION_URL, 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 { + } else { resolve(extractCaption(JSON.parse(body))); } })); diff --git a/Node/intelligence-ImageCaption/package.json b/Node/intelligence-ImageCaption/package.json index daf2bf0229..5ea77f68de 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.7.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "needle": "^1.4.3", "request": "^2.79.0", diff --git a/Node/intelligence-LUIS/azuredeploy.json b/Node/intelligence-LUIS/azuredeploy.json index 570db581d9..ae456e768d 100644 --- a/Node/intelligence-LUIS/azuredeploy.json +++ b/Node/intelligence-LUIS/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MICROSOFT_APP_ID": { "type": "string" @@ -53,7 +53,6 @@ }, "LUIS_MODEL_URL": { "type": "string", - "defaultValue": "https://api.projectoxford.ai/luis/v1/application?id=162bf6ee-379b-4ce4-a519-5f5af90086b5&subscription-key=11be6373fca44ded80fbe2afa8597c18" }, "BING_SPELL_CHECK_API_KEY": { "type": "string", diff --git a/Node/intelligence-LUIS/package.json b/Node/intelligence-LUIS/package.json index 65bd0db91e..3f5c59ba87 100644 --- a/Node/intelligence-LUIS/package.json +++ b/Node/intelligence-LUIS/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "bluebird": "^3.4.7", - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "request": "^2.79.0", "restify": "^4.3.0" diff --git a/Node/intelligence-SimilarProducts/azuredeploy.json b/Node/intelligence-SimilarProducts/azuredeploy.json index a8590ba72d..77d9886be4 100644 --- a/Node/intelligence-SimilarProducts/azuredeploy.json +++ b/Node/intelligence-SimilarProducts/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MicrosoftAppId": { "type": "string" diff --git a/Node/intelligence-SimilarProducts/package.json b/Node/intelligence-SimilarProducts/package.json index 849153d5a2..4d2f152d16 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.7.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "request": "^2.79.0", "restify": "^4.3.0", diff --git a/Node/intelligence-SpeechToText/azuredeploy.json b/Node/intelligence-SpeechToText/azuredeploy.json index ff64987a55..f5ea46de50 100644 --- a/Node/intelligence-SpeechToText/azuredeploy.json +++ b/Node/intelligence-SpeechToText/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MicrosoftAppId": { "type": "string" diff --git a/Node/intelligence-SpeechToText/package.json b/Node/intelligence-SpeechToText/package.json index db3177f84d..ce1520f520 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.7.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "needle": "^1.4.3", "node-uuid": "^1.4.7", diff --git a/Node/intelligence-Zummer/azuredeploy.json b/Node/intelligence-Zummer/azuredeploy.json index 5ccb073797..edffa0317f 100644 --- a/Node/intelligence-Zummer/azuredeploy.json +++ b/Node/intelligence-Zummer/azuredeploy.json @@ -43,7 +43,7 @@ }, "WEBSITE_NODE_DEFAULT_VERSION": { "type": "string", - "defaultValue": "5.9.1" + "defaultValue": "6.9.5" }, "MicrosoftAppId": { "type": "string" diff --git a/Node/intelligence-Zummer/package.json b/Node/intelligence-Zummer/package.json index f37bc3e8d6..4310bfd67d 100644 --- a/Node/intelligence-Zummer/package.json +++ b/Node/intelligence-Zummer/package.json @@ -7,7 +7,7 @@ }, "author": "mmoussa", "dependencies": { - "botbuilder": "^3.5.3", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "memory-cache": "^0.1.6", "restify": "^4.3.0", diff --git a/Node/sample-knowledgeBot/package.json b/Node/sample-knowledgeBot/package.json index fd2fa9c9e7..aa7826d5fc 100644 --- a/Node/sample-knowledgeBot/package.json +++ b/Node/sample-knowledgeBot/package.json @@ -9,7 +9,7 @@ "author": "", "license": "ISC", "dependencies": { - "botbuilder": "^3.7.0", + "botbuilder": "^3.8.2", "request": "^2.78.0", "restify": "^4.2.0" } diff --git a/Node/sample-payments/package.json b/Node/sample-payments/package.json index 67994d6923..a01d322236 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.0", + "botbuilder": "^3.8.2", "dotenv-extended": "^1.0.4", "lodash": "^4.17.4", "restify": "^4.3.0",