Comment on page
A Fallback Skill is a Skill that will be called if no Intent is matched to the Utterance.
The Fallback Skills all have a priority and will be checked in order from low priority value to high priority value. If a Fallback Skill can handle the Utterance it will create a response and return
True. After this no other Fallback Skills are tried. This means the priority for Fallbacks that can handle a broad range of queries should be high (80-100) and Fallbacks that only responds to a very specific range of queries should be higher (20-80). The more specific, the lower the priority value.
from mycroft import FallbackSkill
Create a derived class:
A Fallback skill to answer the question about the
meaning of life, the universe and everything.
super(MeaningFallback, self).__init__(name='My Fallback Skill)
# Add your own initialization code here
Register the handler with the fallback system
FallbackSkillcan register any number of fallback handlers
Registers the fallback handler
# Any other initialize code you like can be placed here
Implement the fallback handler (the method that will be called to potentially handle the Utterance). The method implements logic to determine if the Utterance can be handled and shall output speech if itcan handle the query. It shall return Boolean
Trueif the Utterance was handled and Boolean
def handle_fallback(self, message):
Answers question about the meaning of life, the universe
utterance = message.data.get("utterance")
if 'what' in utterance
and 'meaning' in utterance
and ('life' in utterance
or 'universe' in utterance
or 'everything' in utterance):
Finally, the Skill creator must make sure the skill handler is removed when the Skill is shutdown by the system.
Remove this skill from list of fallback skills.
And as with a normal Skill the function
create_skill()needs to be in the file to instantiate the skill.