diff --git a/src/data/conversation.ts b/src/data/conversation.ts index 8a3bf388e8..e4a096fb3c 100644 --- a/src/data/conversation.ts +++ b/src/data/conversation.ts @@ -9,6 +9,8 @@ interface ProcessResults { export const processText = ( hass: HomeAssistant, - text: string + text: string, + // tslint:disable-next-line: variable-name + conversation_id: string ): Promise => - hass.callApi("POST", "conversation/process", { text }); + hass.callApi("POST", "conversation/process", { text, conversation_id }); diff --git a/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts b/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts index d5471f5444..b42d1c9eb1 100644 --- a/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts +++ b/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts @@ -22,6 +22,7 @@ import { PaperInputElement } from "@polymer/paper-input/paper-input"; import { haStyleDialog } from "../../resources/styles"; // tslint:disable-next-line import { PaperDialogScrollableElement } from "@polymer/paper-dialog-scrollable/paper-dialog-scrollable"; +import { uid } from "../../common/util/uid"; interface Message { who: string; @@ -62,6 +63,7 @@ export class HaVoiceCommandDialog extends LitElement { @property() private _opened = false; @query("#messages") private messages!: PaperDialogScrollableElement; private recognition?: SpeechRecognition; + private _conversationId?: string; public async showDialog(): Promise { this._opened = true; @@ -166,6 +168,7 @@ export class HaVoiceCommandDialog extends LitElement { protected firstUpdated(changedProps: PropertyValues) { super.updated(changedProps); + this._conversationId = uid(); this._conversation = [ { who: "hass", @@ -258,7 +261,11 @@ export class HaVoiceCommandDialog extends LitElement { // To make sure the answer is placed at the right user text, we add it before we process it this._addMessage(message); try { - const response = await processText(this.hass, text); + const response = await processText( + this.hass, + text, + this._conversationId! + ); const plain = response.speech.plain; message.text = plain.speech;