Skip to content

Commit

Permalink
Add example with intents and entities
Browse files Browse the repository at this point in the history
  • Loading branch information
jdnichollsc committed Apr 21, 2018
1 parent a233458 commit cea68be
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/nodejs/bot/dialogs/movieBook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const _ = require('lodash')
const builder = require('botbuilder')

const movieBook = (bot) => {

return bot.dialog('MovieTickets.Book', [
(session, args, next) => {
var intent = args.intent
var title = builder.EntityRecognizer.findEntity(intent.entities, 'MovieTickets.MovieTitle')

var movie = session.dialogData.movie = {
title: title ? title.entity : ''
}

session.endDialog('movie_selected', movie.title)
//https://docs.microsoft.com/en-us/azure/cognitive-services/luis/luis-nodejs-tutorial-build-bot-framework-sa
//https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-recognize-intent-luis
}
]);
}

module.exports = {
init: movieBook
}
5 changes: 5 additions & 0 deletions src/nodejs/bot/luis.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const luisAppIdSpanish = process.env['LuisAppId_Spanish'] || localConf.LuisAppId
const luisAPIKey = process.env['LuisAPIKey'] || localConf.LuisAPIKey
const luisAPIHostName = process.env['LuisAPIHostName'] || localConf.LuisAPIHostName

const dialogs = require('require-all')(__dirname + '/dialogs')

const _initialize = (bot) => {

const recognizer = new builder.LuisRecognizer({
Expand All @@ -28,6 +30,9 @@ const _initialize = (bot) => {
})
bot.recognizer(recognizer)

const movieBook = dialogs.movieBook.init(bot)
movieBook.triggerAction({ matches: 'MovieTickets.Book' })

bot.dialog('/greeting', (session) => session.send('greetings'))
.triggerAction({ matches: 'Greeting' })

Expand Down
3 changes: 2 additions & 1 deletion src/nodejs/locale/en/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
],
"enable_luis": "Enable LUIS",
"luis_enabled": "LUIS enabled, you can say hi! (exit to disable)",
"dont_understand_you": "I don't understand you, what?"
"dont_understand_you": "I don't understand you, what do you want?",
"movie_selected": "The user want's to see the movie: %s"
}
3 changes: 2 additions & 1 deletion src/nodejs/locale/es/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
],
"enable_luis": "Habilitar LUIS",
"luis_enabled": "LUIS habilitado, puedes saludar! (exit para deshabilitar)",
"dont_understand_you": "No te entiendo, qué?"
"dont_understand_you": "No te entiendo, qué quieres?",
"movie_selected": "El usuario quiere ver la película: %s"
}

0 comments on commit cea68be

Please sign in to comment.