How to Use 'Validate Webhook Auth' Step in Workflows with Both HTTP and Schedule Triggers?

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

Most of my workflows have an HTTP trigger, some also have a schedule trigger. For workflows with both types of triggers, how can I use a ‘validate webhook auth’ step? Placing it as the second step works for HTTP triggers but obviously fails for triggers.

I’ve made a customer Node.js action that works with both types but I was wondering if there’s a way to do this with native steps?

Based on your description, it seems like you want to validate webhook authentication for HTTP-triggered workflows, but you’re encountering issues when the same workflow is also triggered by a schedule. Since the ‘validate webhook auth’ step is specific to HTTP triggers, it won’t be applicable for schedule-triggered events, which is why you’re seeing failures. To handle this within a single workflow that can be triggered by both HTTP requests and a schedule, you can use conditional logic in a Node.js code step to determine the type of trigger and execute the ‘validate webhook auth’ logic only for HTTP triggers. Here’s an example of how you might structure your code: export default defineComponent({ async run({ steps, $ }) { // Check if the trigger is an HTTP request if (steps.trigger.context.trigger_type === "http") { // Perform your 'validate webhook auth' logic here // For example, check for a specific header or token const authToken = steps.trigger.event.headers['Authorization']; if (authToken !== 'expected-token') { throw new Error('Invalid authentication token'); } } // The rest of your workflow logic goes here // It will run for both HTTP and schedule triggers }, }); In this code, we’re checking the trigger_type from the context of the trigger step to determine if it’s an HTTP trigger. If it is, we perform the authentication validation. If the trigger is not HTTP (e.g., a schedule trigger), the validation logic is skipped, and the rest of the workflow continues. This approach allows you to use a single workflow for both trigger types without needing to use separate ‘validate webhook auth’ steps for each. Remember to replace 'expected-token' with the actual token you expect to receive in the HTTP request. Please note that this is a custom solution, and there may not be a native step that works for both HTTP and schedule triggers due to their different contexts and requirements.

Actually good answer That’s essentially what I’ve already built

It appears that the user’s message was cut off or incomplete. Since I don’t have enough context to provide a specific answer, I would need more information to assist them effectively. Could you please provide more details or clarify your question so I can offer the most accurate and helpful response?