Trigger a workflow from another workflow

Hi guys!

as the title, is possible ?

a brief explanation :
i’ve already created an ApiEndpoint to trigger a workflow when a webhook is triggered in another platform (Stripe).
Since i don’t want to create N endpoints for each event in my workflow i want to call another workflow based on the event that was sent to Corteza.

thanks as usual

I use a simple function for workflow

1 Like

You could also utilize messaging queues. Unfortunately, we don’t have any written docs for them at the moment, so if you decide to use them, feel free to contribute to the docs.

In the admin web application, under System > messaging queues, you can define a queue for the eventbus consumer.

In workflow A (the one on the endpoint), you can use the “queue message send” function to send a message through that queue.

In workflow B, you can use the system queue on the message trigger and execute the workflow when it receives a message through that queue.

hey @cromalde I have a workaround for such a thing

first of all, you need to use automation scripts, not workflow

the idea is that you create a module for your events. and create checkbox fields titled with the name of the event (e.g. a checkbox titled order_status_has_changed)
and in your automation-scripts trigger, you can specify the trigger when that field is true

so when the original automation changes the order status it also makes the event field true and when your automation-script finishes change the box to false

again it’s a workaround that has its limitations

If you’re already using workflows and integration gateways for this case, I would suggest you take the solution outlined in my response.
You can have one endpoint with one workflow that determines the event type and sends it down the correct messaging queue.

In another case, or if the underlying problem is more complex than hinted in the original post, a variation of what @munawir said could be considered, but I don’t think it’s the correct one for this exact scenario.

Thanks for the solutions !

however i’ve ended up using the Corredor server to trigger scripts based on some condition, i believe is more “clean” for the other team members.

cheers

@cromalde could you share with us a code sample of the trigger?

This is a screenshot of the Workflow.

it’s an integration Gateway endpoint triggered by external event, and depending on the body of that http request i’ve to call different scripts for CRUD operation.
The try/catch is just to notify the Team if something went wrong inside the script

at the moment i’m the only one working on corteza but i believe that in future as the team grows this is pretty straightforward to others to understand

ps. is not a major issue but in my scripts i can use the log function only using ctx.log, if i destructure {Compose, log} the execution will fail for the undefinition of log, am i doing something wrong ? ( notice that the Compose will work even using destructuring)

2 Likes

Thanks for sharing your example!
We’ll take a look at the destructuring issue; we had a similar thing a while ago so we might have missed a case or two.

1 Like