Best Practise for creating intents?


#1

Sorry if this has been asked before, I’ve searched the forum but have not found an answer …

I wonder what is the best practise when you create an app , for example, to control the music via HomeAssistant.
From my understanding I have two possibilities.

#1
I could create an app where each control is an intent of its own, eg. playIntent, pauseIntent, stopIntent, …
Which would lead to a dedicated intent handling in Home Assistant since I would need to react on each of those intents.

#1
PlayIntent
“Play me some music”
“Play the music in the kitchen”

PauseIntent
“Stop the music in the livingroom”
“Pause the music please”

Used Slots would be room only

#2
In contrast to that, I could create one intent MusicControl and define play,pause,stop,… via a specific Slot musicCommand…
With this intent i would only need to handle the intent MusicControl in Homassistant and extract the command via the slot type from the json object.

MusicControl
“Play me some music in the bathroom”
“Stop the music in the livingroom”
“Raise the volume in the kitchen”

Used Slots would be “room” and “musicCommand” where play, pause, stop are values within the slot.

Does #1 lead to a better recognition? Is this how the system is designed and should be used? Does it make any difference at all? Do I miss something here?

Right now I am using #2 and control my lights and my TV just fine. Just want to make sure when I set up my assistant via #2 I won’t come to a point in the future where I have to rewrite everything because I was missing some basic understanding of the concept of snips architecture.


#2

Imo there’s no best pratice. You create an app for music. You can have different intents for each actions in that said app, or everything in one intent. It’s a question of reading the slots or not then. Soon or later, you’ll have to fuse intents together and create slots, as your intents will start to overlap themselves, eg. “Turn of the TV vs Turn off the lights”. Even Google Home fails at “Turn on the tv” if you have Philips Hue linked. This is because both your intent use “turn off” so bot should be fused using a slot for TV and lamps.

But this you’ll only see when you hit the wall, because it’s natural to make an app for your lamps and another for your tv


#3

even in your example it is just another way of combining even more but would not be necessary.
It can as well be two intents “turn ON the TV” and “turn ON the light” as long as every training sentence contains “the TV” or “the light” as well, there is still no need for combining.

So it is just “make everything unique enough or combine it so the slots are required and asked for if not clear”


#4

Hey @Kraken,

I agree with @Psycho and @Philipp: When it makes sense, put it in one intent. I have a big intent with 6 slot types and nearly 400 examples. And it works great so far using one slot as command.

bye
freddy


#5

@Philipp trust me, it’s a necessity when you reach 100 intents :slight_smile:


#6

But doesn’t that make the “store” almost useless? You would have to fork every app and create your own combined intents.
From my point of view, I would prefer 10 apps working with each other out of the box, because everybody made their intents really unique.

Yes, it might sound strange to always say “turn up the volume of my television” if you don’t have any other device with volume output - but it would be the only way in my opinion to make all apps “work out of the box” with each other.

Most people don’t have the luxury to use almost only self developed apps :wink:


#7

Don’t other voice assistants solve this by having you ‘enter’ a skill? For instance:

  • “Hey Snips, enter television skill”
  • “Hey Snips, turn up the volume” -> activates intent VolumeUpTV
  • “Hey Snips, enter Spotify skill”
  • “Hey Snips, turn up the volume” -> activates intent VolumeUpSpotify

Another solution is having Snips take into account the context in its intent recognition: If a TV-related intent was recognized before, the chance that the next intent is also TV-related is higher. For instance:

  • “Hey Snips, turn on the TV” -> activates intent TurnOnTV
  • “Hey Snips, turn up the volume” -> activates intent VolumeUpTV and not VolumeUpSpotify

#8

Well, try google home, if you have a chromecast and philips Hue. Turn on the television gives you an error: No philips Hue in this room.

I understand the app point of view of course. I’m using apps divided by internal modules for Alice also, but getting on high numbers of intent is getting really sportive


#9

Thank you all, for the great feedback! It is good to hear that working with a few intents and a lot of slots is definetly a possible way to go.

What I did so far was to separate my Apps by device classes, e.g. Music,TV, Lights. I understand that it is important to have proper training sentences that contain the “app hotword” like television, musik, tv… to prevent false positive, because there is no differentiation between apps or something like a context.

Do we have any possibility to assign something like a hotword for apps to define the context of a general “turn off”-command like @koan proposed?

As there is no information whatsoever about the app corresponding to the recognized intent within the hermes messages, apps seems to be just a artificial structual level within an assistant. At least when you have no action /skill defined within your app. So in my use case (snips -> HomeAssistant) having different apps for different device classes is no difference compared to having different intents for those device classes. @psycho Is this what you meant?

I have now a better understanding of how to create my intents and will redo my assitant over the next few days like @freddy proposed and compare it to my previous approach in terms of recognition and report back.

I still think it would be great to have some kind of context on app level - whenever television is recognized use only intents from the televison-app.