Serverless Function

Prev Next

Have you ever thought of showing your data capture reviewers a customized message? Or perhaps you have thought of calculating fields like tax rates from other values in the document? You can perform these actions with a Rossum extension, such as a webhook. However, webhooks have a limitation – you need to manage your computing resources, such as a web server. Fortunately, there is a Rossum extension type that overcomes this limitation: a Rossum Serverless Function.

Customize Rossum Logic With a Serverless Function 1

What is a Rossum Serverless Function?

With a Rossum Serverless Function, you can write a piece of code that receives data from a document you are currently reviewing. Based on such data, the function can return messages or data updates to Rossum UI. And all this is done without the need for your own web server. Rossum executes everything for you.

Below is a list of use cases where a function can be helpful:

  • Displaying a custom message to the user in the Validation screen,

  • Using the captured data to calculate missing values in a document,

  • Postponing a document and notifying your domain expert to review it if there appear to be discrepancies,

  • Fine-tuning the exporting process to your ERP once a document has been confirmed.

How to create a Serverless Function

Creating a new Serverless Function is very straightforward; follow the steps below:

  1. Hover your cursor over the Extensions button at the top of your screen, and select “My extensions.”

  2. Click on the “Create extension” button.

  3. Name your extension (you can also add a description if needed).

  4. Select the event’s actions when the Serverless Function is triggered.

  5. Choose the Queues to which you want to add this new function.

  6. For the Extension type, select “Custom Function.”

  7. Click on the “Create the function and start coding.” button.

Customize Rossum Logic With a Serverless Function 2

What are the available triggers

When creating a Serverless Function, you must define a set of events when the function is triggered.

You can find more information in our API documentation.

How to make your function work

Your function needs code that defines its behavior. That is why we have created a function code editor. You will see it when you make a new Serverless Function.

Otherwise, you can access the editor by going to My extensions, selecting the appropriate function, and then clicking the Edit code button.

Customize Rossum Logic With a Serverless Function 3

Customize Rossum Logic With a Serverless Function 4

Note: We highly recommend using Python for creating serverless functions. It’s our main focus and will receive more updates and improvements over time. You can also use JavaScript, which runs in the Node.js 18 environment.

How to assign a Serverless Function to a queue

The last step before seeing the function in production is assigning the Serverless Function to a queue. You can do so while creating a new function.

However, later on, you may want to add this new function to different queues as well. In such a case, you have two ways to do so.

Assign a Serverless Function using Extensions

It is an efficient way to assign a function to multiple queues simultaneously.

  1. Navigate to My Extensions tab.

  2. Click on the function you want to assign.

  3. In the function window, choose the queues to which you want to add this function.

Customize Rossum Logic With a Serverless Function 5

Assign a Serverless Function within the queue

It is useful when you want to add a serverless function to only one specific queue.

  1. Open the required queue.

  2. Navigate to the Queue’s Settings and select Extensions.

  3. Choose the “Attach extension” option.

  4. Select the serverless function to enable on that queue.

Customize Rossum Logic With a Serverless Function 6

What are the limitations of Serverless Functions

By default, no internet access is allowed for a serverless function, except the Rossum API. If your functions require internet access to work properly, e.g. when exporting data over API to ERP system, please let us know at support@rossum.ai.

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 support@rossum.ai to discuss extension of your current plan.

Note:  Read more about serverless functions on our developer hub.

Examples of Custom Functions

Rossum can already offer some examples of custom functions: