Skip to main content

Apps, Bots & Subscriptions — Extending ByteEngine Functionality

Overview

In modern healthcare systems, interoperability isn't just about connecting data — it's about reacting to it. ByteEngine allows you to extend your system with apps, bots, and subscriptions, enabling you to:

  • Automate workflows based on FHIR data changes (e.g., when a new Patient is created)
  • Integrate third-party systems or APIs
  • Build smart assistants and background tasks that respond to clinical events
  • Streamline clinician workflows with event-driven intelligence

Key Concepts

1. Apps

Apps are lightweight extensions that live within your ByteEngine environment. They can connect to your data stores, AI workers, and workflows to provide specialized logic or user interfaces.

  • Written in TypeScript, Python, or Go
  • Can be hosted natively or externally (via webhook or API)
  • Have scoped access to FHIR stores, pipelines, and sessions

Common examples:

  • A custom dashboard app for patient intake
  • A prescription validation app integrated with national formularies
  • An AI triage chatbot embedded in a telehealth portal

2. Bots

Bots are automated agents that listen for events and perform actions.

Bots can:

  • React to FHIR resource changes (like Subscriptions)
  • Interact with AI Workers or Pipelines
  • Send notifications to users or external systems
  • Perform background data processing or enrichment

Example Bot Flow:

  1. A new Observation is added (e.g., blood pressure reading)
  2. Bot detects abnormal value
  3. Bot triggers a FHIR Communication or sends a Slack alert
  4. Optional: Bot runs an AI Worker for deeper analysis
name: "high-bp-alert-bot"
trigger:
type: "fhir.subscription"
resource: "Observation"
condition: "component.code.text = 'Blood Pressure' and valueQuantity.value > 160"
actions:
- type: "notify"
channel: "slack"
message: "High BP Alert for {{patient.name}}: {{valueQuantity.value}} mmHg"
- type: "fhir.create"
resourceType: "Communication"
data:
status: "in-progress"
subject: "{{patient.id}}"
payload:
contentString: "Follow-up required for elevated blood pressure"

3. Subscriptions

Subscriptions are the foundation of event-driven architecture in ByteEngine. They allow you to listen to FHIR resource changes and automatically trigger workflows, bots, or external APIs.

Supported trigger types:

  • create — new resource created
  • update — resource modified
  • delete — resource deleted
  • query — data condition met (computed periodically)

Example: FHIR Subscription JSON

{
"resourceType": "Subscription",
"status": "active",
"criteria": "Patient?gender=male",
"channel": {
"type": "rest-hook",
"endpoint": "https://my-bot.byteengine.app/fhir-event",
"payload": "application/fhir+json"
}
}

Tip: You can manage Subscriptions visually in the ByteEngine Console or via the API. Bots and Pipelines can also auto-generate subscriptions during deployment.

How They Work Together

ByteEngine unifies Apps, Bots, and Subscriptions under one event-driven fabric:

ComponentPurposeTypical Use Case
AppAdds custom UIs or APIsPatient dashboard, clinical forms
BotExecutes logic on eventsAI triage, alerts, data enrichment
SubscriptionTriggers eventsNotify bots or pipelines on data change

Together, these enable a reactive healthcare system — where every data change can lead to an intelligent, automated response.

Real-World Use Cases

1. Automated Lab Notification

When a new lab result (Observation) is added:

  1. Subscription triggers a Lab Result Bot
  2. Bot checks result value range
  3. If abnormal → Bot sends notification to doctor + logs a FHIR Communication

2. AI-Powered Clinical Assistant

A bot listens for new Encounter resources:

  1. Triggers an AI Worker for summarization
  2. Posts the generated SOAP note into the EMR as a DocumentReference

3. Integration with External Systems

A Subscription detects updated Appointment records:

  1. Triggers a webhook to sync data with a hospital scheduling system
  2. Updates patient portal automatically

Building Your First Bot

Let's walk through building and deploying a bot in ByteEngine:

  1. Create a new bot project:
