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 ofexamples/hello-patient.ts
into your new file. - With the
id
of the Botid
in hand, add a section tomedplum.config.json
like so
{
"name": "sample-account-setup",
"id": "aa3a0383-a97b-4172-b65d-430f6241646f",
"source": "src/examples/sample-account-setup.ts",
"dist": "dist/sample-account-setup.js"
}
- 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:
npx medplum deploy-bot sample-account-setup
You will see the following in your command prompt if all goes well:
Update bot code.....
Success! New bot version: 7fcbc375-4192-471c-b874-b3f0d4676226
Deploying bot...
Deploy result: All OK