XMPP - TTS / Text forwarding

blueprint:
  name: XMPP Text Message Received
  description: Handle received XMPP text messages with translation, dynamic filters, and TTS announcements.
  domain: automation
  input:
    webhook_id:
      name: Webhook ID
      description: The webhook ID for XMPP messages.
      default: xmpp_inbound
    media_player:
      name: Media Player for TTS
      description: Select the media player for TTS announcements.
      selector:
        entity:
          domain: media_player
    exclude_senders:
      name: Excluded Senders
      description: List of senders to exclude from TTS and popups. Defaults are pre-filled.
      default:
        - home-assistant
    excluded_keywords:
      name: Excluded Keywords
      description: List of keywords to exclude from TTS and popups. Defaults are pre-filled.
      default:
        - Prowlarr
        - sessions
    announcements_private:
      name: Private Message Announcements
      description: Default TTS announcements for private messages.
      default:
        - "Achtung, Achtung! {} hat eine Nachricht geschickt!"
        - "{} hat geschrieben! Hört sich wichtig an!"
    announcements_group:
      name: Group Message Announcements
      description: Default TTS announcements for group messages.
      default:
        - "Neue Nachricht von {} in der Gruppe {}!"
        - "{} hat in der Gruppe {} geschrieben!"
        - "Gruppennachricht von {} in {}!"
        - "{} hat in der Gruppe {} geantwortet!"
        - "Achtung, Gruppennachricht in {} von {}!"
    custom_announcements_private:
      name: Custom Private Message Announcements
      description: Add custom templates for private message announcements.
      default: []
    custom_announcements_group:
      name: Custom Group Message Announcements
      description: Add custom templates for group message announcements.
      default: []

trigger:
  - platform: webhook
    webhook_id: !input webhook_id

condition:
  - condition: template
    value_template: >-
      {{ trigger.json.image_url is not defined or trigger.json.image_url | length == 0 }}

action:
  - service: system_log.write
    data:
      message: "Sender received: {{ trigger.json.sender }}"
      level: info
  - choose:
      - conditions:
          - condition: template
            value_template: >-
              {% set exclude_senders = input.exclude_senders %}
              {% set excluded_keywords = input.excluded_keywords %}
              {% set message = trigger.json.nachricht %}
              {{ trigger.json.sender not in exclude_senders and not (excluded_keywords | select('in', message) | list) }}
        sequence:
          - service: browser_mod.popup
            data:
              title: >
                {% if trigger.json.is_groupchat %}
                  💬 Nachricht in der Gruppe {{ trigger.json.muc_title or trigger.json.muc_room }}
                {% else %}
                  💬 Nachricht von {{ trigger.json.sender }}
                {% endif %}
              size: wide
              content:
                type: vertical-stack
                cards:
                  - type: markdown
                    content: |
                      **Originalnachricht:** {{ trigger.json.original_message }}

                      **Übersetzte Nachricht:** {{ trigger.json.nachricht }}
          - service: input_text.set_value
            data:
              entity_id: input_text.xmpp_last_sender
              value: "{{ trigger.json.sender }}"
          - service: tts.piper
            data:
              cache: true
              media_player_entity_id: !input media_player
              message: >
                {% set muc_title = trigger.json.muc_title or trigger.json.muc_room %}
                {% set sender_name = trigger.json.sender %}
                {% set all_private_announcements = input.announcements_private + input.custom_announcements_private %}
                {% set all_group_announcements = input.announcements_group + input.custom_announcements_group %}
                {% if trigger.json.is_groupchat %}
                  {% set announcement = (all_group_announcements | random).format(sender_name, muc_title) %}
                {% else %}
                  {% set announcement = (all_private_announcements | random).format(sender_name) %}
                {% endif %}
                {{ announcement }} {{ trigger.json.nachricht }}.
mode: restart

Description will follow once the component is up and running. Only for testing at this moment.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Hello ThUnD3r-Gr33n,

Thanks for contributing to the community with a new Blueprint.

I have a suggestion for you. Many people who are not familiar with directory structures will have problems installing this without the Home Assistant MY tools.

Adding a MY link for this Blueprint to your top post would help them a lot.

Here is the link to make that.
Create a link – My Home Assistant

Note: if the original is in the forums here, only 1 code block can be in the top post ot the MY link tool will not work.