Contentful Trigger

Start the workflow when an entry, an asset, or a content type changes in Contentful.

v1.0.0Source

Install

Read and manage Contentful entries, assets, content types, locales, tags, environments, and webhooks with the Delivery, Preview, and Management APIs, and start a workflow on a content event.

Contentful@zerodot/contentfulInstall
  1. Open System, then Nodes.
  2. Find Contentful and click Install.
  3. Use the new nodes at once. You do not restart.

How it works

Contentful Trigger (trigger.contentful) is a trigger node in the Contentful package (@zerodot/contentful): Start the workflow when an entry, an asset, or a content type changes in Contentful.

Starts a run on a webhook event from Contentful. Choose the topics in Trigger On. A topic is Type.action. The types are Entry, Asset, ContentType, EditorInterface, Comment, Task, Release, ReleaseAction, ReleaseEntry, ReleaseAsset, ScheduledAction, BulkAction, BulkContentOperation, EnvironmentAlias, TemplateInstallation, and Workflow. The actions depend on the type, for example create, save, auto_save, publish, unpublish, archive, unarchive, and delete. Use Type.* for all actions of a type, or *.* for all events.

The output has topic, webhookName, idempotencyKey, spaceId, environmentId, and data (the entry, the asset, and so on). For a delete or an unpublish, data has only sys.

Setup:

  1. Put a Webhook Signing Secret in the management credential. It has 64 characters from the set letters, digits, +, /, =, _, and -. Make one with openssl rand -hex 32.
  2. Set the Space ID (or put it in the credential), the Environment ID, and the topics. When the workflow is active, the trigger sets the signing secret for the space (PUT /webhook_settings/signing_secret) and makes the webhook definition (POST /webhook_definitions). When the workflow stops, it removes the webhook. It does not remove the signing secret.
  3. A space has one signing secret for all of its webhooks. If you set the secret by hand, turn off Set The Signing Secret. If you made the webhook by hand, turn off Make The Webhook. Use the address of the trigger and the same signing secret.

The trigger checks the request signing of Contentful. It builds the canonical request (method, path with query, the signed headers, and the raw body, with new lines between), calculates the HMAC-SHA256 with the signing secret, and compares it with x-contentful-signature. It follows the node-apps-toolkit of Contentful: it trims header values, signs the headers in sorted order, and normalizes the path (encodeURI, with the query escaped by querystring.escape). The x-contentful-timestamp header must be in x-contentful-signed-headers, and it must be less than 30 seconds old. The trigger refuses a request that has no valid signature. Without the signing secret, the trigger refuses all requests. It also ignores an x-contentful-idempotency-key that it saw before. The path in the signature must be the path of the address that Contentful calls, so a proxy must not change it. Test listening is not available: publish the workflow to get events.

Logins it can use

Contentful Delivery API (contentful.deliveryApi): spaceId, deliveryToken (Content Delivery API access token), the optional previewToken (Content Preview API access token), and the data region (US or EU). Both tokens are secret. Find them in Settings > API keys. The Test button reads the space with the delivery token.

Contentful Management API (contentful.managementApi): accessToken (a personal access token from Settings > CMA tokens), the optional default spaceId, the data region, and the optional webhookSigningSecret for the trigger. The token and the secret are secret. The Test button reads the space, or the list of spaces if the credential has no space ID.

Hosts: US cdn.contentful.com, preview.contentful.com, api.contentful.com, upload.contentful.com. EU cdn.eu.contentful.com, preview.eu.contentful.com, api.eu.contentful.com, upload.eu.contentful.com.

Guides and related hubs