# Flutter Demo URL: https://developers.vsee.com/guides/flutter-demo A proof-of-concept Flutter app that shows a complete VSee Clinic integration for patient video visits. It runs the whole flow, from patient sign-in to a live video call in the VSee Browser SDK. ### Download Get the demo app source from [Google Drive](https://drive.google.com/file/d/18n2g47bj1B1Ts5C6u1uxwzYLpf8sVcFA/view?usp=sharing). ### Features - **SSO authentication:** signs the patient in through the VSee API and gets both an API access token and VSee credentials. - **Intake creation:** creates the patient's intake record and links the patient to a waiting room. - **Walk-in visit creation:** creates a visit to join right away and gets the meeting (conference room) ID. - **Video call in the Browser SDK:** embeds the VSee Browser SDK in a WebView, with full audio, video and chat. It works with VSee Messenger clients. ### Project structure ```text vc-flutter-demo/ ├── lib/ │ ├── config/ │ │ └── vsee_config.dart # API credentials & configuration │ ├── models/ │ │ └── vsee_models.dart # Data models (SSO, Intake, Visit) │ ├── services/ │ │ └── vsee_api_service.dart # API service layer │ ├── pages/ │ │ ├── home_page.dart # Main UI with flow orchestration │ │ └── video_call_page.dart # WebView-based video call page │ └── main.dart # App entry point ├── android/ ├── ios/ ├── web/ ├── pubspec.yaml └── setup.sh ``` ### Technologies used - **Flutter:** cross-platform mobile framework - **http:** HTTP client for the API calls - **webview_flutter:** WebView plugin that hosts the Browser SDK - **VSee Browser SDK:** Jitsi-based video calling SDK ### Quick start 1. Install Flutter if you don't have it: [https://flutter.dev/docs/get-started/install](https://flutter.dev/docs/get-started/install). 2. Set up the project: ```bash cd /path/to/vc-flutter-demo flutter pub get ``` 3. Run it: ```bash flutter run -d ios # iOS (macOS only) flutter run -d android # Android flutter run -d chrome # Web (experimental) ``` 4. Tap **Start Video Call** and watch the progress: SSO → intake → visit → the video call launches. ### Platform support | Platform | Status | Notes | | --- | --- | --- | | iOS | Supported | Requires iOS 12.0 or later | | Android | Supported | Requires Android 5.0 or later (API 21+) | | Web | Experimental | WebView limitations apply | | macOS | Untested | Should work with minor configuration | ### Credentials (staging only) Credentials are set in `lib/config/vsee_config.dart`. Use the API key and secret from your staging clinic; see [Sign Up for a Developer Account](https://developers.vsee.com/guides/getting-started/developer-account). ```dart // Use the API key and secret from your developer account: // https://developers.vsee.com/guides/getting-started/developer-account ``` ### Integration flow #### API flow ```text Patient App │ ├─► Step 1: POST /users/sso?fields=vsee │ └─► Returns: {sso_token, vsee_token, user_id, vsee_id} │ ├─► Step 2: POST /intakes (with sso_token) │ └─► Returns: {intake_id} │ ├─► Step 3: POST /visits/add_walkin (with sso_token, intake_id) │ └─► Returns: {visit_id, meeting_id} │ └─► Step 4: Launch WebView with Browser SDK └─► Uses: vsee_token + meeting_id → Joins video conference ``` The same flow runs step by step, with live requests, in the [Video Session](https://developers.vsee.com/use-cases/patient-video-session) use case. #### Step 1: SSO authentication **Endpoint:** `POST /users/sso?fields=vsee` Signs the patient in and returns the credentials for API calls and video calling. **Request:** ```bash # Use the API key and secret from your developer account: # https://developers.vsee.com/guides/getting-started/developer-account curl --location 'https://api.vseepreview.com/vc/stable/api_v3/users/sso?fields=vsee' \ --header 'X-AccountCode: sandbox' \ --header 'X-ApiKey: YOUR_API_KEY' \ --header 'X-ApiSecret: YOUR_API_SECRET' \ --header 'Content-Type: application/json' \ --data-raw '{ "first_name": "YOUR_FIRST_NAME", "last_name": "YOUR_LAST_NAME", "type": 200, "email": "YOUR_EMAIL", "code": "YOUR_UNIQUE_CODE" }' ``` **Key response fields:** | Field | Description | | --- | --- | | `data.id` | The patient's user ID | | `data.token.token` | SSO token for API calls | | `data.vsee.id` | VSee username for the Browser SDK | | `data.vsee.token` | VSee auth token for the Browser SDK | **Implementation:** `VSeeApiService.performSSO()` in `lib/services/vsee_api_service.dart`. See the [User API](https://developers.vsee.com/api/user-api) for the full endpoint reference. #### Step 2: Create an intake **Endpoint:** `POST /intakes` Creates an intake record that links the patient to a waiting room. **Headers:** `X-ApiToken: ` **Request body:** ```json { "waiting_room_id": 1 } ``` **Key response field:** `data.id`, the intake UUID (for example `"61165a8e-d8cc-47da-bd8e-597d64457b1f"`). **Implementation:** `VSeeApiService.createIntake()` in `lib/services/vsee_api_service.dart` #### Step 3: Create a walk-in visit **Endpoint:** `POST /visits/add_walkin` Creates a visit the patient can join immediately. **Headers:** `X-ApiToken: ` **Request body:** ```json { "intake_id": "61165a8e-d8cc-47da-bd8e-597d64457b1f" } ``` **Key response fields:** | Field | Description | | --- | --- | | `data.id` | Visit ID (for example `"67258"`) | | `data.meeting.meeting_id` | Conference room identifier for the Browser SDK | **Implementation:** `VSeeApiService.createWalkinVisit()` in `lib/services/vsee_api_service.dart`. See the [Visit API](https://developers.vsee.com/api/visit-api) for the full endpoint reference. #### Step 4: Launch the video call The call runs in the VSee Browser SDK, which is based on Jitsi Meet. It needs the meeting ID (step 3), the VSee auth token (step 1), and the patient's display name and email. 1. Load the external API script: ```html ``` 2. Initialize the SDK: ```javascript const domain = 'clinic.meet.vsee.com'; const options = { roomName: 'MEETING_ID_FROM_STEP_3', width: '100%', height: '100vh', parentNode: document.querySelector('#vsee-container'), jwt: 'VSEE_AUTH_TOKEN_FROM_STEP_1', userInfo: { displayName: 'Patient Name', email: 'patient@example.com' }, configOverwrite: { startWithAudioMuted: false, startWithVideoMuted: false, prejoinPageEnabled: false } }; const api = new JitsiMeetExternalAPI(domain, options); ``` 3. Listen to events: ```javascript api.addEventListener('videoConferenceJoined', () => { console.log('Conference joined'); }); api.addEventListener('videoConferenceLeft', () => { console.log('Conference left'); }); ``` **Implementation:** `VideoCallPage` in `lib/pages/video_call_page.dart`. See [Browser Call SDK](https://developers.vsee.com/use-cases/browser-call-sdk) for more on the SDK. ### Testing #### Scenario 1: solo test 1. Run the app and tap **Start Video Call**. 2. Check that every step completes (SSO → intake → visit). 3. The video call loads. It may show "waiting for others". #### Scenario 2: two-party test (patient and provider) - **Patient side:** run this Flutter app. - **Provider side:** use VSee Messenger (desktop or mobile), or the [Browser SDK JSFiddle](https://jsfiddle.net/vseelab/8tz3bq5e/) with provider credentials and the same meeting ID. ### Troubleshooting #### Authentication **"SSO failed: 401"** - Check the API credentials (account code, API key, API secret) in `vsee_config.dart`. - Check that the API endpoint URL is correct. **"Create intake failed: 400"** - Check that the `waiting_room_id` exists and is accessible. - Check that the SSO token is still valid. **"Create visit failed: 400"** - Check that the `intake_id` is valid. - Make sure the intake hasn't already been used for another visit. #### Flutter setup **"Flutter command not found"** - Install the Flutter SDK and add it to your PATH: [https://flutter.dev/docs/get-started/install](https://flutter.dev/docs/get-started/install). **"WebView not loading"** - Check internet connectivity. - Check the permissions in `Info.plist` (iOS) or `AndroidManifest.xml` (Android). #### Video call **The video call doesn't load** - Check network connectivity. - Check that the Browser SDK script URL is reachable (`https://clinic.meet.vsee.com/libs/external_api.min.js`). - Look for JavaScript errors in the browser console. - Make sure camera and microphone permissions are granted. **Black screen in the video call** - Make sure camera and microphone permissions are granted, not just requested. - Check that the device has a working camera. - Try another video calling app to rule out a hardware problem. **The provider doesn't see the visit** - Check that `waiting_room_id` is correct and the provider has access to that room. - Make sure the visit was created (check `visit_id` in the logs). - Confirm the patient and provider are using the same waiting room. ### Security > **Warning:** This is a proof-of-concept demo app. The credentials it uses are for the sandbox only and must never be used in production. #### For production deployments 1. **Never hard-code API credentials.** Use environment variables or a secrets manager (AWS Secrets Manager, HashiCorp Vault, etc.). 2. **Use a backend proxy.** Send all API calls through your server, never directly from the client. 3. **Refresh tokens.** SSO tokens expire, so add refresh logic for long sessions. 4. **Check permissions.** Request camera and microphone permissions before launching the video call. 5. **Use HTTPS only.** All API calls and WebView content must use HTTPS. 6. **Separate credentials per environment.** Use distinct credentials for development, staging and production. #### Files to keep out of version control These are generated and should not be committed (they are already in `.gitignore`): - `android/local.properties` - `ios/Pods/` and `macos/Pods/` - `.dart_tool/` - `build/` For a clean distribution archive, run `./archive.sh`. It removes build artifacts, local configuration and IDE files. ### Resources - [Embedding the waiting room: Patient Side Integration](https://developers.vsee.com/guides/embed-waiting-room/patient-side) - [Browser Call SDK](https://developers.vsee.com/use-cases/browser-call-sdk) - [Browser SDK JSFiddle example](https://jsfiddle.net/vseelab/8tz3bq5e/) - [Jitsi Meet IFrame API](https://jitsi.github.io/handbook/docs/dev-guide/dev-guide-iframe/) - [Flutter documentation](https://flutter.dev/docs) Versions: Flutter 3.0.0 or later · VSee API v3 (stable) · Browser SDK beta.