Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] prompts.choice is not working correctly with API.ai #2987

Closed
amitbend opened this issue Jun 20, 2017 · 11 comments
Closed

[Question] prompts.choice is not working correctly with API.ai #2987

amitbend opened this issue Jun 20, 2017 · 11 comments
Assignees

Comments

@amitbend
Copy link

amitbend commented Jun 20, 2017

System Information (Required)

  • SDK Language: Node
  • SDK Version: 8.3.4
  • Development Environment: LOCALHOST, AZURE_BOT_SERVICE

Issue Description

I recently added NLU to my messenger bot using API.ai. I have a choice prompt in my bot (prompts.choice()), with buttons builder.ListStyle['button'].

I noticed that few of the choices are not working - and retryPrompt is invoked, and it happens because they are being matched to an intent from API.ai.

I'm looking for a solution that will isolate prompts from the NLU model or a different workaround.

P.S. I'm using IntentRecognizerSet with 2 API.ai recognizers, maybe I can add the default recognizer as the first item in the set? (not sure how)

I tried to debug the library code and it seems like onRecognize function on PromptChoice detecting the right choice, and the issue comes somewhere later.

@nwhitmont nwhitmont changed the title prompts.choice is not working correctly with NLU [Question] prompts.choice is not working correctly with NLU Jun 20, 2017
@nwhitmont nwhitmont changed the title [Question] prompts.choice is not working correctly with NLU [Question] prompts.choice is not working correctly with API.ai Jun 20, 2017
@nwhitmont
Copy link
Contributor

@amitbend
Copy link
Author

@nwhitmont alright, closing

@amitbend amitbend reopened this Jun 21, 2017
@amitbend
Copy link
Author

Reopened - no response on stackoverflow.

@stevengum stevengum self-assigned this Jun 22, 2017
@stevengum
Copy link
Member

Can you provide your code so we can see it?

@amitbend
Copy link
Author

amitbend commented Jun 23, 2017

Sure,
the prompt looks like this:
(session, results, next) => { builder.Prompts.choice( session, 'Choose one:', Object.keys(choicesObj), { maxRetries: 1, retryPrompt: 'We do not have info regarding that subject', listStyle: builder.ListStyle['button'] }); },
It is a part of a library.

the recognizer looks like:
var r1 = new apiairecognizer('key1'); var r2 = new apiairecognizer('key2');
let set = new builder.IntentRecognizerSet({ recognizeOrder: builder.RecognizeOrder.series,stopIfExactMatch: true }) .recognizer(r1).recognizer(r2)

@stevengum
Copy link
Member

Just to clarify, the user's response to the prompt is unrecognized because of the API.AI recognizers activating and returning matched intents?

How are you plugging set into your bot? Are you using bot.recognizers = set; ?

@amitbend
Copy link
Author

amitbend commented Jun 25, 2017

@stevengum97 yes, I can see there is a matched intent (without any action attached)
I'm plugging it to the bot this way: bot.recognizer(set)
where bot is my universalBot

@stevengum
Copy link
Member

stevengum commented Jun 26, 2017

@amitbend it looks like it's similar to #2839 except you're wanting the recognizers to not fire/return an intent? You're aiming to stay inside of your current prompt and move through it without any interruptions, if I understand correctly.

To handle this using the regular LuisRecognizer, I would use .onEnabled() (sample here), but this method doesn't exist in api-ai-recognizer.

I recommend taking the source code from there and creating a custom recognizer/adding to the instantiated api-ai-recognizers a similar method. For the case that enables/disables the recognizer, a check on the dialogStack would work well. Check if its length >= 1, if so disable the recognizers, as you're in a dialog and don't want to be interrupted.

You could also create a custom prompt; this way you should be able to also ignore results from API.ai.

Since the issue is regarding api-ai-recognizer (third-party) and a solution exists for this case (LuisRecognizer.onEnabled() or creating a custom prompt) in BotBuilder SDK, I'm closing this issue for now. An alternative you could work with is placing the recognizers into an IntentDialog instead of having them at bot level, but this would change other aspects of how the bot works.

@amitbend
Copy link
Author

@stevengum97 thanks for the informative answer.
It seems to be a variation of #2839, in my case, it does not either switch to the other dialog that capture the intent or matching it to one of the choices.
I will check out the solutions that you've mentioned and provide an update later.

@vishmonne
Copy link

hi @stevengum can u help me in how to disable the luisRecognizer using .onEnabled() . i am not finding the solution code anywhere. Would be really helpful

@EricDahlvang
Copy link
Member

Hi @vishmonne

The example @stevengum shared can be found here: https://github.com/Microsoft/BotBuilder-v3/blob/master/Node/examples/feature-onEnabled/app.js

Another example can be found here: #2670 (comment)

You can also use .onFilter, as explained here: #3530 (comment)


The Microsoft Bot Framework team prefers that how to questions be submitted on Stack Overflow so the entire community can benefit from the answer.
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants