How do i send a message to the messagebus?

hello

im reading the messagebus documentation and it says that its possible to send an utterance to the messagebus. which particular function makes that possible?

I think the docs are a bit outdated as it describes uses og self.emitter.emit() but I think the right would be to use self.bus.emit

def some_method(self):  
    self.bus.emit(Message("recognizer_loop:utterance",  
                              {'utterances': ["inject a user utterance"],  
                               'lang': 'en-us'}))  
1 Like

Hey andlo,

I was also looking for something similar. I was wondering… does this method store the utterance in the memory? Would it be possible to match this utterance against other intents in mycroft core as well?

Thanks!

When sending a utterance to the messagebus, and other skills will match and react to it.

So if you add a

self.bus.emit(Message("recognizer_loop:utterance",  
                              {'utterances': "Play rainy day"],  
                               'lang': 'en-us'}))  

at the end of the weather-skill and the ask mycroft “how is the wether” he will tell you the weatherforcast by using the weather-skill and then play Rainy day by using a music skill.

2 Likes

@andlo, Hi, this isnt working currently. The error is: NameError: name 'Message' is not defined. Is there another change to the code that has removed the ‘Message’ function?

1 Like

Nope just needed to add that to the docs, thanks for pointing it out