Create automation with notify message thats changes based on the trigger action?

Im just creating this simple test automation to help me get started with understanding how to do certain things within automations on home assistant. Im attempting to get a notify message to my phone that has the companion app. I got the alerts to work for unplugging and plugging in my phone, but I want the message to change based on the trigger that activates it. Example " if devicec plugged in then message would be" Phone was plugged it", but if the device gets unplugged the same automation would send “phone was unplugged” but im unsure how to grab the correct data when putting it into the message field.

alias: 'Test Notify '
description: ''
trigger:
  - type: plugged_in
    platform: device
    device_id: 55de674b1b5772cbe834188d3b1a2c9e
    entity_id: binary_sensor.sm_g988u_is_charging
    domain: binary_sensor
  - type: not_plugged_in
    platform: device
    device_id: 55de674b1b5772cbe834188d3b1a2c9e
    entity_id: binary_sensor.sm_g988u_is_charging
    domain: binary_sensor
condition: []
action:
  - service: notify.all_devices
    data:
      message: test
mode: single

One way ( there are many ways) would be:

alias: 'Test Notify '
description: ''
trigger:
  - type: plugged_in
    platform: device
    device_id: 55de674b1b5772cbe834188d3b1a2c9e
    entity_id: binary_sensor.sm_g988u_is_charging
    domain: binary_sensor
    variables:                                                                        
      triggermsg: My smart phone plugged
  - type: not_plugged_in
    platform: device
    device_id: 55de674b1b5772cbe834188d3b1a2c9e
    entity_id: binary_sensor.sm_g988u_is_charging
    domain: binary_sensor
    variables:                                                                        
      triggermsg: My smart phone unplugged
condition: []
action:
  - service: notify.all_devices
    data:
      message: '{{ triggermsg | default(''nada'') }}
mode: single

Or you can use the trigger data itself. See