byteengine bots init high-bp-alert
cd high-bp-alert
  1. Edit bot.yaml: (as shown above)

  2. Deploy the bot:

byteengine bots deploy
  1. Monitor activity:
byteengine bots logs high-bp-alert

You can also manage all bots in the ByteEngine Console → Automations → Bots.

UI Example

ByteEngine Console: "Create Bot" Dialog

  1. Choose event type (FHIR Subscription / Workflow Trigger)
  2. Configure condition (FHIR query or AI predicate)
  3. Select actions (Notify, Create FHIR, Trigger Workflow, etc.)
  4. Optionally attach AI Worker

(Insert screenshot placeholder: /img/docs/bots-create-ui.png)

Developer API

The ByteEngine REST API lets you programmatically manage:

  • Apps/api/v1/apps
  • Bots/api/v1/bots
  • Subscriptions/api/v1/subscriptions

Example: Create a Bot via REST

curl -X POST https://api.engine.boolbyte.com/api/bots \
-H "Authorization: Bearer $BYTEENGINE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "bp-alert",
"trigger": {
"type": "fhir.subscription",
"resource": "Observation"
},
"actions": [
{
"type": "notify",
"channel": "email",
"message": "High BP alert triggered"
}
]
}'

Using JavaScript SDK

import { EngineClient } from '@boolbyte/engine';

const client = new EngineClient({ apiKey: 'YOUR_API_KEY' });

// Create a bot
const bot = await client.bot.createBot({
name: 'bp-alert',
trigger: {
type: 'fhir.subscription',
resource: 'Observation',
condition: "component.code.text = 'Blood Pressure' and valueQuantity.value > 160"
},
actions: [
{
type: 'notify',
channel: 'slack',
message: 'High BP Alert for {{patient.name}}: {{valueQuantity.value}} mmHg'
},
{
type: 'fhir.create',
resourceType: 'Communication',
data: {
status: 'in-progress',
subject: '{{patient.id}}',
payload: {
contentString: 'Follow-up required for elevated blood pressure'
}
}
}
]
});

console.log('Bot created:', bot.data.id);

Advanced Use Cases

Multi-Step Clinical Workflow Bot

name: "clinical-workflow-bot"
trigger:
type: "fhir.subscription"
resource: "Encounter"
condition: "class.code = 'AMB' and status = 'finished'"
actions:
- type: "ai.worker"
worker: "clinical-summarizer"
input: "{{trigger.resource}}"
output: "summary"

- type: "fhir.create"
resourceType: "DocumentReference"
data:
status: "current"
type: "SOAP Note"
subject: "{{trigger.resource.subject}}"
content:
attachment:
data: "{{steps.ai.worker.output.summary}}"

- type: "notify"
channel: "email"
message: "Clinical summary generated for {{trigger.resource.subject}}"

Data Integration Bot

name: "lab-integration-bot"
trigger:
type: "external.webhook"
endpoint: "https://lab-system.com/webhook"
actions:
- type: "transform"
mapping: "lab-result-to-fhir"
input: "{{trigger.payload}}"
output: "fhirObservation"

- type: "fhir.create"
resourceType: "Observation"
data: "{{steps.transform.output.fhirObservation}}"

- type: "workflow.trigger"
workflow: "lab-result-analysis"
input: "{{steps.fhir.create.output}}"

Security & Compliance

  • Event-driven security - All bot actions are logged and auditable
  • Scoped permissions - Bots only access data they're authorized for
  • Encrypted communication - All webhook and API calls use TLS 1.3
  • Data residency - Bots respect regional data storage requirements
  • HIPAA compliance - Built-in safeguards for protected health information

Monitoring & Analytics

  • Real-time execution logs - Track bot performance and errors
  • Event analytics - Monitor subscription triggers and response times
  • Cost tracking - Understand resource usage and optimization opportunities
  • Alert management - Set up notifications for bot failures or anomalies

Next Steps