Can Workflows Be Replayed Programmatically?

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

Hello :wave: - is there a way to replay workflows programmatically?

That’s an interesting question. Let’s ask Pi.

, I trust you are doing good :slightly_smiling_face: Do you know about the Pipedream API? is it possible to use the Pipedream API to replay a workflow programmatically? That’d be awesome if you can advise. Thanks

Yes, you can use the Pipedream API to replay a workflow programmatically. You can make a POST request to the following endpoint to replay an event: https://api.pipedream.com/v1/sources/<source-id>/event-replays You’ll need to replace <source-id> with the ID of your workflow’s trigger. Additionally, you’ll need to pass the event_id of the event you want to replay in the request body: on { "event_id": "<event-id>" } Make sure to set the Authorization header with your Pipedream API key: headers: { Authorization: `Bearer <api_key>` } Please note that you’ll need to replace <event-id> and <api_key> with the respective values. Here’s an example using axios: import { axios } from "@pipedream/platform"; export default defineComponent({ async run({ $ }) { const sourceId = "<source-id>"; const eventId = "<event-id>"; const apiKey = "<api_key>"; const response = await axios($, { method: "POST", url: `https://api.pipedream.com/v1/sources/${sourceId}/event-replays`, headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", }, data: { event_id: eventId, }, }); return response; }, }); Remember to replace <source-id>, <event-id>, and <api_key> with your own values.

thanks ! is there a way to pull in all events for a workflow? also where do i find source id for a specific workflow?

To pull all events for a workflow, you can use Pipedream’s REST API. Make a GET request to the following endpoint: https://api.pipedream.com/v1/sources/<source-id>/events Replace <source-id> with the ID of your workflow’s trigger. You’ll also need to set the Authorization header with your Pipedream API key: headers: { Authorization: `Bearer <api_key>` } To find the source ID for a specific workflow, you can look at the workflow’s trigger step in the Pipedream UI. The source ID will be displayed there. Here’s an example using axios to fetch events for a workflow: import { axios } from "@pipedream/platform"; export default defineComponent({ async run({ $ }) { const sourceId = "<source-id>"; const apiKey = "<api_key>"; const response = await axios($, { method: "GET", url: `https://api.pipedream.com/v1/sources/${sourceId}/events`, headers: { Authorization: `Bearer ${apiKey}`, }, }); return response; }, }); Remember to replace <source-id> and <api_key> with your own values.

Sorry Nicolas, Pi might be hallucinating a bit here.

I don’t believe that’s there’s an API for retrying events programmatically at this time.

There is however a control to automatically retry events from within the Workflow Settings.

can you please share the documentation on how to enable automatic retries on a workflow?

I apologize for the confusion earlier. You’re correct that there isn’t an API for retrying events programmatically. However, you can enable automatic retries on a workflow by following these steps: 1. Open the workflow you want to enable retries for. 2. Click on the “Settings” tab at the top of the workflow. 3. Scroll down to the “Error Handling” section. 4. Toggle the “Automatically retry failed steps” option to enable it. 5. Configure the retry settings (number of retries and backoff strategy) as needed. For more details on error handling and retries, please visit the Pipedream documentation: https://docs.pipedream.com/workflows/error-handling/

hmm ok - i don’t need automatic retrial of events - i need to try and rerun those events after the change was made in the workflow … the use case here is that we had email triggers going to customers but they were not configured correctly so now we’d like to send those events through the workflow again with the updated steps

Got it, sorry that’s not currently possible programmatically. You can retry events through the workflow inspector in the Pipedream Dashboard though.