Application Importing Workflow

Is there a way to automate or semi-automate application imports in Losant?

We currently maintain two nearly identical applications. One for development and one for production, with a test environment being added soon. Our goal is to automate the import process as much as possible. Does Losant support this natively, or do you have any recommendations on how to approach it?

It’s not natively supported but you could write some simple application workflows to do this.

For example, an application could be exported to a Git repository using the Losant API Node and the Application: Export action. You could fire that daily using a Timer Trigger.

Similarly, you could import into an application regularly using a Timer Trigger and a Losant API Node using the Application: Import action.

That said, most users want to automate exporting resources as a backup option while tightly controlling the import process as that can have unintended consequences on the receiving application, so if you can provide some more information on what the process you are trying to achieve looks like, I may be able to offer a better recommendation.

Sorry, maybe automate was a poor choice for wording. I would manually trigger the import from, lets say dev to test. But I want the process itself to be “predefined”. I am trying to avoid manually selecting the source and destination application, resources I want to import, and how to handle conflicts. So the dry-run would execute first, then based on the dry-run execution result, it would or wouldn’t continue with the actual import.

Say for example, I want to migrate from dev to test, I would run a script “dev_to_test.py”, which has hard coded import settings, and that would proceed with the import.

So if you’re looking to run a script outside of Losant workflows or the user interface, I would utilize the API directly.

If you want to import from one application to another, you would need to create a user API token to authenticate the request - for a user who has access to both applications. You can lock the token down to just the Application: Import permission.

You would need to provide a callback URL to receive the results of the dry run, or just regularly poll the Application Import Logs API endpoint.


That said, your Python script could also directly invoke a Losant workflow to handle what I’ve described above - initiating the dry run, handling the callback, alerting in case of errors, possibly parsing the dry run CSV, and executing the actual import. That could be invoked through a webhook request or the Press Virtual Button API endpoint.

Hopefully that’s enough to point you in the right direction. I don’t want to throw too many options at you and muddy things so if you settle on a path forward and have additional questions, just let us know.

That is super helpful. Thank you.