How to create a custom report


I am trying to work out how to make reports through email on losant. I managed to send the report of an overview dashboard, but it is giving me issues in terms of how to get the context to work correctly. It shows several blocks with “no data to display” when I pass the right context key-values as the ones I see on the losant dashboard. I am unsure if I am using the wrong syntax, but I can’t get it to work.

I also wonder if this is the right way to go about it, or if there is a better way. One of the main reasons for doing this is that the dashboard API allows to turn off “branding” for the PDF report.

This is what it looks like, when it should have some graphs and maps displayed there:

and I am using the
ctx : {
key: value
syntax shown here: Schemas | Losant Documentation

Hi @Braian_Pita, and welcome to the Losant Forums!

It sounds like you’re using the API directly so I’ll need a little more information from you before I can help. Can you send me an example of the request you are sending, complete with the URL, dashboard ID, and request body including the context variable values? (Make sure to scrub any sensitive information such as your Authorization header.)

And I assume you are getting a successful response from the API call, even though the report being delivered doesn’t match what you are expecting?

Thanks, and again, welcome to Losant!

Hey Dylan. thank you for the response.

I figured out my issue, which was that I was forgetting to set the time on my request body to be the current time, I had the default time from the example, which is from before any data was available.

On another note, is this the best way to create a custom report through email? Or do you think there are better ways? I like it, but I feel there is limited customization for the PDF report.

Thank you!

As for the report itself, suppressing the branding as you’re already doing is about as customized as the look of it can get.

You do have some options for customizing the email that delivers the report, though it takes some work to set up in a workflow. The flow is essentially …

  1. Create a webhook in your application.
  2. Generate the report using the callback URL option instead of providing an email address, and provide the URL to the webhook you created. You also need to pass the user’s email address through somehow (i.e. as a query parameter).
  3. Create an application workflow that contains the following …
    1. Webhook Trigger that fires off the webhook you provided as a callback.
    2. SendGrid Node that has your own custom from address, subject, messaging, etc. that sends to the user’s email and includes a link to the PDF (which is in the webhook request body).

If you want a truly customized report, you’d have to go down the route of writing a Jupyter notebook that generates what you’re after. This is by far the most powerful option but also is significantly more complex to set up.