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
- Create and Answer a Consultation - Complete workflow for creating a consultation and letting patients complete it via iframe
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
keyidentifiers - 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
- Create Resource - Use POST endpoints to create consultations/follow-ups
- Get iframe URL - Call embed endpoints to get presigned URLs
- Display iframe - Show iframe to patient for interaction
- Listen for Events - Handle completion events via Window.postMessage
- View Details (optional) - Get staff-facing details iframe
Related Documentation
- Authentication - API key and tenant headers
- Endpoints - Complete API reference
- Message Events - Browser event documentation