Losant API " Event Export" as attachment, not email link

Im trying to export event data on a 60-90 basis ( as part of a regulatory requirement ).
I am able to get the required data in my workflow gathered and the generic LOSANT email sent to the client of my choosing, but can not rely on the clients opening and saving the data beforethe url expires. So I need to actually emai the *.csv file to them as an attachment.

I have yet to find find a way to retrieve/find that file once created by the API and attach it. Any help appreciated

Just yesterday we released a new template that is remarkably close to your use case - the main difference being you are doing event exports and this template does dashboard reports. I would recommend importing this template into your application and seeing if you can modify it to fit your use case.

One note of caution is, event export calls are limited to one request every five minutes per application, so you have to make some modifications to the template - the resource job and the workflow - to avoid running into this limit. I just filed a request with the engineering team to get that changed to one concurrent request per application.

As to your specific questions … I am assuming you are using the Events: Export call with the “email” option (sending the export file directly to your users) and not the “callbackUrl” option (which would send the link as an HTTP POST request to a URL of your choosing once the report has been generated - usually a Losant Webhook). You would only be able to retrieve the URL to the file if you were using the “callbackUrl” option, which you could then use to …

  1. Trigger a workflow from the webhook URL provided as the callbackUrl
  2. Download the file’s contents with an HTTP Node
  3. Send it to your user using the SendGrid Node, which supports sending attachments

Lots to take into account there, so I would definitely start from the template i mentioned before. Let us know if you have any other questions.

Dylan
Thank you for your reply. I was previously able to configure the Losant API to process a “Event Export” and use the “experienceGroupId” to set the main client email address as the reciever of the email along with the group the exported events were associated with.
But I as I mentioned if the client does not download it soon, the link expires ( I do not know exactly how long the link is valid).

Currently I am triggering with a virt button , but I am able to iterate over all child groups with a Group Tag(s) that adds a suitable time to run the next report given the last export success so the iteration thru the client data is handled on more a “timer” than your example.

What I need to do is email the attachment to the client for their records , not the link.
It looks as if your workflow accomplishes that at some point but when I water it down ( remove dashboard, iteration & token references) change the job execute to point to a Event Export resource job rather than Dashboard I have no success. The error is iteration related althought Im confident I removed all those references.

Regards,

Stewart

But I as I mentioned if the client does not download it soon, the link expires ( I do not know exactly how long the link is valid).

The signed URLs expire 7 days after issuance.

What I need to do is email the attachment to the client for their records , not the link.
It looks as if your workflow accomplishes that at some point

There is a SendGrid Node in the template’s workflow that is not attached to the rest of the output; its configuration mostly matches the Email Node that is in the flow, except the SendGrid Node does support sending attachments so it is configured to do that instead of just sending a link. This requires you to create your own SendGrid account and do a little setup on the Losant side to add your API key in a service credential for the node - but, as we tell people often, we strongly recommend this approach for production applications as the Email Node often gets flagged as spam.

There is an alternative approach you could take - instead of emailing the signed URL that expires to your end users, you could …

  1. Download the file’s contents using the HTTP Node.
  2. Use a File: Create Node to save it to your Application Files.
  3. Email the user the link to the file as it’s stored in your files vs. sending the signed URL, as the files link will never expire.

That same template demonstrates something very similar to what I’m describing here, connected to the Job: Complete Trigger; we are downloading the job’s completion report and saving it to our files. You could take those same nodes and bring it into the Job: Iteration Trigger section to do something similar.

The downside to this approach is that anything in Application Files should be considered public - meaning anybody who got hold of the link could download the contents without any kind of authorization checks. Because of that, this may not be an acceptable solution for you.