Webhooks are a popular way to set up different tools to communicate with each other. Webhooks help manage the content creation workflow better. Content provides webhooks to help manage your workflows. You can send messages when an event occurs in the Content subscription.
For example, webhooks come in handy for content reviews. You can notify approvers with Slack or email that it is time to get their input. You have the flexibility to send your requests where they will get the most visibility.
Check out the sample Custom workflow using webhooks.
Here's how Content webhooks work
Webhooks create a communication route between Content and the tool of your choice. When an event occurs in Content, webhook sends a POST request to the URL of the tool you provided. The POST request contains the event's JSON. When the webhook consumer receives the POST request, it can trigger another event.
For example, the consumer you set up could be Zapier. When it receives the event notification, Zapier will send an email to the approver.
- Go to the Developer > Webhooks page and click Add webhook.
Note: Only administrators can add webhooks.
- Provide a URL for the webhook consumer. The consumer is an external application or tool.
- Select Event types. You can create webhooks for selected authoring events like create, update, and delete.
- Select Item types that the event would occur for, such as Assets, Content types, Content.
- Select the Status for these item types.
- You can also add tags to filter the event occurrence.
Note: The event type, item type, status, and tags act as filters to identify an event. Webhook sends requests only when events that match the specified filters occur. If you do not specify any filters for the webhook, then all events are sent to the webhook consumer.
- After you create a webhook, it needs to be active to communicate with the consumer. Set the Active option to yes.
Note: If you clear the Active option, there is no communication between the tools. Content does not accept and ignores any response it receives from the consumer.
Note: You can authenticate to the Content Rest APIs through the webhooks request. A separate login request is not required. For more information, check out API reference.
The consumer should verify the POST request to prevent malicious attacks. Content uses the same mechanism as GitHub to allow for this check to happen.
- Define a secret in the Secret field when you create the webhook.
- The secret you provide acts as a key to create the hash of the request body.
- Then the webhook event is sent with an additional header containing the hash of the request body as the value.
- The webhook consumer should run the same hash check. The consumer uses its copy of the secret and verifies that the two hashes match. If the two hashes do not match, then the consumer rejects the request. For more information, check out Securing your webhooks.
Common use case example
You can use a webhook to send the text of a content item to an external translation system. Here is how you would do it:
- Create a webhook with filters to send an event when a content item is updated. Events are set to trigger when content items with the tag Ready for translation are updated.
- When a content item is ready to be translated, your composer adds the tag Ready for translation. This update triggers the webhook you created. An event sends the content item to your external translation system.
- Import the translated text into a new content item using the Content APIs.
Article is closed for comments.