This repo contains code for Medplum Bots. Bots power many of the integrations you see in Medplum apps. You can view your deployed bots online on the Medplum App.
Bots make heavy use of the Medplum JS Client Library.
To set up your bot deployment you will need to do the following:
- Create a Bot on Medplum and note its
id
. (All Bots in your account can be found here) - Create a new typescript file (e.g.
my-bot.ts
) and copy the contents ofhello-world.ts
into your new file. - With the
id
of the Botid
in hand, add a line topackage.json
in thescripts
section like so.
"deploy:my-bot": "medplum deploy-bot dist/my-bot.js <bot-id>"
- Create an ClientApplication on Medplum. (All ClientApplications in your account can be found here)
- Create a .env file locally by copying
.env.example
and put theClientId
andClientSecret
from theClientApplication
into the file. - (Optional) Create an AccessPolicy on Medplum that can only read/write Bots and add it to the Bot in the admin panel.
To run and deploy your Bot do the following steps:
Install:
npm i
Build:
npm run build
Test:
npm t
Deploy one bot:
npm run deploy:hello-world
Before your bot runs in production you will need to publish it. Publishing only works from the Medplum app.
- Navigate to the Bots page
- Go to the
Editor
tab - Click on the
Publish
button
After a few seconds your bot will be published and run in production.