#Using a script field for the "data" section of a notification action.

7 messages · Page 1 of 1 (latest)

craggy girder
#

My notification script is used in a lot of automations, so it needs to be very customizable - and I'm hoping to add actionable buttons to the mix.

I know how to hard code these, using the "data" section of a notify action, but I'd like to use a selector field to populate this instead. I've tried using a Text selector, but no buttons show up.

  selector:
    text:
      multiline: true
  name: Data
  default: |-
    actions:
          - action: test_okay
            title: "Okay"```

But whenever I try to add the {{ data }} to the action, it turns to this: "[object Object]": null

```action: notify.notify
metadata: {}
data:
  title: "{{ title }}"
  message: "{{ agent.response.speech.plain.speech }}"
  data:
    "[object Object]": null
enabled: true```

Any help would be appreciated- either how to solve the issue, or a better way of tackling it.
fathom glen
#

Did you provide the variable when you called the script?

#

The value provided for default is not sent by default. It's just the default value shown in the GUI, which you can decide to send if you don't change it

craggy girder
#

I learned that the hard way with a previous issue lol. I'm testing the script from the interface, rather than the editor - and enabling/setting the variable there when testing.

I assume even when I do this, it's not sending it through since the code changes to "[object Object]": null - which will be set as such regardless of the variable, instead of being the field name.

Hopefully I'm making sense.

hard latch
#

can you show exactly what you tried to put in the editor, before it was replaced?

#

[object Object] makes me think you have an unquoted template, since it otherwise interprets raw { } as object notation instead of a template

craggy girder
#

Ah! I was using it unquoted! I could have sworn I tried using it both ways, but I must have gotten mixed up. I need to stop coding at 5am lol.

Unquoted shows the button now, thank you!