Mycroft Community Forum

Editing an existing Skill to converse()

Hi folks! I’m just getting set up with my lil picroft and have successfully added a tiny custom skill that works just fine. However I’m now trying to figure out how to implement the entire reason I got Mycroft…making it respond “it’s party time” when asked what time it is (this is dumb, I know).

I’d like to just edit the datetime skill to do exactly what it does now, except to first respond “it’s party time” upon being asked. Not sure how I want to trigger the actual time response after that, yet - whether to have that behavior always happen (just on a delay) or require some insistence (e.g. the words “no really” + one of the regular utterances). I honestly don’t care, whatever y’all think is easiest I’ll do!

I pointed the datetime skill to my own repo rather than the real skill, and I think this is a job for converse(), but I can’t quite figure out what I’m doing. So far I’ve only tried a couple things when adding this to the

def converse(self, utterances, lang):
# num_asks += 1
# if num_asks <= 1:
# self.speak_dialog(‘it’s party time’)
# return False
return False

(tried the commented-out stuff with a num_asks = 0 definition in init, as well as the function without the counter. the counter was my attempt to handle the need to be re-asked before mycroft will give up the time).

I feel like this should be easy so I’d love anyone’s help!

1 Like

(sorry for the wack formatting in that post, hope it’s legible :sweat_smile: )

Hey Chef - fun idea!

The documentation on converse is severely lacking at the moment but this would achieve what you’re after:

    def __init__(self):
        self.num_asks = 0

    def converse(self, message):
        utterance_has_time = self.voc_match(['utterances'][0], 'Time')
        if utterance_has_time:
            self.num_asks += 1
            if self.num_asks % 3 == 0:
                self.speak_dialog("It's party time")
                return True

In this case, everything third time the user says something that contains a word in the Time.voc file (“time” or “clock”), then Mycroft will say “It’s party time” instead of the actual time.

If you don’t return True then the function will by default return False and Mycroft will continue to send the utterance through the normal intent parsing process. In this case, it means you get “It’s party time… twelve oh five” :smiley:

You’ve also encouraged me to add some content to the converse page in our docs!

Hopefully this helps :slight_smile:

Thank you so much! yeah, this is super helpful. I’ll let you know how it goes!

Hey there - so I gave it a shot, no luck! And then I realized I’m not sure if this should be added to the datetime skill (what I assumed originally) or be wrapped in its own skill (which I tried anyway). I think my confusion comes from this in the docs “This method will be called anytime the Skill has been recently active and a new utterance is processed.”

Does this mean that the first time someone asks for the time, the skill becomes active, but as it wasn’t already active the converse() method doesn’t get called? So you’d only have the utterance “what time is it” sent to the Datetime skill’s converse() method the second time you asked?

My goal is to have “party time” be the first response, and the actual time come upon insistence, which is what makes me think that I need to create a separate skill of some kind, so “what time is it” goes first to that skill, then when asked again goes to that skill’s converse(), which passes it on to the real datetime skill. Is that right?

This seems to fall into the category of fun, but things we actively discourage except on your own device…

The simplest method if you’re happy forking the Date Time Skill would be to actually edit the relevant intent to add in your functionality.

An alternative would be to do your own Skill and use converse, but set a recurring event to call self.make_active() every 4 minutes. Hence your Skill will keep itself in the active Skills list forever. Eg something like:

    def __init__(self):
        self.num_asks = 0

    def initialize(self):
        self.schedule_repeating_event(self.make_active, 240)

This is definitely staying on my own device - thanks so much for all your help! Really useful for knowing how stuff works :slight_smile: