#Send push notification to user that activated script

1 messages · Page 1 of 1 (latest)

granite imp
#

Hi, I have simple script that does something (not really important) but when it's done, I would like to send a push notification to the user that triggered this script.
I have tried to play with trigger context but haven't got anywhere with that.

I know its not something uncommon but haven't found my solution yet so maybe you guys will help me, thank you!

zenith current
#

how is the script being called?

granite imp
#

Button on the dashboard

zenith current
#

if you have seperate dashboards for users then you could add a variable to the script for name and set the button to pass the name to the script then can use that to work out where to send the notificaiton. It feels like a bit of a hacky solution but might work?

vestal loom
#

this is working for me:

sequence:
  - action: notify.persistent_notification
    metadata: {}
    data:
      message: hello {{ context.user_id }}
alias: My Script
description: ""
zenith current
gaunt orchid
#
alias: My Notify Script
sequence:
  - variables:
      user_mapper:
        ae6d18216a6644a0b0215f78ec9257c9:
          name: karwosts
          notify_action: notify.mobile_app_karwosts
  - action: "{{ user_mapper[context.user_id].notify_action }}"
    data:
      message: hello {{ user_mapper[context.user_id].name }}
#

something like this is probably what you want. Would've been easier if we finally had notify entities for mobile app

#

(assuming you want to send the message using the companion app)