Ordering Extensions Execution on Queue

Control the execution order of extensions on a queue by defining dependencies between them, so that one extension runs only after another completes.

Once you start using webhooks and functions, you will find many ways to extend Rossum’s behavior by implementing custom extensions or using pre-built extensions from Rossum. To keep the logic and implementation of the extensions maintainable and reusable, you may want to split the logic into multiple extensions and specify their execution order.

When to order extensions

There are many reasons to use an extension. Use cases include:

For all these use cases, we recommend splitting one extension into multiple extensions when you reuse only part of its behavior on another queue or when you want to use a Rossum pre-built extension in addition to your custom extension.

How to order extensions in Rossum

After you assign an extension to a queue (webhook or function), you can check all extensions on the queue:

  1. Navigate to Extensions > My Extensions.
  2. Select the specific queue in the Selected queue filter.

The list of extensions on the queue appears. You can also filter the list by the events to which the extensions are assigned by using the Selected event filter.

Figure 1. Managing extensions on a queue

You can switch from the List view to the Dependency graph view to see how the extensions will be executed after a specific event action is triggered in Rossum.

The graphs show the extensions in the selected queue grouped by the events to which they are assigned. This grouping lets you easily see which extensions will be called after a specific event action is triggered in Rossum.

Figure 2. Groups of extensions

The extensions on the left (those in the first column) are executed immediately after the event action is triggered. All extensions assigned to the event are called in parallel, and Rossum waits for them to finish before merging their results when updating the annotation or showing values to the user on the validation screen.

To enforce calling one extension after another finishes, open the extension’s context menu and select Update dependencies.

Select the extensions that should run after the extension whose dependencies you are updating. In other words, select the extensions that should depend on the current extension. You can also remove dependencies there.

Figure 3. Update dependencies

After you set up dependencies between extensions, lines connect them in the graph. Click an extension in the dependency chain to highlight the chain. Click elsewhere to clear the selection.

The extensions farthest to the left run first, and the extensions farthest to the right run last.

A dependent extension receives updated data if the previous extension filled or changed data.

Note: When extensions are connected and run in order, the results from the predecessor extension are passed to its successor.
  • The updated_datapoints list is empty for the annotation_content.initialize action if the extension runs immediately, but it can contain data from its predecessor if it runs after another extension.
  • If extensions depend on each other, updated_datapoints contains a list of all datapoint IDs updated by any predecessor extension.
Note: Only two extension events benefit from this chaining logic: annotation_content and email.
  1. For annotation_content, Rossum performs a union operation on updated_datapoints from the My Extension 1 and My Extension 2 responses that are sent to My Extension 3.

  2. For email, Rossum performs an intersection operation on filtered_files from the My Extension 1 and My Extension 2 responses that are sent to My Extension 3.

Warning:

Connectors cannot be ordered.

Connector extensions cannot be part of the ordering. Consider using webhooks because they fully replace connectors.

Extensions assigned to multiple queues

Extensions can be assigned to multiple queues and can have different dependencies in each queue.

Only the hooks assigned to the given queue and events are considered when Rossum executes extensions for an event action on the selected queue.

You can find more information about the API setup under the run_after attribute on a Hook object.

Typical use cases for ordering extensions

The most typical use cases for ordering extensions are:

  • Use one extension to auto-fill data, such as calculating a missing tax rate, and a second extension to show user messages.
  • Use Rossum’s Data Matching extension to match vendors in master data, followed by custom logic:

    • First, the Data Matching extension fills in the vendor match based on the captured field.
    • Then, the second extension takes the updated fields and automatically populates values in other dropdowns or shows custom user messages.

Contact us at support@rossum.ai with any further questions or feature requests related to extension ordering.