| /* INTENT HANDLERS */ | |
| // Add a dialog for each intent that the LUIS app recognizes. | |
| // See https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-recognize-intent-luis | |
| bot.dialog('GreetingDialog', | |
| (session) => { | |
| const WELCOME_TEXT_LONG = `You can say things like: \n` + | |
| `_'Tell me about Azure certifications.'_ \n` + | |
| `_'When was Azure released?'_ \n` + | |
| `_'Give me a random fact.'_`; | |
| let botResponse = { | |
| title: 'What would you like to know about Microsoft Azure?', | |
| response: WELCOME_TEXT_LONG, | |
| image: 'image-16.png' | |
| }; | |
| let card = createThumbnailCard(session, botResponse); | |
| let msg = new builder.Message(session).addAttachment(card); | |
| // let msg = botResponse.response; | |
| session.send(msg).endDialog(); | |
| } | |
| ).triggerAction({ | |
| matches: 'Greeting' | |
| }); | |
| bot.dialog('HelpDialog', | |
| (session) => { | |
| const FACTS_LIST = "Certifications, Cognitive Services, Competition, Compliance, First Offering, Functions, " + | |
| "Geographies, Global Infrastructure, Platforms, Categories, Products, Regions, and Release Date"; | |
| const botResponse = { | |
| title: 'Need a little help?', | |
| response: `Current facts include: ${FACTS_LIST}.`, | |
| image: 'image-15.png' | |
| }; | |
| let card = createThumbnailCard(session, botResponse); | |
| let msg = new builder.Message(session).addAttachment(card); | |
| session.send(msg).endDialog(); | |
| } | |
| ).triggerAction({ | |
| matches: 'Help' | |
| }); | |
| bot.dialog('CancelDialog', | |
| (session) => { | |
| const CANCEL_RESPONSE = 'Goodbye.'; | |
| session.send(CANCEL_RESPONSE).endDialog(); | |
| } | |
| ).triggerAction({ | |
| matches: 'Cancel' | |
| }); | |
| bot.dialog('AzureFactsDialog', | |
| (session, args) => { | |
| let query; | |
| let entity = args.intent.entities[0]; | |
| let msg = new builder.Message(session); | |
| if (entity === undefined) { // unknown Facts entity was requested | |
| msg = 'Sorry, you requested an unknown fact.'; | |
| console.log(msg); | |
| session.send(msg).endDialog(); | |
| } else { | |
| query = entity.resolution.values[0]; | |
| console.log(`Entity: ${JSON.stringify(entity)}`); | |
| buildFactResponse(query, function (document) { | |
| if (!document) { | |
| msg = `Sorry, seems we are missing the fact, '${query}'.`; | |
| console.log(msg); | |
| } else { | |
| let card = createThumbnailCard(session, document); | |
| msg = new builder.Message(session).addAttachment(card); | |
| } | |
| session.send(msg).endDialog(); | |
| }); | |
| } | |
| } | |
| ).triggerAction({ | |
| matches: 'AzureFacts' | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment