Notifications with parameters or loop

I wonder how to manage notifications with parameters.

I want to export a dashboard which has a parameter. This parameter could be empty or have a few values. For each value, I want to send a notification (it will be an email, with variables in the body and an attached xls).

To set the idea, the parameters would be something along the line “each event id having happened 2 days ago”. We are talking about 0 to 5 events per day maybe.

My ideas so far are not great:

  1. using the API to generate an export. Parameters are then easy but I have to deal myself with email sending => doable but not ideal
  2. using the API to trigger a notification, but I am stuck with the setup of the parameters. Is there a way to have parameterised notification? => not doable as far as I know
  3. I might be able to create a custom token, which would return multiple IDs. Assuming I can, how can I have one notification per ID? => not doable as far as I know

Except for option 1 (manual export), would there be any way to achieve what I am looking for?

Cheers,

2 Likes

Typically I’ve done this sort of thing without the need for the API because you can parameterize each notification based on the user receiving said notification.

If you want to create notifications using the API, it’s doable but you probably aren’t going to find a lot of documentation on it as almost everyone sets these up using the UI. If you do want to create these programmatically, you can. I’d recommend using the browser network trace to watch the requests that Dundas BI sends to the server and then simply copy the idea.

Like this:

Once you can see the REST calls that we are making, you can use the API docs to get the full usage of these calls.

https://www.dundas.com/support/api-docs/rest/

Thanks for this Jeff,

I am not sure this actually fits my use case.

I do not actually know how many notifications I need to send per day. I am pretty sure I can get the list of relevant event IDs in a smart way, but then I will need to send one email per event ID. It might be 0, it might be 1, it might be more.

For the API indeed, I am using the developer tools a lot. it’s great that Dundas does everything via its rest API, it helps a lot the understanding.

No problem Guillaume.

If you are looking to do this 100% API based perhaps you could just create a template notification and then modify it to force it to send when you want it. As an example:

Make a one time notification and just change it with code:

  • modify the send time to be 1 minute form now
  • modify the parameters
  • modify the recipient
    etc.

Thanks Jeff,

I was thinking of updating a notification (which is not possible), but fully creating a new one each time would indeed do the trick. Thanks for the idea.

I am not looking per se into doing it 100% API based, it’s just that I have not found a better way to do it via the gui itself. I would love to be proved wrong!

Cheers,

For posterity, this is what I ended up doing.

I first tried to create a notification from the rest API, by snooping what happens when I create one via the web interface. Well, because Dundas use GUID absolutely everywhere, I just could not understand what it was doing. I managed to find half the GUIDs, but the other half stayed incomprehensible, so I could not use this option.

Updating a notification did work, via the rest API. I update pydundas to manage notifications, so my code is now (almost) literally:

api = pydundas.Api(pydundas.Session())
napi = api.notification()
n = napi.getByName(notification_name)

for data in all_data_to_notify_about:
    n.set_recipients([])
    for rcpt in email_rcpts:
        n.add_email_recipient(rcpt)

    n.set_subject(f"Cool subject")
    n.set_body(f"Meaningful body, including data coming for the data object")
    n.update()
    n.run()
    n.waitForCompletedRun()