Using @intent_handler , intent not registering

Hi All,

Hardware:
Macbook pro -> Ubuntu 16.04.2 VM

I am currently trying to make a sample skill based off the new intent handler decorators. I have written a init.py file that can be seen at the bottom of the post (its short I swear!). This is located in /opt/mycroft/skills/skill-test. In the skill-test folder i have also included a vocab file in the location /opt/mycroft/skills/skill-test/vocab/en-us/TestNew.voc. In this file i have one utterance “this is a test”. When i run the following (./start.sh services, ./start.sh skills, ./start.sh voice, ./start.sh cli), I enter “this is a test” into the cli, and my intent associated with the utterance can not be found.

I believe the intent is not being registered.

Per documentation I think i am implementing my skill correctly, but obviously i am not.

Any suggestions here on what i may be doing wrong and how I can get this intent to register using intent decoders?

Thanks!

Heres the Code:


from mycroft.skills.core import MycroftSkill
from mycroft.skills.core import intent_handler, intent_file_handler
from adapt.intent import IntentBuilder

class NewTestSkill(MycroftSkill):

def __init__ (self):
      super(NewTestSkill, self).__init__(name="NewTestSkill")

@intent_handler(IntentBuilder('a').require('TestNew').build())
def new_handler(self, message):
      self.speak("yo yo yo")

def stop(self):
      pass

def create_skill():
      return NewTestSkill

I see one error,

the bottom line should be
return NewTestSkill()

also the indentation is off for the def lines inside the class. (but that may be some issue with the copy paste.

With those two changes I can load your skill and get it to reply “Yo yo yo” just like an old school hip hop star :slight_smile:

Thank you for your quick response and help.

Can’t believe i missed the parenthesis.

I ended up making the change and retesting, and the intent is still not recognized.

I noticed i can see the utterance and Intent being registered:

- SKILLS - DEBUG - {"type": "register_vocab", "data": {"start": "this is a test", "end": "TestNew"}, "context": null}
- SKILLS - DEBUG - {"type": "register_intent", "data": {"at_least_one": [], "requires": [["TestNew", "TestNew"]], "optional": [], "name": "-7533786709289821694:TestIntent"}, "context": null}
    Registering: {u'at_least_one': [], u'requires': [[u'TestNew', u'TestNew']], u'optional': [], u'name': u'-7533786709289821694:TestIntent'}

I also noticed it says the skill is loaded. If i understand correctly the warning “No initialize function implemented” doesnt matter because @intent_handler is doing that:

- mycroft.skills.core:load_skill:121 - INFO - ATTEMPTING TO LOAD SKILL: skill-test-new with ID -7533786709289821694
- mycroft.skills.core:init_dialog:508 - DEBUG - No dialog loaded, /opt/mycroft/skills/skill-test-new/dialog/en-us does not exist
- mycroft.skills.core:initialize:285 - DEBUG - No initialize function implemented
- mycroft.skills.core:load_skill:137 - INFO - Loaded skill-test-new

My cli query:

- SKILLS - DEBUG - {"type": "recognizer_loop:utterance", "data": {"lang": "en-us", "utterances": ["this is a test"]}, "context": null}
- mycroft.skills.intent_service:handle_utterance:241 - ERROR -
Traceback (most recent call last):
  File "/home/steve/mycroft-core/mycroft/skills/intent_service.py", line 237, in handle_utterance
    context_manager=self.context_manager))
StopIteration
- SKILLS - DEBUG - {"type": "intent_failure", "data": {"lang": "en-us", "utterance": "this is a test"}, "context": null}
- mycroft.skills.padatious_service:handle_fallback:98 - DEBUG - Padatious fallback attempt: this is a test
- mycroft.skills.core:handler:670 - INFO - Exception in fallback: max() arg is an empty sequence
- SKILLS - DEBUG - {"type": "complete_intent_failure", "data": {}, "context": null}
- mycroft.skills.core:handler:672 - WARNING - No fallback could handle intent.
- SKILLS - DEBUG - {"type": "speak", "data": {"utterance": "Sorry, I didn't catch that. Please rephrase your request."}, "context": null}

Heres my code:

Looks like there is an issue in intent_service.py?

Thanks

That warning only means it couldn’t find a matching intent.

What word do you have in the TestNew.voc file? (so I can match your work exactly) In my version I had the word well

That fails for me as well. but when using a single word it works. Thanks for reporting, will look into.

“a” is removed in normalization, so the intent never matches

this is test would work

1 Like

Good thinking, forgot about that.