2

I've tested the webhooks plugin. Awesome. Works brilliantly.

How how about incoming webhooks? What if my 3rd party ERP system has changes that it wants to put into my Craft site. How do I go about getting the changes into Craft?

4

This is nitech from the future. You need to read up a bit. While you built RC Planes from FliteTest with your kids, I went ahead and read up a bit for you:

Webhooks is a concept, not a technology

Webhooks are to apps what push notifications are to us. Remember when you had to check your email to know if there was a new mail? Not any more. Technically speaking, webhooks are "user-defined callbacks made with HTTP". They are usually triggered by some event happening in the source app.

Nitech, you're familiar with HTTP-requests, right? It's kinda the way the web it built. A webhook is simply a POST request typically containing JSON, like this one, coming from your ERP-system:

{
  "sku" : "JU40000365",
  "price" : "29999",
  "stock" : "9"
}

It says: Product with SKU JU40000365 has changes - and they're included in the JSON.

The power of Webhooks is that they're triggered by the source app

Okay, I made that one up. But that's my understanding anyhow. The source detects a change - through whatever mechanism (event, polling, whatever), and triggers a webhook, if there is a webhook configured for that change.

It's the way PayPal tells your shop that the purchase of order 123 was successfully paid - or declined.

How to accept incoming webhooks

So, back to your question - atm. you have to create a plugin or module for Craft CMS in order to handle incoming Webhooks.

If you have a look at Rias' Stripe Webhook Plugin for Craft, you can easily build your own plugin for your specific purpose. Look specifically at the controller.

Also have a look at the Craft 3 documentation, How to build a plugin, which gives you what you need to scaffold and load a plugin into your Craft CMS repo.

I used pluginfactory.io to create a scaffold for the plugin.

In finishing, you may ask why I can't simply just give you a zip-file with the finished plugin. My answer is that you'll be better off experimenting and learning this yourself.

  • 1
    from the future is amazing! :) – Brad Bell Nov 13 at 16:53
  • Yes, he is. If only I knew what he knows... – nitech Nov 13 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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