This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This function returns a string indicating if it is morning, afternoon or evening. | |
| function amPm () { | |
| const date = new Date().getHours(); | |
| console.log ('Date:', date); | |
| var period = 'evening'; | |
| if (date < 12) { | |
| period = "morning"; | |
| } else { | |
| if (date < 18){ | |
| period = "afternoon"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://github.com/Microsoft/BotBuilder-Samples/blob/master/Node/demo-ContosoFlowers/README.md | |
| // The SDK also provides a way to configure the default bot's locale: | |
| // Set default locale | |
| bot.set('localizerSettings', { | |
| botLocalePath: './bot/locale', | |
| defaultLocale: 'en' | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var bot = new builder.UniversalBot(connector, function (session) { | |
| var cards = getCardsAttachments(); | |
| // create reply with Carousel AttachmentLayout | |
| var reply = new builder.Message(session) | |
| .attachmentLayout(builder.AttachmentLayout.carousel) | |
| .attachments(cards); | |
| session.send(reply); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| byte[] imagedata = {image} | |
| var image64 = "data:image/jpeg;base64," + Convert.ToBase64String(imagedata); | |
| reply.Attachments.Add(new Attachment() | |
| { | |
| ContentUrl = image64, | |
| ContentType = "image/jpeg", | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Display BASE64 file - https://stackoverflow.com/questions/8499633/how-to-display-base64-images-in-html | |
| <img src=' ... '/> | |
| static void BlobUrl() | |
| { | |
| var account = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true); | |
| var cloudBlobClient = account.CreateCloudBlobClient(); | |
| var container = cloudBlobClient.GetContainerReference("container-name"); | |
| var blob = container.GetBlockBlobReference("image.png"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Vision API test | |
| // Build the url we'll be calling to get top news | |
| var url = "https://westeurope.api.cognitive.microsoft.com/vision/v1.0/describe/"; | |
| // Build options for the request | |
| session.send(attachment.contentUrl + '/' + attachment.name); | |
| var options = { | |
| method: 'POST', // thie API call is a post request | |
| uri: url, | |
| headers: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bot.on('conversationUpdate', function (message) { | |
| if (message.membersAdded) { | |
| message.membersAdded.forEach(function (identity) { | |
| if (identity.id === message.address.bot.id) { | |
| bot.send(new builder.Message() | |
| .address(message.address) | |
| .text("Hello! I'm a bot.")); | |
| } | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| session.sendTyping(); | |
| bot.use(builder.Middleware.sendTyping()); //Bug: doesn't seem to work: https://github.com/Microsoft/BotBuilder/issues/1278 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ---------------------------------------------------------------------------------------------------- | |
| // Calculates the maximum depth of a JSON object. You must pass the string before converting it to JSON! | |
| function getDepth(obj) { | |
| var depth = 0; | |
| var maxDepth = 0; | |
| var i = 0; | |
| while (i < obj.length) | |
| { | |
| switch (obj.substr(i,1)) { | |
| case "{": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // You can either set your preferred Locale like this (default is en if you dont do anything) | |
| session.preferredLocale("en"); | |
| // Allow user to set locale | |
| if (!session.userData['BotBuilder.Data.PreferredLocale']) { | |
| session.beginDialog('/localePicker'); | |
| } | |
| localePicker.js | |
| let builder = require("botbuilder") |