Converse() isn't running?

I’m starting down the path of learning my first skill via the documentation and at this stage it’s very simplistic:

import logging

from mycroft import MycroftSkill, intent_file_handler

logger = logging.getLogger(__name__)


class MySkill(MycroftSkill):
    def __init__(self):
        logger.info("__init__()")
        MycroftSkill.__init__(self)

    def converse(self, utterances, lang=None):
        logger.info("converse")
        return False

    @intent_file_handler("myskill.intent")
    def handle_myskill(self, message):
        logger.info("intent")
        self.speak_dialog("myskill")


def create_skill():
    return MySkill()

The problem I’m having is that the converse() method doesn’t appear to trigger… ever. The skill works just fine: I say “hey mycroft”, he chirps at me, I say the keyword I’m looking for and he responds with one of the responses in the “myskill.dialog” file. But the converse() code never runs. I even tried putting “assert False” in there to see if I could blow everything up, and it still acted the same.

What am I missing here? The documentation tells you what to do, but doesn’t do a very good job of telling you why things aren’t happening as it claims things should.

There definitely is something wonky here…it works for me but not quite right…

So the converse method can only be hit after a skill’s intent handler has been selected (and then there is a 5 minute timeout). For me the skill’s converse method doesn’t get called on the first user utterance after the intent handler is triggered, but the second, third, etc is caught correctly.

And the get_response() method works as expected all the time which is weird. it should basically fail if converse was broken like this…

Will dig into the code more, there’s a PR simplifying the converse handling gonna test that as well and see if it behaves better or worse.

2 Likes

Well that’s refreshing to know that I’m not going crazy. Please report back if you find anything I guess. I’m a pretty accomplished Python guy, but this is my first serious attempt at writing a Mycroft skill so if there’s something I’m missing that wasn’t immediatley obvious from the documentation, then this could at the very least be an opportunity to clear something up.

1 Like

I’ve found at least one problem (or two depending on how you look at it). When using a padatious intent an extra “empty” active skill gets added, this is a problem but shouldn’t really do anything.

When looping through the active skills the “empty” skill however seem to break the loop so the real skill isn’t checked at all.

I’ve got a work-around going but will dig into the actual cause, the loop should continue on bad skill id’s.

1 Like

Think I found the root issue…removing a skill from a list while iterating over said list…

1 Like

Posted a Pull request for a fix (or three separate fixes for the single issue :slight_smile: ) for the issue I could see. If you have the ability, I’d be glad to know if it works for you with this addition

2 Likes

I’m still having this problem where the converse method doesn’t get called until after the skill implementing it has been called once.

Hey Thomas, that’s the expected behaviour. The Skill must have been active within the last 5 minutes for converse to trigger.

As a work around, you could add something like the following to your initialize() method:

self.schedule_repeating_event(self.make_active, None, 270, name="keep active")

This would call self.make_active every 270 seconds.

1 Like