Slots: hermes/intent and json from Gui do not seems to match

I am using MQTT to listen to the intents, so I listen to (tried a few others you can see below)

hermes/intent/#

I send an intent from sentence:

[ShoppingListToThe]
add ($shoppinglist){shopping_to_add} to [the] shopping list

I get this json output in the GUI button:

{
    "entities": [
        {
            "end": 7,
            "entity": "shopping_to_add",
            "raw_end": 7,
            "raw_start": 4,
            "raw_value": "ham",
            "start": 4,
            "value": "ham",
            "value_details": {
                "kind": "Unknown",
                "value": "ham"
            }
        }
    ],
    "intent": {
        "confidence": 1,
        "name": "ShoppingListToThe"
    },
    "raw_text": "add ham to shopping list",
    "raw_tokens": [
        "add",
        "ham",
        "to",
        "shopping",
        "list"
    ],
    "recognize_seconds": 0.7213972329627723,
    "slots": {
        "shopping_to_add": "ham"
    },
    "speech_confidence": 1,
    "text": "add ham to shopping list",
    "tokens": [
        "add",
        "ham",
        "to",
        "shopping",
        "list"
    ],
    "wakeword_id": null
}

Which is great i can reference intent->slots->shopping_to_add and get “ham”

However, the MQTT output is different I get the following:

{“input”: “add ham to shopping list”, “intent”: {“intentName”: “ShoppingListToThe”, “confidenceScore”: 1.0}, “siteId”: “sat1”, “id”: “aefd0bfa-c07e-492d-a897-e49f3570b37c”, “slots”: [{“entity”: “shoppinglist”, “value”: {“kind”: “Unknown”, “value”: “ham”}, “slotName”: “shopping_to_add”, “rawValue”: “ham”, “confidence”: 1.0, “range”: {“start”: 4, “end”: 7, “rawStart”: 4, “rawEnd”: 7}}], “sessionId”: “aefd0bfa-c07e-492d-a897-e49f3570b37c”, “customData”: null, “asrTokens”: [[{“value”: “add”, “confidence”: 1.0, “rangeStart”: 0, “rangeEnd”: 3, “time”: null}, {“value”: “ham”, “confidence”: 1.0, “rangeStart”: 4, “rangeEnd”: 7, “time”: null}, {“value”: “to”, “confidence”: 1.0, “rangeStart”: 8, “rangeEnd”: 10, “time”: null}, {“value”: “shopping”, “confidence”: 1.0, “rangeStart”: 11, “rangeEnd”: 19, “time”: null}, {“value”: “list”, “confidence”: 1.0, “rangeStart”: 20, “rangeEnd”: 24, “time”: null}]], “asrConfidence”: null, “rawInput”: “add ham to shopping list”, “wakewordId”: null, “lang”: null}

Same as above but a bit easier to read and just the Slots bit:

{
  "intent": {
    "intentName": "ShoppingListToThe",
    "confidenceScore": 1
  },
  "slots": [
    {
      "entity": "shoppinglist",
      "value": {
        "kind": "Unknown",
        "value": "ham"
      },
      "slotName": "shopping_to_add",
      "rawValue": "ham",
      "confidence": 1,
      "range": {
        "start": 4,
        "end": 7,
        "rawStart": 4,
        "rawEnd": 7
      }
    }
  ],
  "input": "add ham to shopping list",
  "siteId": "sat1",
  "id": "aefd0bfa-c07e-492d-a897-e49f3570b37c",
  "sessionId": "aefd0bfa-c07e-492d-a897-e49f3570b37c",
  "customData": null,
  "asrToke

I read the hermes Snips Ref Docs

And tried vairous topics: hermes/nlu/intentParsed hermes/nlu hermes/intent they all gave the same results.

My question is what am I doing wrong or is this expected behaviour?

Sorry for the long post, but I always think it’s better to have too much information than the back and forth of having to ask for it :slight_smile:

MattV

As per documentation of Snips: Expected behaviour.

The GUI uses its own format and has nothing to do with the MQTT messages :slight_smile:

In that case as the slots in an option could Rhasspy do the same with them as it does for events and JSON? It would make MQTT just as easy as events then

That would imply a major breaking change, so not likely.

The MQTT is json as well, so you are able to parse the with you listener right?
The slots are a json array

If we are going by Hermes protocol as Slots optional over MQTT it should not break anything if we change it to match the same as Events and GUI JSON. If it does then Rhasspy has drifted from Hermes protocol already. I am not expert but just sounds like the Rhasspy code has just published the JSON the wrong way around, but I am not smart enough to read the source and make sense of it.

The issue is that they way the JSON is delivered with Events/Gui is different from MQTT’s JSON

MQTT JSON:
> slots.0.value.slotname

Events/Gui JSON:
> slots.slotname.value

and in MQTT JSON order changes dependant on which way around you say a sentence, you can never be sure what slots.0 or slots.1 or slot.2 etc are going to be. Which means adding “if this, then” statements in HA for example (not fun in Jinja)

Am I making sense?

The ordering does not matter, it is not good practice to address json arrays by their index.
Like you said, you can never be sure what they are going to be.
You can loop over the slot and parse the slotName and the rawValue if you need it.

I am not sure what you are trying to achieve, but your code should parse all slots with their values.