How to Trigger Another Workflow Once a Workflow is Finished Running?

This topic was automatically generated from Slack. You can find the original thread here.

How can I trigger another workflow when a is finished running

To trigger another workflow when one workflow is finished running, you can use the $.send.emit() function to emit an event from the first workflow (emitter) that triggers the second workflow (listener). Here’s a step-by-step guide on how to set this up: 1. Create the listener workflow if you haven’t already. This is the workflow that will be triggered by the emitter. You can start with a new workflow by selecting the HTTP / Webhook trigger at Create a new workflow. 2. Create the emitter workflow or use an existing one. This is the workflow that will emit an event once it’s finished running. 3. Obtain the workflow IDs of both the listener and emitter workflows. You can find the workflow ID in the URL of the workflow in your browser; it’s the p_abc123 part in https://pipedream.com/@username/p_abc123/. 4. Use the Pipedream REST API to create a subscription that configures the listener to receive events from the emitter. Replace p_abc123 with the listener’s ID and p_def456 with the emitter’s ID in the following command: bash curl "https://api.pipedream.com/v1/subscriptions?emitter_id=dc_def456&listener_id=p_abc123" \ -X POST \ -H "Authorization: Bearer <api_key>" \ -H "Content-Type: application/json" 5. In your emitter workflow, add the following code to emit an event using $.send.emit() at the point where you want to trigger the listener workflow: export default defineComponent({ async run({ steps, $ }) { $.send.emit({ name: "Event Name", // Include any data you want to send to the listener workflow }); } }); This setup will trigger your listener workflow whenever the emitter workflow emits an event using $.send.emit(). You can include any data you want to pass to the listener workflow in the object passed to $.send.emit(). For more details, please visit Trigger a workflow from emitted events.

Or just use an HTTP trigger, and call the url…

Thanks

Sometimes Pi overcomplicates things. :sweat_smile: