Webhooks should be able to invoke tasks

What’s your idea?

Webhooks and (possibly tasks) should be able to invoke a task function.

What problem might it solve?

I have multiple tasks I need to duplicate as resolvers to do basic functionality.

For example, I have 2 tasks that adds/removes emails from my mailing list (Sendgrid). These are great as I can add a user to my “Subscribers” mailing list when they sign up via. a Trigger that already runs.

Naturally when a user cancels. their subscription I want to remove them from that mailing list so they don’t get spammed.

I use Stripe (Probably the most popular online payment system) and the way I know a customer is canceled successfully is via. their subscription.deleted webhook.

So it makes sense for me that when I receive a webhook that confirms the user has canceled I want to invoke my task that removes them from my mailing list.

After building all of this. I just get an error that ctx.invokeFunction doesn’t exist when using webhooks :frowning:

I feel like this would add a lot more re-usability of code if I could re-use task functions anywhere and not just Triggers and Resolvers.

Right now I have to duplicate my task code to a Resolver and manually make a graphQL request to the resolver to run the exact same thing as I have a task for already… :cry:

I do not want to move my task to just always be a resolver as I can re-use the task easier in my Trigger and Resolver functions.

Any ideas on how you think it could/should work?

Add the ctx.invokeFunction you already have available in Triggers and Resolvers to Webhook functions

Please!

Hey @MarkLyck! What’s the functionName and workspaceId? It should work…

@sebastian.scholl

Ahh yeah… It was probably just because I ran the function locally when testing it late last night and I forgot it’s not available when invoking locally.

It would be nice if nothing else to have dummy function so I could still test my functions locally before deploying to production.

Got it! Yeah that would be good to be able to call the tasks functions locally from other functions. I’ll look into it.

1 Like