Skip to content

Commit

Permalink
Fixed bug with recognizers being called twice.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevenic committed Feb 2, 2017
1 parent 21bf1b3 commit d795866
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 2 additions & 4 deletions Node/core/src/bots/Library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,10 @@ export class Library extends EventEmitter {
// top intent is passed along as part of routing. The root libraries recognize()
// method will be called a second time so we want to avoid the second recognize
// pass.
var skipRecognize = (context.intent && context.libraryName === this.name);
if (this.recognizers.length > 0 && !skipRecognize) {
if (this.recognizers.length > 0 && context.libraryName !== this.name) {
this.recognizers.recognize(context, callback);
} else {
// Pass through the top intent recognized by the root libraries recognizers.
callback(null, context.intent);
callback(null, context.intent || { intent: 'None', score: 0.0 });
}
}

Expand Down
12 changes: 6 additions & 6 deletions Node/core/src/bots/UniversalBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,12 @@ export class UniversalBot extends Library {
// Run the root libraries recognizers
var context = session.toRecognizeContext();
this.recognize(context, (err, topIntent) => {
if (topIntent && topIntent.score > 0) {
// This intent will be automatically inherited by child libraries
// that don't implement their own recognizers.
context.intent = topIntent;
context.libraryName = this.name;
}
// This intent will be automatically inherited by child libraries
// that don't implement their own recognizers.
// - We're passing along the library name to avoid running our own
// recognizer twice.
context.intent = topIntent;
context.libraryName = this.name;

// Federate across all libraries to find the best route to trigger.
var results = Library.addRouteResult({ score: 0.0, libraryName: this.name });
Expand Down

0 comments on commit d795866

Please sign in to comment.