Hi there. Since it is possible to create new integrations via REST API, I was wondering if it is possible to create new triggers for workflows by the REST API in order to use the newly created integrations. I found the Flow patch command, but it does not seem to add new triggers? Is there another way to do it?
Many thanks in advance
Hi Jonas_Helmstetter and welcome to the Losant Forums!
We do have the option to create (Post) or edit (Patch) a workflow, including its triggers, using the API.
That being said, we strongly recommend using the UI due to the complexity involved with programmatically building out node configurations and defining their relationships. We suggest at least using the UI to build an initial template workflow to get the underlying JSON as a starting point.
Let us know how it goes!
Thanks for the hint. I got the workflow working and it creates an integration automatically. I also got the automatic worklfow creation withe the newly created mqtt integration working . The hint about the json template was very helpful. Many thanks for the great support.
By the way: Is there any source for best practises for losant development? Like best practise for payload paths or multi user development?
One thing I learned is that it is needed to send several post requests. This way you get the ids for the nodes in order to connect the nodes by outgoing ids. The order I used was:
- Create a new workflow with one node via Flows POST.
- Get the nodes id via (Flow GET)
- Patch a trigger of the flow with the previously gotten node ID so that the trigger output is connected to the nodes input. (Flow PATCH)
Maybe there is a more elegant way, but this one worked for me.