Automation made easy with the Kontent Zapier integration
So you want to integrate your Kentico Kontent project with hundreds of other applications, but you don’t want to write the code yourself? Our new native Zapier integration is here to save the day!
What is Zapier?
Zapier helps you automate tasks using triggers and actions in an easy-to-use interface. This enables your team to perform even complex tasks such as deploying websites automatically, without the need to write any code! You can find a detailed introduction to Zapier terminology and usage in their guide. To get started, create a free account at https://zapier.com.
Watch a short demo to see it in action!
Creating a Zap
An automated task in Zapier is called a Zap. The first step in a Zap is always a trigger, which defines when the Zap will run. Create a new Zap here and search for “Kontent” to view the Kontent triggers:
To use Kontent triggers and actions, you will need to register your project in Zapier. In the window that pops up, enter the keys found in Project settings > API keys:
If Secure access is enabled, you also need to provide this key to use the “Taxonomy Group Changed” trigger.
In the final Find data pane of the trigger, you can click Test & Review to see a sample of the trigger’s output, which will be available in subsequent steps. For the second step, you can choose any action—it doesn’t need to be a Kontent action. For example, we can use the Gmail > Send Email action to receive an email whenever a delete, create, or restore operation is performed on a language variant in Kontent. In the action, you can use the drop-down to populate the email with values from the trigger:
Testing the Zap
Once the trigger and actions are complete, you need to turn on the Zap. When you do, the integration will automatically create the webhook in Kontent—you don’t need to do anything! In Kontent, perform the action that should trigger your Zap. For example, if you chose the “Variant Created, Deleted, or Restored” trigger with this configuration, the Zap will execute when you create a new variant in any language:
After a few moments, your Zap should execute. You can debug your Kontent webhook and see the latest attempts to POST data to Zapier in Project settings > Webhooks. You can also click the Task history button in Zapier to view the executions and the data that was output in each step.
Kontent integration
With the native Kontent integration in Zapier, you can create triggers, actions, and searches.
Triggers
Triggers are always the first step of a Zap and define when a Zap should run. Using the Kentico Kontent integration, you only need to configure the Zap in Zapier. The creation of the webhook in Kontent is handled automatically by the integration; the webhook will be created when you turn on the Zap and deleted when you turn it off.
Each trigger in the Kontent integration has an Events to watch field where you can specify one or more actions that trigger the Zap. For most triggers, if this is left empty, the Zap will run when any of the actions are performed:
There are currently 4 triggers in the integration:
- Variant Workflow Step Changed: Choose one or more workflow steps from your project. Whenever a variant moves into that workflow step, the Zap will trigger.
- Variant Published Status Changed: Choose Publish or Unpublish. Whenever a variant’s published status changes to that state, the Zap will trigger.
- Variant Created, Deleted, or Restored: Choose Create, Delete, or Restore. When these actions are performed for a variant, the Zap will trigger.
- Taxonomy Group Changed: Choose Delete, Restore, or Create/Update. When these actions are performed on a taxonomy group, the Zap will trigger.
The output of a trigger in Zapier is exactly what Kontent’s webhook POSTs to Zapier. It will look something like this:
{
data: {
items: [
{
item: {
id: '42c21e82-0772-4d79-a6b3-c916e51b24ff'
},
language: {
id: '00000000-0000-0000-0000-000000000000'
}
}
]
},
message: {
id: 'a268da50-b3c5-4d09-9b36-6587c8dea500',
project_id: '11a3492b-cd32-0054-51d2-8234ec4244a6',
type: 'content_item_variant',
operation: 'create',
api_name: 'content_management',
created_timestamp: '2019-07-18T10:52:33.1059256Z',
webhook_url: 'https://hooks.zapier.com/hooks/standard/47992d003732'
}
}
Most triggers contain an optional Content Type For Samples field. If you select a content type, the output of the trigger should contain the ID of a content item of that type. This will make it easier to test the Zap if it relies on loading data from a specific content type.
Actions
Actions are steps that allow you to modify your data in Kontent. There are currently 4 actions:
- Create Content Item
- Change Variant Workflow Step
- Update Language Variant
- Delete Language Variant
For many of these steps, you are required to enter data in a particular format that Kontent will understand, e.g. in a Linked items element. You can find descriptions of formats that Zapier expects in fields here. As for the Kontent integration, here’s some examples of the data to provide action steps:
- Linked items: Acceptable values are content item IDs and external IDs. These can be used in any combination—for multiple linked items, some can be item IDs, and some can be external IDs. You can use the Find Content Item action if you need to locate items for this field. You can add a single value to each line, or multiple values separated by a comma. For example, the output of a previous step might be an array like “external_item_1, external_item_2.” You can refer to this output in the linked item field on a single line.
- Taxonomy: This field accepts taxonomy IDs or codenames. Similar to linked items, you can provide one value per line or comma-separated values on a single line.
- Assets: Like taxonomy fields, you can provide the asset ID or codename of an asset, and values can be added on a single line separated by commas, or multiple lines. You can use the Find Asset action to locate assets in your project.
- Dates and times: This follows the formats specified by Zapier. You can also pass a value obtained from a previous step as in the screenshot above. Some examples of acceptable date-times are:
- 11/11/2011
- 11/11/2011 4PM CST
- next friday at 7pm
- 2019-03-27T13:10:01.791Z
Searches
Because the webhook notification from Kontent only contains basic information, such as a content item ID and language ID, you may need to search your project for more information. For example, to load all data about a content item, you can use a Find Content Item action. You can search for an item based on the id, codename, external_id, or any of the content type’s elements.
There are currently 4 searches available:
- Find Content Item
- Find Workflow Step
- Find Language
- Find Asset
Another useful example would be to translate language or workflow step IDs into codenames. The webhook notification generally contains IDs, but if you need to compare a language codename (“en-US”) later on in the Zap, or if you’re writing values to a Google Sheet and want to add the user-friendly name, you could add a Find language step. You can search for the language via ID, and in the output you will find all the details of the language:
{
id: '1c37a40c-9158-031d-9d2d-adf65a568cd6',
name: 'Czech',
codename: 'cz-CZ',
external_id: 'lang_czech',
is_active: true,
is_default: false,
fallback_language: {
id: '00000000-0000-0000-0000-000000000000'
}
}
Summary
With these tools, you have everything you need to integrate your Kontent project with hundreds of other applications! To see an example Zap, you can check out the GitHub repository. If you have any ideas to improve the integration or run into issues, please submit a GitHub issue.