UchihaYuki
(Uchiha Yuki)
November 20, 2023, 9:18am
1
There is an example I found somewhere online:
conversation:
intents:
YearOfVoice:
- "how is the year of voice going"
intent_script:
YearOfVoice:
speech:
text: "Great! We're at over 40 languages and counting."
Which adds a custom sentence and response. But it doesn’t tell HA which language these sentences and responses are written in, so I guess it will use the language of HA.
Is it possible to specify the language of both sentences and responses in the above settings? (Since I use multiple languages myself)
UchihaYuki
(Uchiha Yuki)
November 20, 2023, 1:39pm
2
It seems I can’t set language in the above settings, so I tried the following:
#/config/custom_sentences/en/example.yaml
language: "en"
intents:
ExampleIntent:
data:
- sentences:
- "do you love me"
response: "default"
#/config/custom_sentences/en/example_responses.yaml
language: "en"
responses:
intents:
ExampleIntent:
default: "of course baby"
But I got the following error:
starob
November 20, 2023, 3:03pm
3
There are a few issues in your yaml files:
In example.yaml remove the “response:” line. The remaining lines should be fine.
Put the following lines into your configuration.yaml file and delete the example_responses.yaml file.
intent_script:
ExampleIntent:
speech:
text: of course baby
This should work.
1 Like
UchihaYuki
(Uchiha Yuki)
November 20, 2023, 3:14pm
4
I use multiple languages. This will only work for English.
starob
November 20, 2023, 3:30pm
5
You need to create a second custom_sentences file. Example for German where you put it into the “custom_sentences/de” folder:
#/config/custom_sentences/de/example.yaml
language: "de"
intents:
ExampleIntentDE:
data:
- sentences:
- "Liebst du mich"
And add it to your configuration.yaml
intent_script:
ExampleIntent:
speech:
text: of course baby
ExampleIntentDE:
speech:
text: na klar mein schatz
That’s how I would do it with the knowledge I currently have regarding assist.
UchihaYuki
(Uchiha Yuki)
November 21, 2023, 3:47am
6
Thank you! Your solution works!
But it doesn’t seem natural. Please take a look at this doc:
# Example config/custom_sentences/en/responses.yaml
language: "en"
responses:
intents:
HassTurnOn:
default: "I have turned on the {{ slots.name }}"
If people can custom responses for built-in intents, then I think this should also work for custom ones.
tetele
November 21, 2023, 7:43am
7
You’re right, and here’s how you should go about it:
#/config/custom_sentences/en/example.yaml
language: "en"
intents:
ExampleIntent:
data:
- sentences:
- "do you love me"
response: "default"
#/config/custom_sentences/de/example.yaml
language: "de"
intents:
ExampleIntent:
data:
- sentences:
- "liebst du mich"
response: "default"
#/config/custom_sentences/en/responses.yaml
language: en
responses:
intents:
ExampleIntent:
default: "of course"
#/config/custom_sentences/de/responses.yaml
language: de
responses:
intents:
ExampleIntent:
default: "jawohl"
But there has to be something in the intent_script
for ExampleIntent
intent_script:
ExampleIntent:
action:
- service: script.do_the_twist
UchihaYuki
(Uchiha Yuki)
November 21, 2023, 8:05am
8
Does the filename have to be responses?
tetele
November 21, 2023, 8:08am
9
No. In fact, you can actually place the entire responses:
tree in the same file as the sentences. Something like:
#/config/custom_sentences/de/example_intent.yaml
language: de
responses:
...
intents:
...
1 Like