Have you ever thought of showing a customized message to your data capture reviewers? Or maybe you were thinking about calculating fields like tax rate from other values on the document? Such actions can be done with a Rossum extension, such as Webhook. However, the Webhooks have one limitation, you need to manage your own computational resources, such as a web server.
Luckily, there is a Rossum extension type that removes this limitation: a Rossum Serverless Function.
What is a Rossum Serverless Function?
With a Rossum Serverless Function, you can write your own piece of code that receives the data from a currently reviewed document. According to such data, the function can return messages or data updates back to the Rossum UI. Moreover, all this is done without requiring you to have your own web server. Rossum executes everything for you.
Below is a list of use cases where a Function might be handy:
- Show a custom message to the user in the validation screen
- Compute missing values in a document based on captured data
- Postpone a document and notify your domain expert to have a look at the document if there seem to be some inconsistencies
- Fine-tune your exporting process to your ERP when a document is confirmed.
Creating a Serverless Function
The first step to quickly extending Rossum is to create a new Serverless Function. Follow the steps below to make that happen:
- Go to Settings
- Click on “Create extension” button
- Select the “Serverless Function” type
- Define the name of the function
- Select the event’s actions when the Serverless Function will be triggered
- Create the Serverless Function
When is the Serverless Function triggered?
When creating a Serverless Function, you have to define a set of events when the function is triggered:
- Email received
- filter out non-relevant documents that should not be processed by Rossum
- Document status changed
- trigger a specific action in your workflow when document’s status changed.
- Document content is being initialized
- update the document’s data right when it got processed by the AI Engine. For example, match the captured vendor name to master data before the user opens the document.
- Document content is being updated
- show a custom message to the user in the validation screen.
- Document content is being exported
- send the verified data to the ERP/AP system when a user clicks on the “Confirm” button.
Making your function work
Your function needs code that defines its behavior. For such needs, we have created a function code editor, where you will be taken when you create a new Serverless Function. Otherwise, the editor is available from the extension detail.
Assigning a Serverless Function to a Queue
The last step before seeing the function in production is to assign the Serverless Function to a queue. You can do so in just a few steps:
- Navigate to the detail of the Extension
- Open the “Queues” tab
- Add a Queue to the Extension
Applying your Function to a document
As part of the Serverless Function template we have added the following behavior:
- Show a warning user message on fields with the “item_amount_base” schema ID that have value > 1000 0000.
- Clean up the field with the “invoice_id” schema ID by removing a “-” from its value
Such an extension to Rossum’s behavior can be done in seconds and without worrying about any infrastructure management from your side.
Limitations of Serverless Functions
Compared to Webhooks, Rossum extensions based on Serverless Functions are much easier to configure and deploy. However, Webhooks still have their place when building a larger-scale extension. If your extension requires network access (e.g. to external ERPs) or database resources, or simply contains so much code it should be versioned and split to several files, you should still choose the Webhooks interface. In the longer term, we will definitely work on making Serverless Functions even more powerful and remove these limitations.
Note: Serverless Functions are enabled for all trial accounts and certain paid plans. If you are not seeing Serverless Functions in your account, please contact us at firstname.lastname@example.org to discuss extension of your current plan.
Note: Read more about serverless functions on our developer hub.