Automation through Bots
Automation, and the ability to build highly automated, custom workflows is one of the primary use-cases of Medplum. Medplum automations are implemented via bots, which are lambdas that implement custom functions written by developers.
Bots are often linked with integrations and are one of the most utilized features of Medplum.
To get a sense of what bots are, it's useful to consider some examples. Below are examples of automations built using the bots framework.
- Consume event data or webhooks from other platforms: see this tutorial on consuming HL7 feeds and converting to FHIR.
- Export data to other systems: see this tutorial on exporting a PDF report for human consumption.
- Drive workflow: see this tutorial on checking insurance eligibility for a specific medical service.
- Calling out to 3rd party APIs: see this tutorial on uploading a file to an external API.
Bots are written in TypeScript using the Medplum SDK. Bots are then deployed into and hosted as part of the core application, much like AWS Lambdas. When the bot is invoked the bot code is executed.
- The bots active in your account can be viewed in on app.medplum.com
- Tutorials on how to write bots can be found here
- Reference implementations of common bots can be found here
- Command Line Interface (CLI) documentation for testing and deploying bots can be found here
Bots can be triggered the following ways:
- Via subscription: subscriptions are webhooks that are triggered when FHIR resources are created or updated and can trigger bots.
- POST to $execute endpoint: each bot exposes an API endpoint and a POST to that endpoint will trigger the bot.
- Via Questionnaire: you can link a questionnaire to a bot and when the questionnaire is filled out, the bot can process the response.
A detailed guide on these scenarios can be found in our bots tutorials.
|Resource||App Link||Create New||API Documentation|
|Bot||View All||Create New||CLI|
|Subscription||View All||Create New||API|
|Questionnaire||View All||Create New||API|
|QuestionnaireResponse||View All||Created programmatically||API|
|AuditEvent||View All||Created automatically||API|
This diagram shows how bots fit into the overall system architecture.