Problem with Alexa Media Notification and Google generative AI ("back slashing")

When I write any automations using Google Generative AI (response variable) and Alexa Media Notifications, the echo starts by first saying “text” prior to the message, then repeatedly adds (“back slash”) or (“back slashing”). Usually tts and Alexa media doesn’t first announce as “text”. No clue where the black slashing comes from. When testing the prompt it doesn’t show any characters or anything that would be spoken as “back slashing” when I manually test the prompts action then paste the response instead of using {{response_variable}} its spoken just fine. I’m not certain why this happens and how to correct it. I certainly don’t want to hear text before each notification or Alexa say “Back Slashing”.

description: "Sample"
mode: single
triggers:
  - trigger: zone
    entity_id: person.sarah
    zone: zone.home
    event: enter
conditions: []
actions:
  - action: google_generative_ai_conversation.generate_content
    metadata: {}
    data:
      prompt: >-
        Welcome Sarah back home. Be friendly and sweet. Do not not worry about
        language, being PG or SFW. Give a short response in clean text with no emoji's symbols, unnecessary characters or formatting.
    response_variable: welcome_response
  - action: notify.alexa_media_bob_b_echo_dot
    metadata: {}
    data:
      message: "{{welcome_response}}"
      data:
        type: tts

I’m kinda guessing that the welcome_response actually contains some garbage text and several backslashes. Maybe try {{ welcome_response | replace("\\","") }} just to see if it helps the backslash part.

I had the same issue. Try adding .text after your variable “{{welcome_response.text}}”

1 Like

Ahhh something as easy as that. Thank you, I was also trying to solve this.

I added a time addition to my prompt using.

      prompt: >
        Generate a welcome for Bob and announcement of the current time. The
        current time is {{ now().strftime("%I:%M %p") }}. Keep it brief and
        suitable for a voice announcement.

This prompt works well.

Thanks! I just added .text to the sanitization I already had.

action: notify.alexa_media_bob_b_echo_dot
metadata: {}
data:
message: >
{% set response = door_response.text | replace(‘Text’, ‘’) | replace(‘\’,
‘’) | replace(‘"’, ‘’) | replace(“'”, ‘’) %} {{ response.strip() }}
data:
type: tts

I’m having this exact issue.
I have llm vision scan my camera feed. Then I get the response variable as llmvariable.
Then I pass the variable to notify Alexa as below

Alexa also says “Response underscore text”
Then the message from the variable llmvariable.
Lastly it say “back slashing” or sometimes “exclamation marks”

I tried both OpenAI and Gemini. Both creates similar results.

How can I format the text so that it won’t say all these extra characters.

Thanks