Webhook action

What are webhooks?

OTYS has it's own API layer OWS (OTYS Webservices). OWS is used by OTYS Go! aswell as many third party integrations with OTYS (like the OTYS WordPress plugin). Sometimes it's needed for third parties to know when something happened with data in OTYS. For example, the OTYS WordPress plugin needs to know when a vacancy gets edited so the cache from the plugin can be updated.

Via webhooks OTYS can let third party applications know when a specific action has been triggered in OTYS Go! so the third party can act accordingly. The WordPress plugin uses webhooks to listen to a variety of data (see the list below);

  • Vacancy

  • Interaction forms

  • Match criteria

  • Candidate questionsets

  • Extra fields

  • Settings

The WordPress plugin uses [yourdomain.com]/webhooks as a entry point for OTYS. OTYS Go! will tell your plugin what happened in OTYS Go and your plugin will automaticly update cache accordinly.

Use case

Sometimes it's not only enough to for the WordPress plugin to simply listen to the webhook and do it's thing. It might be that you as a developer need to some action when a webhook gets triggered. A good example might be that you are using your own caching methods on top of the WordPress transients (which the plugin uses). This means that it's not enough to only refresh the transient cache, but also your other caching method needs to get a heads up that it needs to refresh it's cache. Here the webhook action 'otys_webhook' comes in handy.

How to use the webhook?

On the left you see an example of the use case above. We register a webhook by calling add_action('otys_webhook', 'example_callback', 10, 3). Now when a webhooks gets send to your website it will first handle the webhook as usual, at the end before giving a response back to OTYS the OTYS plugin will call the specified callback function example_callback($request, $webhook, $response).

The following parameters available in the callback function;

array $request

Webhook request data specified by OTYS

array $webhook

Details about the webhook callback. The following fields are available;

  • serviceCall (name of OWS service that triggered the webhook)

  • webhookUrl

  • callback (callable)

  • klantGlobal

array $response

Response that the plugin will give to OWS. The response will be an array with a 'message', 'code' and 'data'.

Examples of available codes:

  • webhook_action_not_found

  • webhook_vacancy_update

  • webhook_interactions

  • webhook_match_criteria_update

  • webhook_questionset_update

  • webhook_csm_update