Build an open future with us.

Invest in Mycroft and become a community partner.

Advanced Dialog Control


#1

I have a few questions about dialog control

  1. Is there an ability to compound multiple vocab files into a single speak_dialog response do create more natural random dialog for longer conversations?
    a. self.speak_dialog(‘dialog.file.1’ + ‘dialog.file.2’)
  2. Is there a way to pass multiple “data=” values to the dialog file?
    a. self.speak_dialog(‘dialog.file.1’, data={“result_1”: string_value_1, “result_2”: string_value_2})

Thanks


#2

Hey there @pcwii, great questions.

Compounding multiple vocab files and passing multiple data

I didn’t think this was possible, but to make sure, I did a search on GitHub - I couldn’t find any examples of this at all.


#3

@KathyReid
I can confirm that the data portion of my question with multiple data points actually does work as described. I have not gotten the compound vocab files to work though.
I am having another issue where I can’t get the regex to work on single word replies when I also have set a context value as well.
Any thoughts?


#4

Are you able to paste the code for us to have a look at?


#5

Code, is here


#6

@KathyReid,
Here is a code snip of what I am using.
SearchChat is the context set in previous conversation and SkillName is the regex requirement.
The file “SkillName.rx” is located in the regex\en-us folder of the skill and contains (?P.*)
Basically I am requesting the user name the skill they want to search for.
I hope that helps

@intent_handler(IntentBuilder('SearchHelpIntent').require('SearchChat').require('SkillName')
                .build())
@removes_context('SearchChat')
def handle_search_help_intent(self, message):  # A decision was made other than Cancel
    # remainder = message.utterance_remainder()
    search_skill = message.data.get('SkillName')
    search_skill.replace('skill', '')
    if "cancel" in search_skill:
        self.stop_help_chat()
    else:
        for each_skill in self.skill_names:
            if remainder in each_skill:
                self.skill_index = self.skill_names.index(each_skill)
                self.read_search_help_item()
            else:
                self.speak_dialog('location.error', data={"result": search_skill}, expect_response=False)
                wait_while_speaking()

#7

@pcwii So, what happens with the regex? In what way is it not working as expected?
What does your mycroft-skills.log show?


#8

I need a bit more to go on here :wink:
The regex itself looks correct.


#9

@KathyReid,
I have not had an opportunity to dig into this in a bit. At a very basic level i can’t get the intent to trigger at all. I am setting the context in a previously triggered intent (working) then expecting to be able to trigger this intent with a one word answer (or basically any utterance). This is not occurring, I just get the standard, “I don’t understand”. If I get a chance I may try to add some other logic to confirm the context is properly set. Probably something simple but can’t see it at this point.


#10

OK - tailing mycroft-skills.log can be very helpful for identifying these sorts of errors.


#11

@KathyReid, I am still struggling to get the .rx files to work in my intent builder. Can you provide some clarity or point me in the documentation where I can understand how the intent builder knows when / how to reference the .rx file instead of the .voc files? Also do I need to “declare” the .rx file somewhere simillar to how the .voc files are referenced in the intentbuilder? Lastly when referencing the .rx file in the intent builder do I refer to the filename or the regex keyword located in the file? Sorry for any confusion but this looks very straight forward but I am struggling with getting it working.


#12

Sure, can you post a link to your repo as this will help explain it?


#13

My Repo is located here help-skill.
Line 129 is the intent that should be triggered with ‘SkillName’ being the key in the skill.name.rx file.
To repeat the error
user speaks, Hey mycroft, help (HelpStartIntent)
mycroft responds.
user speaks ‘search’ (HelpChatDecisionIntent - calls search_help_item())
mycroft responds.
user speaks the name of a skill (ie. kodi) (should trigger SearchHelpIntent)
This is where it fails.

Thank you for the support.


#14

Hey there @pcwii, thanks for that information, super helpful. The way I’ve approached this is to install the Skill, give it a run through and then try and isolate the regex issue.

Install Skill

(.venv) kathyreid@kathyreid-Oryx-Pro:~/mycroft-core$ msm install https://github.com/pcwii/help-skill.git
INFO - Downloading skill: https://github.com/pcwii/help-skill.git
INFO - Installing requirements.txt for help-skill
INFO - Successfully installed help-skill

Installed OK, proceeded to test the different Intents

  • Christopher, help

looped through each of the installed Skills correctly. I used more as the command each time so that it would keep scrolling through. When it got to the last Skill, it threw this error:

21:25:44.030 - SKILLS - DEBUG - {"type": "mycroft.skill.handler.start", "data": {"name": "HelpSkill.handle_help_chat_decision_intent"}, "context": {"target": null}}
21:25:44.032 - SKILLS - DEBUG - {"type": "speak", "data": {"utterance": "this skill can be run by saying, hey mycroft: help", "expect_response": false}, "context": {"target": null}}
21:25:44.335 - SKILLS - DEBUG - {"type": "speak", "data": {"utterance": "We have reached the last skill that is installed on the system", "expect_response": false}, "context": {"target": null}}
21:25:44.636 - mycroft.skills.core:wrapper:655 - ERROR - An error occurred while processing a request in Help Skill
Traceback (most recent call last):
  File "/home/kathyreid/mycroft-core/mycroft/skills/core.py", line 646, in wrapper
    handler(message)
  File "/home/kathyreid/mycroft-core/mycroft/skills/context.py", line 29, in func_wrapper
    ret = func(*args, **kwargs)
  File "/home/kathyreid/mycroft-core/mycroft/skills/context.py", line 43, in func_wrapper
    ret = func(*args, **kwargs)
  File "/opt/mycroft/skills/help-skill.pcwii/__init__.py", line 123, in handle_help_chat_decision_intent
    self.more_help_item()
  File "/home/kathyreid/mycroft-core/mycroft/skills/context.py", line 29, in func_wrapper
    ret = func(*args, **kwargs)
  File "/home/kathyreid/mycroft-core/mycroft/skills/context.py", line 43, in func_wrapper
    ret = func(*args, **kwargs)
  File "/opt/mycroft/skills/help-skill.pcwii/__init__.py", line 166, in more_help_item
    self.next_help_item()
  File "/home/kathyreid/mycroft-core/mycroft/skills/context.py", line 29, in func_wrapper
    ret = func(*args, **kwargs)
  File "/home/kathyreid/mycroft-core/mycroft/skills/context.py", line 43, in func_wrapper
    ret = func(*args, **kwargs)
  File "/opt/mycroft/skills/help-skill.pcwii/__init__.py", line 157, in next_help_item
    self.stop_help_chat()
  File "/home/kathyreid/mycroft-core/mycroft/skills/context.py", line 43, in func_wrapper
    ret = func(*args, **kwargs)
TypeError: stop_help_chat() missing 1 required positional argument: 'message'

My interpretation of this is that the stop_help_chat() function does not need the message parameter, just self.

That doesn’t help with the actual error you were reporting though.

Testing the part that is failing

To try and trigger the error you’re reporting, I did:

  • help

it then asked me to choose more or cancel or next (but not search)
I said search
it then asked me to enter the name of the Skill. I did aircrack because I have that Skill, and it said
“sorry I don’t understand”

Tried again, this time using podcast and this triggered the Podcast Skill.

So yes, I’m getting a similar error.

I then added these lines of logging to the Skill, beginning at line 134;

        logger.info('--BEGIN LOGGING--')
        logger.info(search_skill)
        logger.info('--')
        logger.info(message.utterance.remainder())
        logger.info('--END LOGGING--')

and ran the Skill again. However, the logging never appeared in the skills.log, so I don’t think this part of the code was actually being hit.

I’ve checked the regex and that looks fine. I’m at a loss here.

I wonder if @forslund has any ideas?


#15

Hey @KathyReid thank you for your efforts, I am definitely going to adopt some of your testing methodology in the future (never thought to try the logging). I am actually encouraged that you encountered the same issue as me. During my testing I never actually got through all my skills to encounter the error you first encountered, I will look into that issue. I am hoping that @forslund will be able to shed some light on this for me.

Thanks again for your trials.


#16

Hi,

The issue with regex + context can be a scoring issue. Both regexes and context’s are rated 0.5 of normal keywords and the kind of grab all regex that’s being used can also be an issue (there’s an open issue with adapt, having these very open regexes makes the regex scoring fail sometimes). I’ll see if I can play around with your skill and see what’s really going on.

Some of these cases sounds like they’re more suitable for use with self.get_response() and self.ask_yesno() instead of using context. This is good for cases where you want a direct answer which is needed to continue the interaction.

if self.ask_yesno('start.chat') == 'yes':
    skill = self.get_response('which.skill.dialog')
    self.give_info(skill) # or what a good method for handling the skill input may be

These methods are really good for serial conversation since they lock the conversation to the skill and forces a serial flow.

The compound dialogs aren’t directly supported but can be done:

compound.dialog
{dialog1} {dialog2}

dialog1.dialog
This is the first part

dialog2.dialog
and this is the second part

self.speak_dialog('compound', data={'dialog1': self.translate('dialog1'),
                                    'dialog2': self.translate('dialog2')})

#17

@forslund, I am hoping you can assist with some skill decision making I am using that is not working as expected.
In my skill I issue the following code.
if self.ask_yesno(‘youtube.playlist.present’) == ‘yes’:
self.play_youtube_video(youtube_id[1])
else:
self.play_youtube_video(youtube_id[0])

The question in the ask_yesno is spoken but Mycroft does not understand my yes responce. I am not sure what could be wrong or even where to begin looking for the issue as no errors are thrown.


#18

Hi,

If you have the CLI open does the logged input show that Mycroft heard a yes?

(for me I often need to say a couple of words for it to be detected correctly “Yes that’s right” or “Yes do that”)