Extensions reference

Reference documentation for Extensions development

Alf.io extensions

The official repository for the extensions can be found here.

How to write an extension

Extensions allow you to link Alf.io with your existing tools, such as:

  • Billing/Accounting systems
  • CRMs
  • Additional Email marketing services (Mailjet, …)
  • Custom notifications (Slack, Telegram, etc.)

How it works

Extensions can be added and modified by each user. However, some limitations are applied that can be found here.

Each extension consists of a JavaScript script and is registered to one or more Application Events, and is fired as soon as the Application Event occurs.

You can find some sample code in the introduction page.

Scope Variables

Alf.io provides some objects and properties to the script in the script scope:

Variable Type About
log Log4j Logging utility
extensionLogger ExtensionLogger A logger that writes in the extension_log table.
simpleHttpClient SimpleHttpClient A simplified version created by Alf.io for calling external services
GSON GSON JSON parser/generator
returnClass java.lang.Class<?> The return class of the methods
extensionParameters Map<String, Object> Defined parameters as in the script metadata
event Event Alf.io’s implementation of a general event
eventId int The id of the event
organizationId int The id of the organization that organized the event
Utils ExtensionUtils A collection of utilities
executionKey String An identifier for the execution, which can be treated as an idempotency key.

Other event-related variables are also injected in the scope.

Methods

getScriptMetadata

This method returns the actual configuration options and capabilities of the extension. It must return a JSON object with the following properties:

  • async boolean: whether or not the script should be invoked asynchronously.
  • events string[]: list of supported events
  • configuration {(key: string): string}: the extension configuration (WIP)

executeScript

The actual event handling. Return types are event-dependent. Will always receive a single parameter (scriptEvent) which is the event that triggered the script.

Application Events by entity

Below is a list of all the supported Application Events by related entity, with some additional global variables, expected result type and a short explanation.


Event

Compatible Application Events for the “Event” entity

Reservation

Compatible Application Events for the “Reservation” entity

Ticket

Compatible Application Events for the “Ticket” entity

Subscription

Compatible Application Events for the “Subscription” entity

Email

Compatible Application Events for the “Email” entity

Other

Other Application Events

Last modified 02.02.2024: update documentation (9e96972b)