Custom action: access query params or body from a previous step triggered by a webhook

Hi,
I’m creating a workflow with a custom action triggered by a webhook. I would like to know if it is possible to access the query params and body of the webhook triggering the workflow to be able to use them as variables in my custom action.
Is that something possible?
Let me know if my question is not clear enough.
Thank you.

Hi @sbkl

First off, welcome to the Pipedream community. Happy to have you!

Absolutely you can.

Check out this 5 minute video that shows how to use the body of a payload to an Pipedream HTTP webhook triggered workflow:

That video shows how to access the body of the incoming HTTP request with the steps.trigger.event.body varible.

This video shows you how to use these variables in a custom Node.js step:

We don’t have a video series yet on custom Action development, but you can read the quickstart on our docs to learn how to build them:

Hi @pierce,
Thank you for pointing me out to these videos. They are great! Will definitely look into more of them.
I would like to understand how I could access the steps variable within the run function of a custom action to do the exact same thing than I can see in the custom node step in the first video.
I went through the Action development documentation and start to get a good understanding of it, and accessing the steps variable just like in the workflow in the browser is the missing piece. Is that something possible?
Thank you.

Hi @sbkl,

Great question!

You can think of actions as unconfigured steps, or Class if you’re familiar with Object Oriented Programming.

A step is an instance of a action.

Actions can be reused across multiple workflows, so the steps variable isn’t present at that level.

You can define props which allow individual step implementations of your action to access the step exports at runtime.

For example, if you wanted to accept a string value in an action:

export default defineComponent({
  props: {
    value_from_webhook_body: {
      type: "string"
    }
  },
  async run({steps, $}) {
     // now the individual implemenation has access to the data defined in the workflow
     this.value_from_webhook_body;
  }
}

After publishing this action, you can use it in your workflows and pass the steps variable to it:

Oh yes. I got it now! Was aware of props but you made realised I can use them as dynamic user input and access the previous step. Exactly what I wanted to achieve. Been checking pipedream for a few days and it takes a bit of time to get it but it is a great experience. Thank you for your help!

1 Like