admin管理员组

文章数量:1122846

I am having Issues with my home assistant webhook that sends the Alexa json to ChatGPT. I have created a custom Alexa Skill with one intent and a few utterances to "prompt". My home assistant webhook automation looks like this:

automation:
  - alias: ChatGPT Webhook Dynamic Handler
    trigger:
      platform: webhook
      webhook_id: chatgpt_webhook
    action:
      # Step 1: Check if the payload contains a 'prompt'
      - choose:
          - conditions:
              - "{{ 'prompt' in trigger.data }}"
            sequence:
              # Step 2: Send the 'prompt' to the OpenAI API using the REST command
              - service: rest_command.openai_query
                data:
                  prompt: "{{ trigger.data['prompt'] }}"

              # Step 3: Wait for the response from OpenAI
              - wait_template: "{{ states('input_text.chatgpt_response') != 'Awaiting response...' }}"
                timeout: "00:00:10"
                continue_on_timeout: false

              # Step 4: Save the response for reference
              - service: input_text.set_value
                data:
                  entity_id: input_text.chatgpt_response
                  value: "{{ states('input_text.chatgpt_response') }}"

              # Step 5: Notify the response using TTS
              - service: notify.media_player.office_echo
                data:
                  type: tts
                  message: "ChatGPT Response: {{ states('input_text.chatgpt_response') }}"
                  title: "Webhook Response"

              # Step 6: Notify the response for debugging
              - service: persistent_notification.create
                data:
                  message: "ChatGPT Response: {{ states('input_text.chatgpt_response') }}"
                  title: "Webhook Response"

      # Default action if 'prompt' is not in the payload
      default:
        - service: persistent_notification.create
          data:
            message: "Webhook triggered, but no 'prompt' found in data!"
            title: "Webhook Debug"

Im wondering if someone out there can point out whats wrong in the code?

I have spent countless hours formatting and trying different variations of the base code, but i'm having trouble getting it to work.

本文标签: ChatGptHome AssistantAlexa IntegrationStack Overflow