Building Integrations

Agility provides extensibility layers to allow developers to build custom integrations with any system.

Integration Types

Depending on the type of integration you want for your solution, it may be split into two parts.

  1. CMS Integration - This includes developing custom fields where editors can interact with an external system, and executing event-driven business logic.
  2. Website/App Integration - For interfacing with your external system from your website/app directly.

Some integrations do not require a CMS integration or may not require any Website/App integration. It all depends on what you are trying to do.

CMS Integration

The Content Manager provides several different integration points:

  1. Custom Fields - Allows you to create your own Custom Field Type such as a dropdownlist that displays options from a third-party service. Custom Field Types are defined in JavaScript, HTML and CSS and registered within your CMS instance.
  2. Custom Scripts - Allow you to hook into CMS input form events such as onLoad, onBeforeSave, onAfterSave, onBeforePublish ,onAfterPublish via JavaScript and provide custom validation. For example, validating content or inserting content in a third-party service.
  3. Webhooks - Agility can notify external services when content or its workflow state has been changed.

Website/App Integrations

Agility is a headless CMS, so it does not enforce any rules or restrictions in how you build your website or app. The way your integration works in your solution is entirely up to you.

Example Use Cases

Custom Field for Selecting Database Records

A module has been developed that displays a listing of featured items that is sourced from an external database. The editor would like to be able to control exactly which of those items are displayed on the website.

A solution to this, was to create a Custom Field Type via JS that renders a Searchlistbox (search based on input and select) that uses AJAX and CORS to return a list of results from that external database. Now editors, are actually selecting real records from their database, saving the ID of the record on save and then in the module code, a database query is executed to retrieve those details.

Validating Content

A list of "Products" is maintained with AgilityCMS. Each product has a SKU field. The SKU field is used later to map and synchronize data with Microsoft Dynamics. It is imperative that the editor sets a valid SKU when they save a product in Agility.

A solution to this was to validate the SKU on the onBeforeSave event using the Custom Events JS API. A controller action result was setup on the website to accept a SKU parameter and query Dynamics to see if that SKU exists and is active. Then, in Agility CMS every time a Product is saved, the onBeforeSave event is called which executes a JS function. Code was implemented in the function to call the Dynamics SKU validation controller action via AJAX and CORS and await a response. If the SKU was valid, the Save was allowed to continue. If it wasn't valid, the save would be cancelled and the user was prompted to enter a valid SKU.

Next Steps

Are you working on an integration and thinking about the best way to tackle it? We'd love to hear from you and offer some guidance. Please contact us and we'd be happy to help!