How to decipher Snips MQTT information

I am trying to use some MQTT data from Snips but I'm new to Node-Red and I'm stumbling a bit while I begin to understand the bits of Node-Red.

I have this data from Snips on MQTT that I'd like to use.

Message 10 received on hermes/nlu/intentParsed at 10:27 PM:

    "id": "cfbbcf73-4c19-470e-8b2a-548c141fa8f5",
    "input": "hello",
    "intent": {
        "intentName": "SirBuildsALot7:hello",
        "confidenceScore": 1
    "slots": [
            "rawValue": "hello",
            "value": {
                "kind": "Custom",
                "value": "hello"
            "alternatives": [],
            "range": {
                "start": 0,
                "end": 5
            "entity": "hello",
            "slotName": "hello",
            "confidenceScore": 1
    "sessionId": "4ea038ea-81aa-425d-8719-e115f8e5ffcf",
    "alternatives": [
            "intentName": null,
            "confidenceScore": 0.06004923,
            "slots": []
            "intentName": "rob:GoodMorning",
            "confidenceScore": 0.04279821,
            "slots": []

Now my goal here is to be able to ask snips to play a radio station stream on my Chrome Cast speakers. I've got that bit worked out by using inject nodes right now.

What I am struggling with is how to use the "intentName": "SirBuildsALot7:hello" part of the MQTT data to have Node-Red then play the appropriate radio stream. So obviously the value of intentName would be the station I want to play but for testing purposes it will do for right now (until I can train more intents).

I don't know how to grab the intentName value and then how to associate it with a radio stream.

I'm thinking I need a switch Node as I could have multiple entries for different streams.
I tried this setup with a property of msg.Payload.intent == intentName:SirBuildALot7:hello
but that didn't seem to work.

Start by reading the node red docs page Working with Messages.

1 Like

Then follow by reading the Snips MQTT documentation where they explain the entire format of what their messages look like :slight_smile:
But yes, the Working with Messages is most important to start with

Did you use a json node first to convert the json you receive from snips to a Javascript object? After that you can simply use a switch node that filters for msg.payload.intent.intentName to find the right intent.
If you want to do more complex intent interaction with snips where you have one intent with multiple slots you will than have to use a function node that iterates over the object to extract the msg.payload.slots.value.value property afterwards.
Best regards Johannes

1 Like

@JGKK Thank you so much. That is exactly what I needed. I would never have thought to convert to a Javascript object.

I think I will stay away from using slots, I never did well in programming class and it sounds very complicated!

Its not that hard and I'm more than happy to help you with anything nodered and snips related. I have built my whole assistant based on this combination. From timers, calendars and weather all the way to smarthome integration.
Are you on the Openhab forum too? Your profile picture looks familiar.

@JGKK Thanks so much, I appreciate the help. I use Home Assistant maybe from there or the Snips forum.

I think I might tackle timers next, be handy for cooking :slight_smile:

Timer were a complicated one for me. Especially if you want to be able to have multiple at the same time and be able to ask how long they have left.
I would recommend starting with something like a simple how late is it or how is the weather right now.
Than from the Snips Forum.

I have Home Assistant responding to a weather query and controlling some lights with voice commands to Snips.
I've just added Node-Red into the mix and I'm finding it easier to create but there is a steep learning curve.

There is a Good Morning setup I'd like to create. I need to read on how to send TTS and a web-based MP3 to Snips.

You could always use node-red in between: have it get the web based mp3 with an http request node, and publish it as buffer over mqtt to the relevant Snips endpoint that shows in the Hermes API docs.

As far as I know The Snips audio Server only excepts certain wav files. You have to send them as one buffer or a stream of buffers over Mqtt.
If you have the file locally you can use the file node for example.
For mp3 streaming if you are running nodered on the Same machine you can use a command line tool like mpg123. You can pass the stream address to it via the exec node. You can than use pkill and the exec node to stop it again.

ack! Perhaps I'll just use my Chromecast for the Audio out... Although in trying that I've completely confused myself.
I thought it would be fairly simple to have a few Change Node to set various payloads, grab a few values of sensors in Home assistant, join them together and then do some magic (that I haven't worked out yet) and turn that payload into a TTS payload to send to the chromecast.

I got 2 payloads to join together just fine but more than that and the order is completely messed up. I thought that maybe the order was based on the number in this msg.payload : string[38] for each payload. But that wasn't the case.