Customizable webhooks: integration without the effort

  • Product updates
  • Engineering
  • Guides
Use customizable webhooks to send data directly from Dynamic Content to 3rd party APIs, reducing integration effort and opening up a world of possibilities.
6 mins reading time
Olly Secluna | March 16, 2020

We are very excited about our new Customizable webhooks features and we’re confident that our webhooks are among the most powerful and easy to use of any app.

Customizable webhooks enable direct communication between Amplience Dynamic Content and external APIs such as Algolia search, Slack and Jira. They significantly reduce the development effort and in many cases remove the need for a developer to build an additional integration service.

You lost me at webhooks

Webhooks are a way for one software service to automatically send messages or data to another. When you receive an email about a PayPal purchase or an SMS confirming that your DHL package has been shipped, the chances are that a webhook is responsible.

There is an excellent article on Zapier's blog for those of you who want to know more.

How do customizable webhooks work?

Many apps and services have webhook settings hidden away under custom settings or APIs. A standard webhook will have a user configurable URL to which it will send data, in a format defined by the system sending the data.

The webhook will be sent when a defined event or action occurs in the sending app.

To receive a webhook, a system will have to accept the request and understand the data in the format in which it has been sent, before processing it and triggering any further actions.

Dynamic Content's customizable webhooks simplify this process by providing the following features:

  1. Custom payloads: allows developers to transform the webhook’s request body into any format using handlebars templating. Importantly, it is possible to send data from the full content graph, including linked content.

  2. Custom headers: sending additional headers with the request enables basic authorization, opening up 1000s of apis. Custom headers could also be used to override the content type, for example to send xml

  3. Filters: filtering allows developers fine-grained control over when a webhook will be triggered. For example only index a specific content type in algolia search or only send content items with a specific workflow status to a translation service.

  4. Configurable request methods: You can create a webhook using PUT, PATCH or DELETE as well as POST. This allows you to perform more operations in external apps, such as updating an existing record in a search index or deleting a resource when an event occurs in Dynamic Content.

  5. Templated webhook URLs: When sending a PUT, PATCH or DELETE request to an API, you will generally have to identify the object which you want to update or delete. To assist with this, you can now add code to your request URL to generate a predictable value such as an ID or label. Our library of handlebars helpers even allows you to URL encode the value.

  6. Awesome testing and debugging features: Our new webhooks testing tool speeds up development by allowing you to process all of your webhook settings and see the generated output without triggering a new request. Previous requests can also be resent to assist in development of external integration services.

What are common uses for customizable webhooks?

CategoryExamples
Content syndicationSearch index, External content library
Content production workflowsTranslation, Content approval, Jira
NotificationsSlack, SMS (via Twilio), Email
Triggering builds/ deploymentsNetlify, Travis, Heroku, GitHub
Legacy systemsSend content as XML, Send content as CSV

When will customizable webhooks do the job?

As I mentioned in the introduction, for many use cases customizable webhooks will remove the need for an API orchestration layer (or integration service) for server-to-server integrations. Data transformation via custom payloads ensures interoperability between systems, custom headers enable authorization / mediation, and filters provide fine grain control over your workflow. If the following conditions are met, a webhook alone will suffice:

  • Create, update or delete a record via a single API request, triggered by a single event in Dynamic Content

  • Simple authorization via header(s)

  • Transforming data into a specific JSON, XML or other format.

When do I need to build an additional service?

If you have any of the following requirements you may need to build an integration service, though you can still use our customizable webhooks features to keep your service simple.

  • Logic based on the API response

  • Multiple, sequential requests from a single action

  • Complex auth patterns

  • Requirement for very large request bodies

Detailed examples

I want to message a Slack channel when an edition is scheduled or published

  • Trigger on Edition - Scheduled and Edition - Published

  • Create a custom payload in the format required by Slack including the edition name, start date and end date:

  • For detailed instructions, see our Slack integration guide

I want to receive an SMS when a content item is assigned to me

  • Set up a Twilio account or use your existing details

  • Add your webhook URL as follows: https://api.twilio.com/2010-04-01/Accounts/<twilio_account_sid>/Messages.json

    Replace <twilioaccountsid> with your Twilio account SID

  • Trigger on Content item - Assignee change

  • Filter on

    • JSONPath: $.payload.assignees[?(@ == '<dc-user-id>')]

    • Value: <dc-user-id>

    Replace <dc-user-id> with the Dynamic Content user id for the user you want to message. To find this you can assign a content item to the user, then look at the webhook activity log or use our webhook testing tool to find the value in the assignees array of the standard payload.

  • Add a basic auth header with Username: <twilioaccountsid> and Password: <twilioauthtoken>

  • Add a content-type header to override our standard content-type header with the value application/x-www-form-urlencoded. This format is required by the Twilio API.

  • Create a custom payload including the label of the content item assigned to you, the phone number from your Twilio dashboard and the phone number where you will receive test SMS messages

From=+<your_twilio_number>&To=+<your_verified_number>&Body=Content%20Item%20Assigned to you%20{{encodeURI payload.label}}

I want to send a content item to my translations agency when the workflow status is 'Ready for translation'

  • Trigger on Content item - Status change

  • Filter on

    • JSONPath: $.payload.workflowStatusLabel

    • Value: Ready for translation

  • Create a custom payload in the format required by your translations agency

I want to index published content items in an Algolia search index

  • Trigger on Snapshot - Published

  • Filter on

    • JSONPath: $.payload.rootContentItem.contentTypeUri

    • Value: <my-schema-id>

  • For detailed instructions, see part 1 of our Algolia Search integration guide

Where to go from here

We've covered just some of the ways that you can use customizable webhooks to power your integrations with Dynamic Content. The best way to find out what our webhooks can do is to build your own, so take a look at the examples on our documentation site and start integrating.