ApiAiRecognizer icon indicating copy to clipboard operation
ApiAiRecognizer copied to clipboard

Smalltalk intents don't work

Open GanadiniAkshay opened this issue 7 years ago • 12 comments

Due to changes on api.ai side the old method of handling api.ai doesn't work

GanadiniAkshay avatar Jun 02 '17 19:06 GanadiniAkshay

Using the preBuilt Smalltalk agent, it is possible to recognize them. they will have the name smalltalk.agent.XXX

amitbend avatar Jun 12 '17 14:06 amitbend

Would it be acceptable to add something like this: if(result.action.includes('smalltalk')) result.action = 'smalltalk'; intent = { score: result.score, intent: result.action, entities: entities_found };

bradleyscott avatar Jun 16 '17 09:06 bradleyscott

@bradleyscott Yes I think that would be the way to go for now. It would be great if you could send in a PR now, I am a little busy and it might take some time for me to add this fix.

GanadiniAkshay avatar Jun 17 '17 23:06 GanadiniAkshay

Unfortunately I have found some problems with that strategy. When API.ai detects cancellation intents you would want to handle that differently to the smalltalk.agent responses.

bradleyscott avatar Jul 01 '17 00:07 bradleyscott

I tried using a regular expression but it doesn't work

First I tried with the whatIsWeather intent handler: intents.matches(/whatIsWeather/i, (session, args, next) => { session.send("It's 27 degrees celsius"); });

Any ideas why this doesn't work?

If regular expression can be used then the smalltalk.greetings..* reg ex can be used

Also is there a way to figure out the original API AI classified intent name (and other values) when the onDefault handler is called?

bigman73 avatar Apr 17 '18 18:04 bigman73

You're doing it wrong. Regex should be used as an alternative method to NLU. If the name of your intent is whatIsWeather , you should write it this way -> intents.matches('whatIsWeather', ....)

On Tue, Apr 17, 2018 at 9:27 PM, Yuval Naveh [email protected] wrote:

I tried using a regular expression but it doesn't work

First I tried with the whatIsWeather intent handler: intents.matches(/whatIsWeather/i, (session, args, next) => { session.send("It's 27 degrees celsius"); });

Any ideas why this doesn't work?

If regular expression can be used then the smalltalk.greetings..* reg ex can be used

Also is there a way to figure out the original API AI classified intent name (and other values) when the onDefault handler is called?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GanadiniAkshay/ApiAiRecognizer/issues/8#issuecomment-382094778, or mute the thread https://github.com/notifications/unsubscribe-auth/AKvNgeSJrTGYLr2NBGCiSMuw2qBVGNBeks5tpjQggaJpZM4NutP8 .

amitbend avatar Apr 17 '18 18:04 amitbend

@amitbend the topic of this issue is that the small talk intents are not working If we could catch all intents that match the format smalltalk.agent.* then the issue will be resolved We could build a specific intent handler for each small talk, but what if we just want to handle all small talk in a generic way?

The matches() API is documented to support a regular expression parameter but for some reason it is not working

bigman73 avatar Apr 17 '18 19:04 bigman73

Try writing exactly whatIsWeather in the chat and see if you get the right response. Also, post more code here. it might be something with the way you've configured it

amitbend avatar Apr 18 '18 06:04 amitbend

@bigman73 from what I understand passing regex into intent.matches() doesn't compare the regex with the intent name but the actual message sent by the user which is why it wouldn't work

GanadiniAkshay avatar Apr 18 '18 09:04 GanadiniAkshay

Thanks @GanadiniAkshay Now I get the problem. It looks like an odd design decision by Microsoft - one function does two very different logic depending on a parameter. It should have been matchesByName and matchesByContent I guess this is an issue I need to open with BotBuilder.

Do you have any idea how the original intent name can be extracted in the default intent provider?

bigman73 avatar Apr 18 '18 12:04 bigman73

Here's how I solved it ` let intentName = result.action;

            if (intentName.startsWith('smalltalk.')) {
                intentName = 'smalltalk.';
            }
            intent = { score: result.score, intent: intentName, entities: entities_found, 
                            original_intent: result.action };

`

The original_intent keeps the unmodified intent name as it comes out of API.AI This technique allows the handler to be generic for all small talk intents and yet have access to the original intent name if needed: intents.matches('smalltalk.', function (session, args) { session.send(args.entities[0].entity); });

I can create a pull request if this makes sense

bigman73 avatar Apr 23 '18 14:04 bigman73

Do you have an example of how this works altogether in code? I'm getting this error:

WARN: IntentDialog - no intent handler found for smalltalk.emotions.wow

robbiew avatar Aug 16 '18 04:08 robbiew