Script to notify with dynamic actions

Hey All.

I’m a software engineer, so I want to DRY my code. One aspect that I would really like to centralize is sending notifications to a specific set of devices. For this reason, I would like to create a script which can be used to send notifications to specific devices, but the title, message, actions, etc should all be dictated by the automation or other trigger.

It is trivial to pass title and message to the script (doc for reference); however according to the section on passing parameters, it seems like only strings are supported. This means that I cannot pass dynamic actions which is a big feature of the notifications I would like to send to mobile devices specifically.

Here is my script so far:

alias: Notify Monitors - Basic
sequence:
  - service: notify.mobile_app_bryans_iphone
    data:
      title: '{{ title }}'
      message: '{{ message }}'
description: Notify all of devices
fields:
  title:
    description: The Title of the notification
    example: Example text
  message:
    description: The content
    example: Example text
    required: true
mode: single
icon: mdi:message-badge

Even if I add the actions parameter to the script and attempt to pass it to the notify.... service under data (like normal), it fails. It seems like the parameter is probably being stringified which is probably not supported by the notifier.

Am I missing anything, or is this just a limitation of the system at this time?

did you find a solution for this? I had the exact same idea, making a generic notification script and invoking it with parameters. I use ‘dynamic content’ in the strings as well

Can you share an example of the kind of actions or dynamic content you’re wanting to pass?

I hope you eventually found a solution to your problem! I also wanted to say ‘thank you’ for the example! I’m using this script so I don’t have to recreate the wheel everytime I want to send notifications from an automation. Thanks!!