Last active
July 28, 2017 11:37
-
-
Save jazzedge/23fc1e2665e253e659375d8f00a4c0dc to your computer and use it in GitHub Desktop.
Bot - Luis and Regex recognizers and intents together
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
| // See: https://github.com/Microsoft/BotBuilder/issues/2456 | |
| // Install a custom recognizer to look for user saying 'help' or 'goodbye'. | |
| // Set the recognizeOrder to 'series', use RegExpRecognizers and the LuisRecognizer | |
| // Using 'series' stops the service checking Luis if the Hello or Hi recognizers return a positive | |
| // Without 'series', all of the recognizers including Luis are checked | |
| var recognizer = new builder.LuisRecognizer(model); | |
| var regExHi = new builder.RegExpRecognizer('Hi', /^hi$/i); | |
| var regExHello = new builder.RegExpRecognizer('Hello', /^hello$/i); | |
| var intent = new builder.IntentDialog({ recognizers: [regExHello, regExHi, recognizer], recognizeOrder: 'series' }) | |
| .matches('Hello',(session,args)=>{ | |
| console.log(args); | |
| session.send('hello recognizer'); | |
| }) | |
| .matches('Hi',(session,args)=>{ | |
| console.log(args); | |
| session.send('hi recognizer'); | |
| }).matches('Greet', (session,args) => { | |
| console.log(args); | |
| session.send('greet found by luis'); | |
| }); | |
| var bot = new builder.UniversalBot(connector); | |
| bot.dialog('/', intent).onDefault(session => session.send('no match found')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment