Ordering Extensions Execution on Queue
Once you start using webhooks and functions, you will find out there are many ways to extend Rossum’s behavior. Either by implementing custom extensions or by using pre-built extensions from Rossum. In order to keep the logic and implementation of the extensions easily maintainable and reusable you may want to split the logic into multiple extensions and specify the order of extensions’ execution.
When to order extensions
There are multiple reasons why you have an extension in place. The use cases are various:
- Showing custom user messages
- Auto-filling data
- Translation of line items descriptions
- Recalculating values based on unit of measurement
- Filtering received document mime types
- … and many others ...
For all those UCs, we would recommend splitting one extension into multiple extensions when you would like to reuse only part of the behavior on another queue or when you would like to use Rossum’s 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 the extensions on the given queue by:
- Navigating to settings
- Clicking on the specific queue in the “Queues” tab
- Navigating to the Extensions tab
Afterwards, you will see the list of the extensions on the given queue, separated by the events to which they are assigned. Grouping by the events lets you easily see what extensions will be called after triggering a specific event action in Rossum.
Moreover, you can see a dropdown with “Run immediately” value next to the extension name. This means all the extensions assigned to the event will be called in parallel and their results will be merged together when performing updates on the annotation or when showing the values to the user in the validation screen. Rossum will wait for all extensions executed for a given event and will merge the results.
You can enforce calling one extension after another one finishes by clicking on the dropdown and selecting the extension on which the current one should depend.
The dependent extension will receive updated data if some data was filled or changed in the previous extension.
Distinguishing updated datapoints from previous extension
The attribute updated_datapoints is currently not updated before it comes to the dependent extension. This behavior will be changed in the future, so that you would be able to see the IDs of the updated values from the previous extension in the payload of the currently called extension. For now, the annotation data will be updated if updating operations are returned in the previous extension but the updated_datapoints list will be empty.
Connectors cannot be ordered
Connector extensions cannot be part of the ordering. Consider using webhooks since they fully replace the connectors.
Extensions assigned to multiple queues
Extensions can be assigned to multiple queues where the extensions can have different dependencies.
How does this affect the execution of extensions on a given event action on a selected queue?
As expected, only the hooks assigned to the given queue and events are considered for the execution.
Moreover, using the API, you can set a single hook to be dependent on multiple extensions triggered at one event on the given queue. Using the UI, it is currently possible to set an extension tobe dependent only on one extension in a single event action.
You can find out more about the API setup under the “run_after” attribute on a Hook object.
Please contact us at [email protected] about any further questions or feature requests related to extensions ordering.
Typical use cases for ordering extensions
The most typical use cases for ordering extensions are:
- Use one extension for auto-filling data (calculating missing tax rate, etc), second extension shows user messages
- Use Rossum’s Data Matching extension for matching vendors in master data, followed by custom logic
- Firstly, Data matching extension fills in the vendor match based on the captured field
- Second extension takes the updated fields and should automatically populate values in other dropdowns or show custom user messages
Updated almost 2 years ago