Engine EE 1.3+ Actions overview
Actions in Contember provide developers with a powerful way to keep track of entity changes and trigger webhooks in response. With the use of Actions, developers can automate workflows, interface with external systems, and optimize their application's overall performance.
To configure an Action, you need to employ the decorator syntax provided by Contember. Below is an example of an Action definition to demonstrate its structure:
import { c } from "@contember/schema-definition"
@c.Watch({
name: 'book_watch',
watch: `
title
tags {
name
}
`,
webhook: 'https://example.com/book/updated',
})
export class Book {
title = c.stringColumn();
tags = c.manyHasMany(Tag);
category = c.manyHasOne(Category);
}
In this example, we've defined an Action for the Book
entity in Contember. The Action is set up to monitor the creation, deletion, and changes in the title
field of the Book
entity, along with modifications in the tags
relation. It detects when tags are added or removed from a book, or when a tag's name changes. If any of these monitored fields or relations are altered, Contember triggers the assigned webhook. This enables the automation of workflows, integration with external systems, or execution of custom actions.
Subsequent sections of this documentation will provide a more detailed understanding of Actions, including how to configure them, customize payloads, utilize best practices, and more. Let's tap into the full capabilities of Actions in Contember and streamline your development process.
Contember tracks modifications made to data through the Contember Engine. It's important to be aware that if a user modifies data directly in the database bypassing Contember, such changes will not trigger the associated events. Events are only fired when modifications are performed using the Contember API or other supported mechanisms within the Contember ecosystem.