t0mer / green-api-custom-notifier

Send whatsapp notification using green API
Apache License 2.0
37 stars 2 forks source link

[Feature Request] Add support for defining target in the notify service config, in order to be able to create notify groups #1

Closed shlomki closed 6 months ago

shlomki commented 6 months ago

Some notify services such as the Telegram Bot allow defining the target (chat_id) in the notify service itself. This has multiple benefits:

  1. You don't have to specify the target every time you want to send a message (e.g: notify.tomer).
  2. Allows creating notify groups, which simplify the usage of notification services.

Here's an example:

notify:
  - name: daddy
    platform: telegram
    chat_id: 11111111

  - name: mommy
    platform: telegram
    chat_id: 22222222

  - name: girl
    platform: telegram
    chat_id: 33333333

  - name: family
    platform: group
    services:
      - service: daddy
      - service: mommy
      - service: girl

This way, you could simply call notify.family and all notify accounts would get triggered, without having to specify targets ids. Currently, the integration doesn't support that, and you must specify the target every time you want to use the notify.greenapi service.

After this change is implemented, this is how I expect the configuration to look like:

notify:
  - platform: greenapi
    name: Tomer
    instance_id: #Set Instance ID
    token: #Set Token
    target: #Set Target

And the service would be called this way:

- service: notify.tomer
  data:
    message: "Hello World"
shlomki commented 6 months ago

I've changed the code to add this feature. I'll make a pull request shortly.