Embedding Scenarios

This section covers common integration scenarios and workflows for embedding Empego’s functionality into your applications using the v2 API.

What are Embedding Scenarios?

Embedding scenarios demonstrate end-to-end workflows that combine API calls with iframe embedding. These patterns show you how to:

  • Create consultations and patients via the API
  • Generate presigned iframe URLs for patient-facing flows
  • Handle browser message events from embedded iframes
  • Track the consultation and follow-up lifecycle

Available Scenarios

Key Concepts

Presigned iframe URLs

Embed endpoints (like /embed/consultation/answer) return presigned URLs that:

  • Are temporary and contain session tokens
  • Should be loaded directly into an iframe
  • Cannot be reused or shared
  • Point to https://app.empego.ca/embed/...

Message Events

When patients interact with embedded iframes, Empego sends browser events via the Window.postMessage API:

window.addEventListener('message', (event) => {
  if (event.origin === 'https://app.empego.ca') {
    // Handle consultation/followup events
    console.log(event.data);
  }
});

See Message Events for complete details.

Patient Upsert

The v2 API automatically handles patient creation and updates:

  • Include patient data in your consultation request
  • API matches on key identifiers
  • Creates new patient if no match found
  • Updates existing patient if match found

This simplifies integration - you don’t need separate patient management calls.

Common Integration Pattern

  1. Create Resource - Use POST endpoints to create consultations/follow-ups
  2. Get iframe URL - Call embed endpoints to get presigned URLs
  3. Display iframe - Show iframe to patient for interaction
  4. Listen for Events - Handle completion events via Window.postMessage
  5. View Details (optional) - Get staff-facing details iframe

Table of contents