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. Traditional extension types implementing this are Connectors or Webhooks. However, the Connectors and 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.
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. In most cases, you would select the document content event and its actions:
- Initialize – update the document data after the Rossum AI Engine performs the initial data capture
- User update – update the data after user changes a value
- Export – take the data confirmed by the user and send it via API to the target AP/ERP system
Note: The code in a Rossum Serverless Function currently cannot send any HTTP requests that would access resources from the Internet. This would include using a third-party API for storing document data, etc. Contact us at firstname.lastname@example.org to enable Internet access.
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 Settings
- Click on the target queue where you want to use the function
- Open the Extensions tab
- Click on “Add extension”
- Select the extension by clicking on the “+” icon
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 email@example.com to discuss extension of your current plan.