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:
- Log in to your Super Admin Project.
- Access your Project resource.
- Go to the
Edit
tab. - In the
Features
section, add thebot
feature.
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:
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.
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.