Skip to main content

Overview

An event is something your app declares once and emits from a logic function each time it happens.
Beta. Events can be declared and emitted, and Twenty checks each occurrence against its definition. Nothing receives an occurrence yet: realtime delivery, storage, and triggering logic functions, agents or workflows from events are planned.

Declaring an event

An event describes its properties with the same schema format as a tool trigger’s inputSchema: an object schema, with type: 'record' and objectUniversalIdentifier for a reference to a record.
src/events/message-added.event.ts
name and property names are camelCase. An event name is unique within your app. Dotted names are reserved for events Twenty itself emits. Properties are flat: nested objects and arrays are refused. enum, minimum and maximum are checked too. label and description document a property.

Emitting

src/logic-functions/handlers/post-message-handler.ts
Name the event with event or with eventUniversalIdentifier: MESSAGE_ADDED_EVENT_UNIVERSAL_IDENTIFIER, not both. Either way, only events your app declares can be emitted. id is optional. Set it when a retried logic function could emit the same occurrence twice, so both emissions carry the same id. It follows the same rules as a background job’s jobId: letters, digits, _, . and -, up to 128 characters. Without it, Twenty generates one. The server checks the properties against the schema and refuses anything undeclared or mistyped. It returns the occurrence id and the time it was recorded.

Limits