Is It Possible to Trigger a Workflow from Another Workflow in Pipedream?

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

Hello, is it any easier / possible yet with Pipedream to trigger a workflow from another workflow?

Use case:
We need to have various ways to recieve data about new orders. This might be via a public webhook URL, or it might be a WooCommerce webhook, Google Drive monitor, file upload, whatever.

Once the data from each source is processed, the procedure for loading the order into our system is standard. I don’t want to repeat the steps for every source, so ideally I just want to call the “Add order” workflow which is a single instance that contains all that logic. Basically like a function call.

Yep! Check out https://pipedream.com/docs/code/nodejs#invoke-another-workflow

Awesome!

Is it going to cost twice as many credits to do it that way? Hope not… :simple_smile:

You might want to update your help articles as I was Googling for this but that solution wasn’t pinned on some / all of the posts in the search results Google Search

Yes, every workflow invocation consumes credits!

This also applies to Control Flow segments: Overview - Pipedream

Let me see if Pi knows the answer

, how can I trigger a workflow from another workflow?

To trigger a workflow from another workflow in Pipedream, you can use emitted events. Here’s a step-by-step guide on how to set this up: 1. Create the Emitter Workflow: This is the workflow that will emit events. If you haven’t created it yet, you can create a new workflow. 2. Create the Listener Workflow: This is the workflow that will listen for events emitted by the emitter workflow. You can start with a new workflow and select the HTTP / Webhook trigger. 3. Get Workflow IDs: Obtain the workflow IDs for both the emitter and listener workflows. The workflow ID is found in the URL of the workflow in your browser, e.g., https://pipedream.com/@username/p_abc123/. 4. Create a Subscription: Use the Pipedream REST API to configure the listener to receive events from the emitter. This is done by creating a subscription. If your listener’s ID is p_abc123 and your emitter’s ID is p_def456, you can run 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. Emit an Event: In your emitter workflow, emit an event using $.send.emit(). Here’s an example: ```
export default defineComponent({ async run({ steps, $ }) { $.send.emit({ name: “Yoda”, }); } });

Ah, that’s a legacy way of doing it, maybe updating the docs will fix that