botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[LUIS] User utterance hits LUIS only on the second time

Open saileshcts opened this issue 9 years ago • 3 comments

System Information (Required)

  • SDK Language: Node
  • SDK Version: Node 4.2.6
  • Development Environment: LOCALHOST/OTHER

Issue Description

The chatbot is being tested using a channel emulator. The conversation is initiated as shown below (U: user, B: Bot):

U: Hello B: Tell me your name U: Testuser B: Hi Testuser, how you doing ? U: Iam good

At this point, the control goes to the dialog handle, that hits the LUIS to obtain the intent classification of the utterance "Iam good". However, nothing happens on the first time. It hits the LUIS only when the user repeats the utterance for the second time.

From logging, it appears that the control moves to luis dialog handle at the very first time itself, but never goes on to hit the LUIS for intent classification. Please find the relevant log traces below:

Log trace when the user utters "Iam good" for the first time:

ChatConnector: message received.
UniversalBot("*") routing "Iam good" from "emulator"
Library("BotBuilder").findRoutes() explanation:
        ActiveDialog(0.5)
...BotBuilder:prompt-text - Prompt.returning(Iam good)
...BotBuilder:prompt-text - Session.endDialogWithResult()
../startSession - waterfall() step 2 of 2
../startSession - Session.beginDialog(/luis)
.../luis - Session.sendBatch() sending 0 message(s)

Log trace when the user utters "Iam good" for the second time:

ChatConnector: message received.
UniversalBot("*") routing "Iam good" from "emulator"
Library("*").findRoutes() explanation:
        ActiveDialog(0.4968815062675876)
.../luis - IntentDialog.matches(Good)
.../luis - Session.beginDialog(/userGood)
..../userGood - waterfall() step 1 of 1
..../userGood - Session.beginDialog(/userExisting)
...../userExisting - waterfall() step 1 of 2
...../userExisting - Session.beginDialog(BotBuilder:prompt-text)
......BotBuilder:prompt-text - Session.send()
......BotBuilder:prompt-text - Session.sendBatch() sending 1 message(s)

Code Example

var recognizer = new builder.LuisRecognizer(config.model);

var luisDialog = new builder.IntentDialog({ recognizers: [recognizer] });

var connector = new builder.ChatConnector({

    appId: config.BOTFRAMEWORK_APPID, 
    appPassword: config.BOTFRAMEWORK_APPSECRET

});

//code initiating conversation

/* User: Hello
Bot: Tell me your name
User: Testuser
Bot: Hi Testuser, how you doing ?
User: Iam good*/

// When the user says "I'm good", the control is passed to the dialog 'luis'

session.beginDialog('/luis');

// at the 'luis' dialog

academyDialog.dialog('/luis', 
luisDialog.onDefault(builder.DialogAction.send(prompts.default_response)));
luisDialog.matches('Good', '/userGood');

Steps to Reproduce

  1. Setup Nodejs as a webapp and use LUIS as the model for intent classification
  2. Use the conversation scenario provided in the issue description
  3. Test the conversation flow using channel emulator and try hitting LUIS for recognizing intent

Expected Behavior

The LUIS should receive the user utterance the very first time

Actual Results

LUIS receives the user utterance for intent classification only on the second time.

saileshcts avatar Jun 09 '17 06:06 saileshcts

Is your luisDialog plugged into your root dialog? e.g. academyDialog.('/', luisDialog);?

This aside, if you're just calling session.beginDialog(), it shouldn't send anything to LUIS. Are you trying to match an intent based on what the user says in response to "How are you doing?" If this is the case it would probably be better to take the session.message.text and use recognizer.recognize() to get the intent from LUIS, then place a switch statement in your callback for .recognize().

stevengum avatar Jun 12 '17 17:06 stevengum

Closing issue due to inactivity. If you are still having the issue, please feel free to leave a message here or post a question on Stack Overflow.

stevengum avatar Jun 16 '17 22:06 stevengum

Thanks! Sorry for the delay in responding as I was away. I'm now using recognizer.recognize() as suggested by @stevengum97 and it seems to work now. Thanks again!

saileshcts avatar Jun 19 '17 07:06 saileshcts