Sample Plugin Code

BioT provides a sample JavaScript Plugin code that describes the steps needed in plugin development.
The code is available free under the MIT license and can be browsed here.


To pack and deploy the sample, you require Node.js installed on your computer.
You can download it for free from here.

Download the Code

To download the code, make sure you have GIT installed and execute the following command from our command line:

git clone

To download dependencies, execute the following command line:
npm install

Basic Plugin Flow

The following boilerplate functions should be executed before the code can be executed:
(You may change them as required)

  • extractDataFromEvent - Extracts the data and metadata from the event.
  • getTraceId - Get a trace ID from the event (or fallback to a trace ID from a BioT service). The trace ID is used for better logging traceability.
  • configureLogger - Create new logs format (including a traceId).
  • authenticate - Authenticate the token sent by the notification service.
  • login - Login to BioT (using a service user) and get a token.
  • perform - An example of the different event types.
  • response - Send response (see errorResponseCreator for error responses).


A helper function that obtains the raw JSON data from the event.


The trace ID is a unique ID string that is set in the header of each API call and saved to the log. Using this unique ID allows us to trace the whole flow of the call, in case of a problem, beginning with the plugin and going through all the API calls that the plugin made, and any internal API calls made by the platform until the plugin response.


This function prepares the log structure for a well-structured log that will enable easy searching when needed.


This function validates the JWT token received from BioT to ensure the call originated from the platform and not from any unauthorized origin.


Before making an API call to BioT the plugin needs to obtain a new JWT token using the service user credentials.


According to the event type, the demo plugin maps the event to the appropriate event handler.
Under the src folder, a specific handler was written to each event type:

Notification handler from "./notification/index.js"
Interceptor Post from "./interceptorPost/index.js"
Interceptor Pre from "./interceptorPre/index.js"
Interceptor Post Entity from "./interceptorPostEntity/index.js"

Check the appropriate code for each plugin type for an example on how to handle the event and how to make API calls.


The response depends on the plugin and should be updated according to your business logic.

Deploy the Plugin

You may want to zip the source code before deploying it by executing the following command:
npm run zip

To deploy the code, refer to Custom Plugin Deployment.

Set Environment Variables

The following environment variables need to be set before the plugin can be executed:

Variable NameDescription
BIOT_APP_NAMEName of this Plugin, used for logging purposes.
BIOT_BASE_URLThe base API URL of your BioT account.
For example,
BIOT_PUBLIC_KEYThe public key of BioT, used to ensure the call originated from BioT. The key can be obtained by making a request to:
GET: https://<your_biot_domain>/ums/v1/security/public-key
BIOT_SERVICE_USER_IDThe service user ID.
See Creating a Service User for Your Plugin.
BIOT_SERVICE_USER_SECRET_KEYThe service user secret key.
See Creating a Service User for Your Plugin.
BIOT_SHOULD_VALIDATE_JWTSpecifies to the lambda if it should check for a valid JWT token in the request header. This is done to make sure requests originate from BioT. If you have your own validation method, or you want to make the lambda truly public, set it to "false"

To set these environment variables:

  1. Login to the AWS console and go to the Lambda service.
  2. From the list, select your Lambda function and click on "Configuration", then "Environment Variables" and finally "Edit".

  1. In the Edit Environment Variables box that appears, enter the environment variables as keys and values.
  2. To add more than one environment variable, click Add environment variable.
  3. When finished, click Save.

Test Your Plugin

Now register your Plugin as a Notification or Interceptor and verify that it works.