1

Craft Webhooks is great for sending one POST to a service... but if you need to parse the response from that hook... is there a way to do that? I can't see it as any option in the plugin, and I can't see a Service or anything for having Craft listen to that event?

I'm trying to get it so when a new User is created it's also subscribed to an Active Campaign account. I've no problem creating the Contact in Active Campaign through the Webhook plugin - it works flawlessly. But you can't then add the new Contact to an Active Campaign List because that requires a second POST that includes the new ContactID and a pre-defined List ID.

Craft has no clue about the new ContactID because it wasn't listening or parsing the response to the first successful Webhook (which contains an object with that data in it).

Likewise, it doesn't look as though it's possible to perform both actions in one API call.

2 Answers 2

2

You might want to look into creating a simple Craft plugin to do this. You can make the first call to add the contact and get the ID in response. Then use that ID to add to a campaign.

Do not be intimidated by plugin development, your problem is fairly easy to solve. If you are on Mac, I like the Paw app to test API calls.

2
  • 1
    I'm doing some plugin development, but ... the biggest issue is knowing what to look for. I'm familiar with watching for a User creation event for example, but I have no clue how to send a POST in JSON format then listen to the response - parse it - and send another POST to the endpoint as a result. The concept is simple... the mechanics mostly a mystery. Sep 11, 2019 at 15:06
  • 1
    You might be interested in my Craft Recaptcha plugin which makes a POST request from the backend using Guzzle github.com/clarknelson/craft-recaptcha-3/blob/master/src/… Sep 11, 2019 at 15:49
1

Turns out this was not a good use case for the Webhooks plugin - which is better suited to blind "shout outs" to other services than "communication" with them.

I created a plugin instead that uses Guzzle to make API calls, and can do some round-trip requests as a result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.