How to get the response variable from a conversation into a input_text

Hi,

Just trying to let my Sonos tell me every evening a bedtime story which chatgpt is creating. Due to that this takes about 10-20sec to process I want to store the response into a text input helper (I already increased the maximum characters to store to 2000)

But unfortunately there is nothing stored into the text, I also get no warnings or errors. To confirm that it is generally working I added a notify to my Phone, which is working fine.

Any ideas what I’m doing wrong?

Automation:

alias: ChatGPT Test
description: ""
trigger: []
condition: []
action:
  - service: conversation.process
    data:
      agent_id: bb818bce4388ebe27a8d54531d1e4d7d
      text: >-
        Tell me a random bedtime story
    response_variable: chatgpt
  - service: notify.mobile_app_s23ultra
    data:
      message: "Assist Reply: {{ chatgpt.response.speech.plain.speech }}"
    enabled: true
  - service: input_text.set_value
    target:
      entity_id: input_text.test
    data:
      value: "{{ chatgpt.response.speech.plain.speech | string }}"
mode: single

An entity’s attributes can store up to 16Kb. I suggest you create a Trigger-based Template Sensor and store the response variable’s value in a custom attribute.

1 Like

Thanks, unfortunately the gui let you set a value greater than 255…

But your suggested solution is now working.

Thanks

For future reference, when the form field’s title is displayed in red it indicates there’s a problem with the field’s value.

1 Like

Hello! First time poster and sorry for reviving a sort of old post but I’ve been wanting to do something similar. Would you mind giving me some kind of pointer as to what you did to fix this @heschdy? Not fully grasping @123s comment :slight_smile:

1 Like