RESTful Notify and optional fields

Hi everyone, I am struggling setting up the RESTful Notification integration (RESTful Notifications - Home Assistant) for a chat platform, allowing to pass optional fields.

The api of the chat platform I am trying to use takes a message and a target - as usual - but it also takes (optionally) a bunch of extra fields (ie icon_url). I am trying to map these extra fields to the data field.

My ideal goal would be to be able to send a message such as

service: notify.chat
data:
  message: hello

or

service: notify.chat
data:
  message: hello
  data:
    icon_url: 'whatever'

and have either of them work.

My config currently looks something like

- platform: rest
  name: chat
  resource: https://xxxxxxxxxxx/hooks/xxxxxxxxxxxxx
  method: POST_JSON
  target_param_name: channel
  message_param_name: text
  data:
    icon_url: '{{ data.icon_url if (data.icon_url is not none) else "" }}'
    icon_emoji: '{{ data.icon_emoji if (data.icon_emoji is not none) else "" }}'

but this doesn’t seem to work. Again, my goal here would be to have the flexibility to pass no extra data, or just icon_url, or icon_emoji, or all of the fields. Honestly I’d even prefer to be able not to pass any default value, but that seems to be mandatory.

Anyway, I hope someone can help me figure this out!