Skip to main content

Running Bots Locally

To set up the Medplum Bot framework locally, Medplum offers VM Context Bots. VM Context allows bots to spin up a local thread inside your server, rather than using an isolated lambda.

Before enabling VM Context Bots, you must first enable bots on your project. To do so, follow thse steps:

  1. Log in to your Super Admin Project.
  2. Access your Project resource.
  3. Go to the Edit tab.
  4. In the Features section, add the bot feature.
note

The defaultProjectFeatures server config setting is used for default features when your project is being set up. Editing this config setting will not update your project to enable bots.

Once this is done, you can enable VM Context bots. There are two steps to set up VM context bots:

  1. Enable VM Context Bots on your server config.
  2. Set your Bot's runtime version to VM Context.

To enable VM Context Bots on your server, set vmContextBotsEnabled: true in both the AWS parameter store and your local config.json file.

All Bots have a field for runtimeVersion, which can be set to either awslambda or vmcontext. To use your Bot locally, set this field to vmcontext.

Using VM Context allows you to use resources more efficiently, however it can also have security and isolation concerns if used in an untrusted environment. For this reason, it is important to only use VM Context Bots in trusted environments.

danger

WE STRONGLY CAUTION THAT VM CONTEXT BOTS SHOULD ONLY BE USED IN TRUSTED ENVIRONMENTS.

The code for these bots runs in the server, so they can potentially have access to sensitive information when run in production environments without appropriate safety measures.