mycroft-skills icon indicating copy to clipboard operation
mycroft-skills copied to clipboard

New Skill: CatchAll Fallback asks to repeat phrase when no intent determined

Open auwsom opened this issue 4 years ago • 5 comments

Following the docs on Fallbacks here: https://mycroft-ai.gitbook.io/docs/skill-development/skill-types/fallback-skill, and the example here: https://github.com/forslund/fallback-meaning, and figuring out the correct syntax by trial and error here: https://github.com/MycroftAI/mycroft-core/issues/2611, and adding the following lines of code (the second part replacing the Arthur Dent intent finding), the fallback now asks a follow up question 'What was that?' whenever an intent cannot be determined. (several variation on that vocab could be added to the self.speak_dialog('CatchAllFallback')

from mycroft.messagebus.message import Message
.....
    def handle_fallback(self, message):
        self.speak('what was that?')
        self.bus.emit(Message('recognizer_loop:wakeword', {"utterance": "homie"}))
        return True

I had started it in the fallback-unknown skill, but didnt want it to tell me to 'Please wait a moment as I finish booting up'.. which is coming from def make_intent_failure_handler in mycroft/skills/fallback_skill.py

@forslund , I'm actually debugging it right now.. I didnt realize the it is overriding other skills until I started working on another one. Any suggestion on how to catch just everything that isnt a skill intent? I thought that was what the fallbacks did, but your example uses several word verification steps.

auwsom avatar Jun 07 '20 18:06 auwsom

Actually, just putting:

        self.speak('what was that?')
        self.bus.emit(Message('mycroft.mic.listen'))
        return True

in place of: #self.speak_dialog('unknown') in fallback-unknown seems to work..

auwsom avatar Jun 07 '20 18:06 auwsom

Hey, we strongly encourage the use of dialog and vocab files rather than having the messages directly in the code. It is generally easier to read the code, and makes it translatable for those using Mycroft in other languages.

Did you have a dialog/en-us/unknown.dialog file for the above?

krisgesling avatar Jun 08 '20 00:06 krisgesling

@krisgesling , yes, I see those there. In the back of my mind I figured they were for localization.

However, as skills scale up, starting complex drastically increases complexity. For example, I will be trying to create a skill that creates other skills. It will be much. much easier to accomplish that small feat with a simplified 'seed' skill, that references a single file holding json data for all intents, dialog, vocab, etc.. than trying to create and write to all those files.. localization could be done within that..

Step by step Im appreciating the complexity (and therefore power) of mycroft, but I always try to start dirt simple, because it has saved me from overcomplicating code many times. That said, I may have to come back to some of the builtin complexity of mycroft as I learn more functionality. ..until then though, Im hoping not.. ;)

..so I hope you can see the counterargument for not using all those various files.. and not trying to cause any rifts here, as were all on the same team! just explaining

auwsom avatar Jun 08 '20 00:06 auwsom

Speaking of, I need to understand 'contexts' next, and/or how I can use some kind of fallback skill to catch all commands of a single context, without having the commands overlap intents, Open Chrome vs Open Homepage or Open file for example.

auwsom avatar Jun 08 '20 00:06 auwsom

Yeah totally understand starting simple and building up :)

For contexts, the docs need some love but here are some example skills to give you an idea:

However for the open examples, I'd probably use Adapt intents, each would require two keywords

  1. "open"
  2. [ application, webpage, file ]

I believe someone else took a similar approach and dynamically generated the 2nd keyword but I can't find it right now :(

krisgesling avatar Jun 08 '20 01:06 krisgesling