Can Anyone Share an App That Uses Rhasspy Hermes App and passes multiple Arguments for an Intent

So using the Rhasspy Hermes App wrapper is pretty straight forward in implementing custom skills using the provided examples that are triggered by a specific intent. But how do you pass other arguments that are available via the JSON message sent from Rhasspy for a specific intent? For example, I have created an intent and two numeric variables are part of the intent trigger sentence:

[SetFMStation]
set radio to f m (88…108){channel} point (0…9){channel1}

So using the Rhasspy Hermes App wrapper you trigger your python app with:


@app.on_intent(“SetFMStation”)

async def set_fm_station(intent:NluIntent):

the program logic…

How do I get {channel} and {channel1} variables out of the JSON message sent by Rhasspy??

Entity channel value and entity channel1 value in the JSON sent below is what I need.

JSON sent my Rhasspy
{
“entities”: [
{
“end”: 19,
“entity”: “channel”,
“raw_end”: 28,
“raw_start”: 17,
“raw_value”: “ninety nine”,
“start”: 17,
“value”: 99,
“value_details”: {
“kind”: “Number”,
“value”: 99
}
},
{
“end”: 27,
“entity”: “channel1”,
“raw_end”: 38,
“raw_start”: 35,
“raw_value”: “one”,
“start”: 26,
“value”: 1,
“value_details”: {
“kind”: “Number”,
“value”: 1
}
}
],
“intent”: {
“confidence”: 1,
“name”: “SetFMStation”
},
“raw_text”: “set radio to f m ninety nine point one”,
“raw_tokens”: [
“set”,
“radio”,
“to”,
“f”,
“m”,
“ninety”,
“nine”,
“point”,
“one”
],
“slots”: {
“channel”: 99,
“channel1”: 1
},
“text”: “set radio to f m 99 point 1”,
“tokens”: [
“set”,
“radio”,
“to”,
“f”,
“m”,
“99”,
“point”,
“1”
],
“wakeword_id”: “default”
}

Hi James,
Not sure if you know about this site: https://jsonpathfinder.com/
I use it frequently to find the correct path to elements in a json message. I tried your JSON, (btw, if you enclose your code by starting with a line of three back tics “`” and end it with a line of three back tics, it will format correctly) in it but its showing as invalid JSON, most likely because of formatting.
And (please forgive me if this is too basic, never sure of anyone knowledge or experience) take a look at this stackoverflow:
Extract multiple values from a JSON using JSONPath - Stack Overflow
It might be what you’re looking for.
Jeff

Thank you for the response. The JSON supplied is what is provided by pressing the “JSON” button on the Rhasspy UI for the intent sentence I created. My question is how you reference or pull this data using the Rhasspyhermesapp api in my custom skill python program. All of the examples reference the intent word to trigger the routine. IE: @app.on_intent(“GetTime”). So “GetTime” is the intent name. I would like to get additional data from the JSON, but no other arguments are referenced in the function. I was reviewing other functions provided in the the api reference for the Rhasspyhermesapp such as on_raw_message() and on_topic and guessing maybe these functions should be used instead of on_intent(). There are just no examples provided other than triggering by on_intent.

Okay, this might help:
https://snips.gitbook.io/tutorials/t/technical-guides/listening-to-intents-over-mqtt-using-python
This is from a long time ago, back in the bad old days before synesthesiam created the magical Rhasspy, but if you look at the very bottom of the page, you’ll see a section on accessing intent parameters, which are the slots in the json.
Jeff

Thank you for your response JeffC.
In case anyone out there may be struggling…your post led me to stumble on to this.
Using the basic “onintent” function in the Rhasspy Hermes App as below:

For an example Rhasspy intent sentence to change my radio station that needs to variables;

[SetFMStation]
tune radio to f m (88…108){channel} point (0…9){channel1}

The python skill script using the basic “onintent” trigger–

@app.on_intent(“SetFMStation”)

async def set_fm_station(intent: NluIntent):

channel = intent.slots[0].value.get(“value”)
channel1 = intent.slots[1].value.get(“value”)

Big picture is all of the info sent by Rhassy is available to the routine via the “intent” object.
Intent.slots[0] is the first variable in the sentence reading left to right. [1] next, etc.

Prettty much all of the message is available (not just the variables). I’m still learning, but all of my skills are simple as being triggered by an intent and parsing the variables for room names, numbers, on, off, etc.

thanks