Send phone notification based on email subject

I want to send my phone a notification whenever I get an email with a specific subject from hotmail. I looked at the IMAP integration and searched online, but I’m too much of a noob to figure this out. I get notifications whenever I get an email or whenever I read it, but I want to only get the notification for specific emails with a specific subject. Can anyone help me?

Hi, from IMAP - Home Assistant

template:
  - trigger:
      - platform: event
        event_type: "imap_content"
        id: "custom_event"
    sensor:
      - name: imap_content
        state: "{{ trigger.event.data['subject'] }}"
        attributes:
          Subject: "{{ trigger.event.data['subject'] }}"

Thanks! But how do I specify the subject I’m looking for? Also, I tried creating an automation using this device and it sends me a notification for any email and also sends another one if I select and read it.

The IMAP setup you have shared has some issues…

The YAML configuration that has been added in the Template to create custom event data field doesn’t belong there. For a general purpose IMAP sensor, you should leave that field blank.

You can use a more specific trigger as well as conditions (the “And If” section in the Automation editor) to control whether the actions of the automation get executed or not. For example, the imap_content event data contains a variable initial which can be used to prevent the issue described above.

The following is an automation example that shows using a more specific trigger so that only new emails will fire it, and a template condition to search the email’s subject:

alias: Notify on Special Email Subject
description: ""
trigger:
  - platform: event
    event_type: imap_content
    event_data:
      initial: true
condition:
  - alias: Check for specific phrase in subject
    condition: template
    value_template: >-
      {{ trigger.event.data['subject'] is search('Specific Phrase') }}
action:
  - service: notify.EXAMPLE
    metadata: {}
    data:
      message: "The Message that OP wants to send"
mode: single

If you give us a more specific description of the conditional logic that you need, we can help you expand the above example to fit your situation.