Connecting command line parser to mqtt

Connecting Python-IntentHandlers to Rhasspy

As Rhasspy can tell you the weather (at least if you speak German) descriped, it would be a good idea to handle intents directly in python.
The best way to exchange information to the python-script and back to calling satellite would be mqtt,
especially if you use docker container for rhasspy or nodered.

As you can see in ( Python Skill Code), there is already a basic script.

Whats missing is a connection to the skills.

My Idea:

Adding a function into the script,

import importlib

def handle_intent(nlu_payload):
        module = importlib.import_module(nlu_payload["intent"]["intentName"] + ".action")
        return module.getAnswer(nlu_payload)
        return ""

calling it and resending it.

 answer = handle_intent(nlu_payload)
 client.publish("hermes/tts/say", json.dumps({"text": answer , "siteId": site_id}))

Now the stuff for the intenthandler programmers:

In Profile folder, you create a subfolder (Intents?),intentHandler

  • The script from above (
  • Each Intenthandler in its own folder with the Intent Name (GetTime, SetSituations)
  • Inside the Intentfolder the starting python-module called “”
  • Inside the “” a function called getAnswer(payload), which returns the answer that will be resendet to the satellites.

Then you only have to copy the new IntentHandler in that Intents-folder, start the script and thats it.

Maybee it’s a useful idea, but I think the import stuff could be better. It would be also better if you could arrange the answering procedure with just a print() command.

1 Like