The next version of the cows lists skill

The next version of the cows lists skill is now available at
Before I make the pull request to the Mycroft skill repo, you are welcome to try it out. Any feed back is appreciated.

It is now possible to “undo” the last operation. And lists names are recognized even is mispronounced. In both cases you enter a dialog about what to do. See the read me for more details.

Behind the scenes a lot has changed. Many unittests were introduced, and the code has been heavily refactored. Dialog context is used to control many of the new features.

Happy New Year

1 Like

I did a few changes after testing, and updated the repo (

1 Like

Do you have a video of this in action? I would like to get a better handle on the “conversational context” in action and in reading your code, it seems like you have a nice implementation of this.

1 Like


Unfortunately, I dont have a video. But take a look at as well.
When working with context there are two main findings I would like to share:

  1. I use json to pass parameters from the method where the context is created, the the method where the context is used.

  2. Dont use the @removes_context() decorator on methods where you use the set_context() inside the method

Ad 1) If you look at the example in the link above, you will see that self.set_context() takes a context name and a string as parameters, e.g: self.set_context(‘PythonPerson’, python). In may case, I have created an “Undo” context, that currently are able to delete a task that was created earlier. However, to delete it I need the exact identification on the task, which is a composite key, consisting of a task ID, a list ID and a tasklist ID. All three parameters are needed to uniquely identify the task. And these three parameters are a part of my context, even if Mycroft will not talk about them. Furthermore, to make an undo method, that can handle all kinds of undo operations comming in later releases, I add even more parameters to the context, like what to undo, and what mycroft should say after undoing. I need to pass all these parameters as a string in the set_context(context, string). I do that by converting the parameters to json, and parsing them serialized. Since the context is passed over the messagebus, it must be passed as a string.

Ad 2)
I did not investigate this too much, but I found that in this construction:

def some_method(self)

The context A would be removed, but the context B would not be set. I don’t use the remove decorator if a context is added within the method. In my case, i use a “return early” pattern, which means that I may return successfully before adding a task to a list. Therefore I need the self.set_context() in the code after the task was added, I cannot use the @set_context() decorator.

If you want to see exactly what the code does, You can attach a Python debugger to the running instance.
However, Pycharm and its debugger may create files or install packages that may interfere with Mycroft, only do this if you understand what you are doing.

I use Pycharm community edition for debugging, it will add some files to the skills directory, which may prevent automatic update of the skill later, if used within Mycroft. You may want to make a backup copy before doing this, and restore it after.
In short, what I do:

  • Start mycroft
  • Open the Pycharm project in /opt/mycroft/skills/skill-the-cows-lists
  • In Pycharm settings, set virtualenv to mycroft (requirements (imports) should be fulfilled after this)
  • Put in breakpoints in where you want the debugger to stop
  • On Ubuntu, allow ptrace (temporarely): echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
  • Select run->attach to local process, attach to the process ending with mycroft/skills/ The console should write Connected to pydev debugger
  • Speak to mycroft to hit the method where your breakpoint is
  • happy debugging

As an alternative, you may also run my unittests using Pycharm (or something else). This can (must be) done outside /opt/mycroft/skills/skill-the-cows-lists. So download skill-the-cows-lists to some folder.
Before the test can be run:

  1. Create a file called test.cfg in the test sub-direstory, and add the RTM api_key and secret, like this:
    api_key=many characters
    secret=many characters

  2. Edit the file, and change AUTH_TEST = False to AUTH_TEST = True

  3. Change to virtualenv mycroft to fulfill requirements

  4. Run the unittests in
    It will write an authentication link in the console. Click on the link, and authenticate in a browser. After authentication in the browser hit return in the unitest console.
    The test should succeed

  5. Edit the file, and reset AUTH_TEST = True back to AUTH_TEST = False

After this both and can be run, or debugged, to better see what the code does.



thank you for the time and effort you put in this reply and helping me understand the conversational context! You highlighted some of the areas in your code that had me puzzled. I look forward to learning more and implementing this
feature soon!
Also, this is pretty good life(& linux) advice in general: