Build an open future with us.

Invest in Mycroft and become a community partner.

Cant get it to work - simple sayhelloto skill


#1

Trying to make a simple sayhelloto skill but cant make it work. I did read the docs (but dont understand all of it) and used helloweorld and stock skill as eamples. Could some one look at https://github.com/andlo/say-hello-to-skill and guide me ? What am I missing ?

What I want to acomplish is getting to understand how to make a skill that takes one word (a name) and speaks back whith that word (name)

Hey Mycroft - Say hi to Sonia
and then Mycroft replyes
Hi Sonia - Nice to meet you


#2

Just had a quick look, but I think you will only need the regex.
Instead of
@intent_handler(IntentBuilder("").require("to.hello.say.intent").require("Name"))
try
@intent_handler(IntentBuilder("").require("Name"))


#3

Ill try that to - but actuly I got it to work by changing to

    def handle_say_hello_to_intent(self, message):
        response = {'name': message.data.get("Name")}
        self.speak_dialog("to.hello.say", data=response)

#4

Next problem…My vocab include “say hi to” and this conflicts whith the speak skill who has vocab say.

How to deal with that ?


#5

@andlo
Break up your vocab files so each vocab file is a bag of similar meaning words then include each vocab in your “requires” statement. First vocab may have only the word “say”. Second file will have ‘hi’, ‘hello’, ‘high’, last vocab file will have ‘to’, ‘too’, ‘two’. This will significantly reduce the chance that this group of vocab files conflicts with other intents.


#6

I am not sure what you say…

vocabfile1:
Say

vocabfile2:
Hello to
Hi to

vocabfile3:
Meet
Let me interduse you to

vocabfile4:
This is

But what to write in
@intent_handler(IntentBuilder("")
.require(“Name”))

and does it matter how i name the vocabfiles?


#7

I would suggest reading this guideline that was created but the community member @Jarbas_Ai. It has substantially helped me in understanding the best way to create the “bag of words” approach to vocab files.
In the following link the Guidline 4 is a good description on how to use the vocab files.


#8

Hi @andlo, as @pcwii mentioned, @Jarbas_Ai has written a really good introduction to this. In summary though, you’re taking the right approach. In the example you gave, you would name the files something like:

say.voc =>
Say

hello.voc =>
Hello to
Hi to

meet.voc =>
Meet
Let me introduce you to

thisis.voc =>
This is

In the Intent Handler, it would be written as:

@intent_handler(IntentBuilder("")
.require("say").require("hello").require("meet").require("thisis"). 

If the Intent for your Skill has optional vocab items, these are called used using option("vocab") instead of require("vocab"). Example:

@intent_handler(IntentBuilder("")
.require("say").require("hello").require("meet").optional("thisis"). 

#9

Great - except for a missing ) which gave me troble.

I have changed the skill, he dosnt work :frowning:
This is Peter
>> I’m not sure I understood you.

class SayHelloTo(MycroftSkill):

@intent_handler(IntentBuilder("").require("say").require("hello").require("meet").require("thisis"))

def  handle_say_hello_to_intent(self, message):
    response = {'name': message.data.get("Name")}
    self.speak_dialog("to.hello.say", data=response)

And changed fles in vocab as described.

What am I missing…I now know wht I am not a programmer - I am great doing trial and error but this gives me headake :wink:


#10

@andlo,
I think there is still a bit to be done in your code (viewed on github). My suggestion is to check your skills.log file and it will report where it is erroring out. I have a simple pick number skill that you can use as a base if you would like.


A few things I noticed.

  1. Think you may require…

def init(self):
super(SayHelloTo, self).init(name=“SayHelloTo”)

  1. Also may require this to load the vocab and dialog files

def initialize(self):
self.load_data_files(dirname(file))

  1. Intent builder should i think be like this

@intent_handler(IntentBuilder("").require(“say”).optionally("hello’).optionally(“to”).build())

  1. Since you did not define “Name” as one of your optional vocab files, likely because the name will be dependant on the speaker I would recomend you use the “remainder” option to retrieve everything else that is spoken.
    eg. response = message.utterance_remainder()

Don’t be discouraged. It has been just over a year now since I committed to learning python and I have discovered that once you understand syntax a bit as well as how to google what you are looking for, you are well on your way.:+1:


#11

Thanks that got me going again :slight_smile:

Sinse Name is important - how do I get that from the utterance ?

something like Say hello to {Name}
and response = {‘name’: message.data.get(“Name”)} but I cant figure out where to put {Name} ?

in an errlier version I got it working but I did use regex - but think there is an alternative way to get it ?


#12

Glad you are having some success.
If you use
response = message.utterance_remainder()
This will return any part of the utterance (the sentence you spoke to Mycroft) that is not found in your intent builder. If you speak “say hello to andlo” the remainder will return the word “andlo”. If you speak “say hello to andlo python programmer extraordinaire” the remainder will return “andlo python programmer extraordinaire”. You can then pass this back to the speak_dialog so that Mycroft will respond “hello andlo python programmer extraordinaire”.


#13

Ohh I see.

I think I get confused by intent_file_handler and intent_handler where intent_handler is using .voc files and intent_file_handler is using .intent.
I have now got it to work using intent_file_handler and one .intent file whit all posible sentenses that should trigger and having {name} in that to.
So it is working :slight_smile: and is simple so I can understand what is going on.

Jarbas dis write some good stuff, and he pointed me to https://mycroft.ai/documentation/padatious/

So a simple skill should be simple to write :slight_smile: and it IS simple once figure out that there are to aproches for intent_file_handler and intent_handler.


#14

Next step is to figure out the acceptence proces for getting a skill to the skill repo :wink:


#15

And make a skill whit an dialog…

Say hello to Peter

Hi Peter, nice to meet you. How old are you ?
I am 7 years old

That is nice, Peter. 7 years old is great


#16