craftcms / webhooks

Plugin for integrating Craft with Zapier and IFTTT.
https://plugins.craftcms.com/webhooks
MIT License
84 stars 12 forks source link

[FR] Ability to do something with the response from a webhook #19

Closed MattWilcox closed 4 years ago

MattWilcox commented 5 years ago

I'm not expecting to be able to do much in the plugin itself, but I have a use case where I need to make a Module or Plugin that can respond to the result of a Webhook, and I don't think that's possible at the moment?

Use Case:

I have a Webhook set up so that when a User is saved for the first time, a hook is fired out to Active Campaign in order to create a new Contact in that service. This works fine.

However, I also need to conditionally add that Contact to a List in Active Campaign... but Contact creation and assignment to a List can not be done in one POST. I need to send a second POST out with the ContactID that was created as a result of the first webhook, along with the ListID I already know.

That contactID is returned as a response to the first webhook... but as far as I can tell, Craft does nothing at all with that returned data. And I don't see how I can either. I'd like to store it in a field on the User, and then trigger another webhook to do the List subscription.

It'd be even better if as part of Webhook's "conditionals" I could choose values for fields that are part of the User/Entry/Whatever. That's straying into a different topic though.

brandonkelly commented 4 years ago

Not sure this is something that can be easily done at the time being, but we are going to be introducing some core features to Craft that will help, down the road.

In the meantime, you may be able to pull this off with Zapier – the initial webhook could point to Zapier, which could then be the one that creates the contact, then takes the response and adds the contact to the list.