@Igo_Monteiro there are two different ways you could accomplish this …
- User clicks your “Export Data” button
- Doing so submits an asynchronous request to an Experience Endpoint that fires an Experience Workflow.
- That workflow queries the data you’re requesting using a Data: Time Series Node (or, if necessary based on the nature of your query, the Data: Time Series Query action of the Losant API Node).
- Convert points from the JSON object to a CSV string using a CSV: Encode Node. You may need to insert one or more nodes before this point to modify the data for your specific purposes. (You could also do this conversion to CSV browser-side, skipping this step in the workflow and using a library to do the conversion in the user’s browser.)
- Using an Endpoint: Reply Node, send the CSV string back to the browser.
- On receipt in the browser, make the browser download the result.
If the size of the data you are attempting to request is too big to fit into a single API call, you could instead do the following:
- In Losant, create a webhook. You’ll need the URL of the webhook in a later step.
- On click of “Request Data Export”, fire an Experience Endpoint as before. You can provide immediate feedback to the user that the request is being worked on and that they will get a link in their email.
- In the workflow run, use a Losant API Node and execute a Data: Export request, making sure to include a callback URL in the body of the request. That callback URL should be the URL of the webhook you created. You will also need to include the user who made the request’s email address as a query parameter.
- Create an application workflow and, within it, use a Webhook Trigger and set it to execute on requests to the webhook you created.
- In the body of the webhook request will be a temporary signed URL for the generated CSV. Using the email address passed through the query parameter, you can send this URL to the user with an Email Node or a SendGrid Node.