question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Forward Dialog utterance and parameters when doing a LUIS Intent redirection

See original GitHub issue

I have implemented the onDefault action to handle all the utterances that are not matched elsewhere. I have added a grammar spell checker, so that I could fix typos by the user like

quute by adele that is not understood by LUIS, by a simple grammar can turn this in the right one that is quote by adele. At this point, I’m going to suggest the user if the correction is the right one prompting it:

var msg = "You typed " + result.text + "\nDid you mean \""+result.correction+"\"?"
BotBuilder.Prompts.text(session, msg );

and as soon as the user type yes I would like to reenter the dialog with this query, but I do not see a way to do this:

 function (session, results)
          {

           var response=results.response;
            if ( response == 'yes' ) {
              //@TODO redo query
              session.beginDialog('/');
            }
            else {
              session.send( self.getLocalizedString('RESPONSE_DISCARD','RESPONSE_DISCARD') );
            }

          }

For my understanding I can define redirects like

.on('DeleteTask', '/deleteTask')

Using the Session userData object I can add parameters like

session.userData.correct =  {
                      text : result.text,
                      correct : result.correction
                    };

in a session, and that’s ok, but how to forward the user utterance as well properly in order to force to the right redirect i.e. force LUIS Dialog to the right route programmatically or to express this differently:

Given an utterance programmatically, is in the botframework api a way to get the matching Intent objects back from LUIS dialog model?

Here is the code callbacks in the onDefault.

self.dialog.onDefault(
        [
          function(session, args, next)
          {

            // Check query grammar
            var message = session.message.text;
            console.log("Checking grammar on %s", message);
            self.languageBot.spellChecker(message, function(result,error) {
                if(error) { // grammar error
                  self.logger.error("Failed to check grammar for %s", message);
                  session.send( self._options.locale['RESPONSE_NOTUNDERSTOOD'] )
                } else { // grammar passed
                  if( result.text != result.correction ) { // misspelling
                    var msg = "You typed " + result.text + "\nDid you mean \""+result.correction+"\"?"
                    session.userData.correct =  {
                      text : result.text,
                      correct : result.correction
                    };
                    BotBuilder.Prompts.text(session, msg );
                  }
                  else {
                    session.send( self._options.locale['RESPONSE_NOTUNDERSTOOD'] )
                  }
                }
            });


          }
          ,  function (session, results)
          {

           var response=results.response;
            if ( response == 'yes' ) {
              //@TODO redo query
              session.beginDialog('/');
            }
            else {
              session.send( self.getLocalizedString('RESPONSE_DISCARD','RESPONSE_DISCARD') );
            }

          }
        ]);

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Steveniccommented, Apr 28, 2016

So I guess I have one more suggestion. You can teach LUIS to recognize these misspellings. When you first train your LUIS model it’s going to pretty much suck. The idea is you have to regularly go back and update your model by labeling all of the utterances it’s been seeing, including the ones with misspellings, and then retrain and deploy a new model . If you do this it will quickly get better and eventually it’ll will handle pretty much any misspellings the user throws at it. Honestly you shouldn’t need to add your own spell checking logic as a way to deal with unrecognized intents. Just be religious about updating your model every day the first few weeks/months your bot is deployed.

Its also useful to just let a few people kick the tires by throwing your bot some messages you didn’t think of. It’s going to suck at first but it will quickly get better.

2reactions
Steveniccommented, Apr 28, 2016

Interesting… First let me answer your core question and then I have one other suggestion…

To answer your question you’d want to use session.replaceDialog() instead of session.beginDialog() that will unload and reload the current dialog. To apply the correction just assign it to session.message.text before calling replaceDialog() That should do what you’re trying to do.

My other suggestion is to use Prompts.confirm() instead of Prompts.text(). This prompt already knows to look for several variants of the yes & no. The returned result.response will be a simple Boolean so way easier to check.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Forward Dialog utterance and parameters when doing a LUIS ...
Given an utterance programmatically, is in the botframework api a way to get the matching Intent objects back from LUIS dialog model? Here...
Read more >
C# Microsoft Bot Framework with luis result directing to QNA ...
I think the best way to handle dialog redirection by intent is to make something like an IntentDetectorDialog whose only job is to...
Read more >
How to use intents in LUIS - Azure Cognitive Services
In the Create new intent dialog box, enter the intent name, for example ModifyOrder, and select Done. A screenshot showing the add intent...
Read more >
Intent redirection - Android Developers
An intent redirection occurs when an attacker can partly or fully control the contents of an intent used to launch a new component...
Read more >
Build a Doctor Appointment Bot with Azure Bot Service ... - Twilio
Learn how to build an SMS booking system using Twilio, Azure Bot ... by dialogs to extract intents and entities from a user's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found