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.dialog('email', [ | |
| function (session, results) { | |
| builder.Prompts.text(session, 'What is your email address?'); | |
| }, | |
| function (session, results) { | |
| var validEmail = helpers.isEmailAddress(results.response); | |
| console.log('EMAIL VALIDATION: ', validEmail); | |
| if (validEmail == false) { | |
| session.say('That is not a valid email address.'); | |
| session.replaceDialog('email'); |
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
| //End Conversation and clear all data (restart the conversation completely) | |
| bot.dialog('reset', function (session) { | |
| session.dialogData = {}; | |
| session.userData = {}; | |
| session.conversationData = {}; | |
| session.privateConversationData = {}; | |
| session.endConversation("End Conversation"); | |
| }).triggerAction({ matches: /^(exit)|(quit)|(goodbye)|(finish)|(stop)|(end)|(terminate)/i }); |
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.dialog('help', function (session, args, next) { | |
| session.endDialog("I'm a virtual assistant that can help decide whether or not you require planning permission for a loft. <br/>Please say 'ok' to continue"); | |
| }) | |
| .triggerAction({ | |
| matches: /^help$/i, | |
| onSelectAction: (session, args, next) => { | |
| // Add the help dialog to the dialog stack | |
| // (override the default behavior of replacing the stack) | |
| session.beginDialog(args.action, args); | |
| } |
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
| //DEMO-QNA2.JS | |
| // Demonstrates use of the QnA Service | |
| // Combines: | |
| //https://stackoverflow.com/questions/42629688/begin-dialog-with-qna-maker-bot-framework-recognizer-node-js | |
| //and | |
| //https://github.com/Microsoft/BotBuilder-CognitiveServices/blob/master/Node/samples/QnAMakerSimpleBot/app.js | |
| 'use strict'; | |
| // 01. Include required files | |
| require('dotenv-extended').load(); |
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.dialog('greetings', [ | |
| // Step 1 | |
| function (session, args, next) { | |
| builder.Prompts.text(session, 'Hi! What is your name?'); | |
| }, | |
| // Step 2 | |
| function (session, args, next) { | |
| session.endDialog('Hello %s!', args.response); | |
| } | |
| ]); |
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.dialog('/', [ | |
| function (session) { | |
| var msg = new builder.Message(session) | |
| .text("Thank you for expressing interest in our premium golf shirt! What color of shirt would you like?") | |
| .suggestedActions( | |
| builder.SuggestedActions.create( | |
| session, [ | |
| builder.CardAction.imBack(session, "green", "green"), | |
| builder.CardAction.imBack(session, "blue", "blue"), |
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
| //Dialog when user joins conversation | |
| var cFirstRun = true; | |
| bot.on('conversationUpdate', function (message) { | |
| if (cFirstRun == true) { | |
| cFirstRun = false; | |
| var reply = new builder.Message() | |
| .address(message.address) //Required | |
| .text("This is Yaddop's Geography Chatbot") | |
| .addAttachment({ | |
| contentUrl:"https://roccobot02gghwh4.blob.core.windows.net/images/chatbot1.jpg", |
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
| console.log("Channel:", session.message.address.channelId); |
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
| 'use strict'; | |
| // 01. Include required files | |
| require('dotenv-extended').load(); | |
| var restify = require('restify'); | |
| var builder = require('botbuilder'); | |
| // 02. Setup Restify Server | |
| var server = restify.createServer(); | |
| // 03. Configure listen for messages |
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
| // Call like this: | |
| var r = randomInt(1,10); | |
| //Display like this: | |
| session.send ('Random n.'+ r); // Use the plus sign, not a comma. | |
| // Generate a random integer between low and high | |
| function randomInt (low, high) { | |
| return Math.floor(Math.random() * (high - low) + low); | |
| } |