Cancel Appointment Flow Template
The Cancel Appointment flow enables the AI Agent to programmatically cancel an existing appointment in the Epic EHR system based on a patient's request.
Overview
This flow ensures secure authentication, processes the cancellation via the Epic API, and evaluates the outcome to provide feedback to the patient.
Pre-requisites
- Webex AI Agent Studio
- EPIC Prebuilt Integration
User Roles
- Flow Developer: Configures the Webex Connect flow, Epic authentication, and JavaScript logic for error handling and result formatting.
- End User: The patient requesting to cancel their upcoming appointment.
- AI Agent: Triggers the flow upon receiving a cancellation request for a specific appointment.
- Epic EHR System: Processes the cancellation request and returns the status of the operation.
Node Breakdown
| Node Type | Purpose | Outcome |
|---|---|---|
| Configure AI Agent Event | Receives the inbound request from the AI Agent and initializes the flow. Input Variables: appointmentId, patientId, cancellationReason. | |
| Authenticate | Establishes a secure connection with the Epic EHR. | Authentication token required for the cancellation API call. |
| Epic Cancel Appointment | Executes the subscription-based API call to Epic to cancel the specified appointment. | Cancellation confirmation status. Behavior: On success, proceeds to Set Schedule Type; on error/timeout, triggers the Evaluate nodes for retry handling. |
| Set Schedule Type | Updates the schedule type after a successful cancellation. | Success/Failure status for the final response to the AI Agent. |
| Evaluate (Error Handler) | Analyzes the response to determine if the cancellation was successful or if business logic constraints were met (e.g., appointment is too close to start time, or ID is invalid). Logic: Implements retry loops for transient failures and handles invalid data scenarios. |
Input & Output Variables
Input Variables (Configure AI Agent Event)
appointmentId:The unique identifier of the appointment to be cancelled.patientId:The unique identifier for the patient.cancellationReason:The reason provided by the patient for the cancellation.
Output Variables
The flow processes the result into a status object that informs the AI Agent whether the cancellation was successfully processed or if an error occurred.
Error Handling
- API Timeout: If the cancellation request fails due to network issues, the flow routes to the Evaluate node to attempt a retry.
- Invalid Data/Business Logic: If the appointment cannot be cancelled (e.g., it is too close to the start time), the Evaluate node captures this and routes the flow to a failure path to notify the patient.
Script Analysis
Evaluate Script
- Processing: The JavaScript logic in the Evaluate nodes checks the response from Epic. It handles retry logic by incrementing a counter and checking it against the maximum allowed retries.
- Result: Ensures that transient failures are resolved automatically, while permanent failures (like invalid IDs) terminate the flow with a clear status.
Updated about 19 hours ago
