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.
Located in examples/medplum-demo-bots/src/appointment-bots/send-appointment-reminders.ts, this bot:
- Sends reminders for upcoming appointments
- Handles both 1-hour and 12-hour reminders in a single bot
- Creates Communications for each reminder
- Includes test coverage in
send-appointment-reminders.test.ts
To deploy:
npx medplum bot deploy send-appointment-remindersTo 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/medplum-demo-bots/src/appointment-bots/send-appointment-reminders.tsinto your new file. - With the
idof the Botidin hand, add a section tomedplum.config.jsonlike so
{
"name": "send-appointment-reminders",
"id": "your-bot-id-here",
"source": "src/appointment-bots/send-appointment-reminders.ts",
"dist": "dist/send-appointment-reminders.js"
}- Create a ClientApplication on Medplum. (All ClientApplications in your account can be found here)
- Create a .env file locally by copying
.env.exampleand putting theClientIdandClientSecretfrom theClientApplicationinto the file. - (Optional) Create an AccessPolicy on Medplum that can only read/write Bots and add it to the Bot in the admin panel.
Medplum bots can also be created, edited, and deployed entirely from the medplum app. See creating a bot
To run and deploy your Bot do the following steps:
Install:
npm iBuild:
npm run buildTest:
npm tDeploy one bot:
npx medplum bot deploy sample-account-setupYou 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