I try to create a reusable script thats prompts Gemini as an AI Task. The resonse variable e.g. response stores the response as text in the data key of a dictionary:
response:
conversation_id: 01KDDTTKW693RMT343PVDFJ87D
data: Hallo Acema! Es ist schön, dich zu sehen. Wie war dein Tag heute?
This response variable should be passed to another script that forwards this text to an Alexa or Voice Assistant device.
The calling script defines that the prompt script (see above) returns a value:
sequence:
- action: script.1766399657012
data:
prompt: Sag Hallo Acema
response_variable: response
- action: script.ki_sagen
data:
device: media_player.home_assistant_voice_0585da_media_player
message: "{{ response.data }}"
alias: KI Test
description: ""
Unfortunately the object(?) isn’t copied into the respnse variable response, see traces:
response: {}
Any advice how to proceed? Do I have a major missunderstanding of fields and response variables?
sequence:
- action: ai_task.generate_data
metadata: {}
data:
task_name: Prompt
instructions: >-
Du bist ein Hausdiener und sprichst auf deutsch mit einem Kind von 12
Jahren. Es ist {{ now().strftime('%A %H:%M %d.%m.%Y') }}. Die Antworten
werden gesprochen.
{{ prompt }}
entity_id: ai_task.google_ai_task
response_variable: response
alias: KI prompt
description: Gemini antwortet auf einen Prompt
fields:
prompt:
selector:
text:
multiline: true
name: Prompt
required: true
sequence:
- action: ai_task.generate_data
metadata: {}
data:
task_name: Prompt
instructions: >-
Du bist ein Hausdiener und sprichst auf deutsch mit einem Kind von 12
Jahren. Es ist {{ now().strftime('%A %H:%M %d.%m.%Y') }}. Die Antworten
werden gesprochen.
{{ prompt }}
entity_id: ai_task.google_ai_task
response_variable: response
alias: KI prompt
description: Gemini antwortet auf einen Prompt
fields:
prompt:
selector:
text:
multiline: true
name: Prompt
required: true
That gets the var from ai_task and it’s sitting in response - BUUUT…
You never pass the var back out of your script - To do that, you have to do this:
sequence:
- action: ai_task.generate_data
metadata: {}
data:
task_name: Prompt
instructions: >-
Du bist ein Hausdiener und sprichst auf deutsch mit einem Kind von 12
Jahren. Es ist {{ now().strftime('%A %H:%M %d.%m.%Y') }}. Die Antworten
werden gesprochen.
{{ prompt }}
entity_id: ai_task.google_ai_task
response_variable: response
- stop: Return Response
response_variable: response
alias: KI prompt
description: Gemini antwortet auf einen Prompt
fields:
prompt:
selector:
text:
multiline: true
name: Prompt
required: true
That lets the next script have response so it can grab .data. dont do that and you get null.