# Enter Waiting Room Flow URL: https://developers.vsee.com/guides/clinickit/android-enter-waiting-room To enter a waiting room, the user first logs in to VSee with a patient account, an SSO token, or as a guest. ![Enter waiting room flow: login, create intake, select video call options, in video call](https://developers.vsee.com/images/guides/clinickit/android-enter-waiting-room/flow.png) For the same flow on iOS, see [Enter Waiting Room Flow](https://developers.vsee.com/guides/clinickit/enter-waiting-room) under Mobile flows. ### 1. Authentication #### 1.1. Patient authentication ![Patient login](https://developers.vsee.com/images/guides/clinickit/android-enter-waiting-room/login-patient.png) ```kotlin val res = VseeApi.auth.loginAsPatient(username = username, password = password) when (res) { is Resource.Success -> {} is Resource.Error -> {} } ``` The sample app uses the `loginAsPatient` API to authenticate the patient. #### 1.2. Guest authentication ![Guest login](https://developers.vsee.com/images/guides/clinickit/android-enter-waiting-room/guest-login.png) ```kotlin fun loginAsGuest(firstName: String, lastName: String, dob: String) { viewModelScope.launch { val res = VseeApi.auth.loginAsGuest(firstName = firstName, lastName = lastName, dob = dob) when (res) { is Resource.Success -> {} is Resource.Error -> Timber.e("Login SSO error: ${res.message}") } } } ``` To log in as a guest, the user enters their `firstName`, `lastName`, and date of birth. #### 1.3. SSO authentication ![SSO login](https://developers.vsee.com/images/guides/clinickit/android-enter-waiting-room/sso-login.png) ```kotlin fun loginWithToken(token: String) { viewModelScope.launch { val res = VseeApi.userApi.getUser() when (res) { is Resource.Success -> {} is Resource.Error -> { Timber.e("Get user using SSO token error: ${res.message}") _errorMessage.postValue(res.message ?: "Login using SSO token error") } } } } ``` The sample app uses `VseeApi.userApi.getUser()` to verify the SSO token. The authentication result is either `Success` or `Error`. - **Success:** the app starts VSeeKit authentication. ```kotlin fun loginVseeKit() { Timber.d("Login vsee-kit...") if (vseeConnection.getLoginState() != LoginState.LOGGED_IN) { EventBus.getDefault().register(this) vseeConnection.login() } else { _vseeKitLoginState.postValue(LoginState.LOGGED_IN) } } ``` VSeeKit is a library for embedding VSee multi-way video calling and chat in mobile apps. The app uses `EventBus` to listen for the VSeeKit login result: ```kotlin @Subscribe fun onLoginStateChanged(event: VSeeEvents.LoginStateChange) { Timber.d("LoginStateChange => oldState = ${event.oldState}, newState = ${event.newState}") val newState = event.newState if (newState.isProcessing()) { isLoading.postValue(true) } else if (newState.isLoggedIn() || newState.isFailureState) { isLoading.postValue(false) } _vseeKitLoginState.postValue(newState) } ``` Once VSeeKit login succeeds, the user is taken to the Dashboard screen: ![Dashboard](https://developers.vsee.com/images/guides/clinickit/android-enter-waiting-room/dashboard.png) - **Error:** the app shows a Snackbar message with details of the error. ![Patient login failed](https://developers.vsee.com/images/guides/clinickit/android-enter-waiting-room/login-patient-failed.png) ### 2. Create intake The patient taps **Enter waiting room now** to open the intake form. Here they can update medical information for the visit, such as the reason and the consultation. For details, see the [Intake & Visit API](https://developers.vsee.com/guides/clinickit/android-intake-visit-api). ![Create intake](https://developers.vsee.com/images/guides/clinickit/android-enter-waiting-room/intake.png) ```kotlin fun createIntake(reasonForVisit: String) { val request = CreateIntakeRequest( reasonForVisit = reasonForVisit, type = 1, roomCode = VseeApi.session.getRoomCode().orEmpty(), consent = true ) viewModelScope.launch { val res = VseeApi.visitApi.createIntake(request) when (res) { is Resource.Success -> {} is Resource.Error -> Timber.e("Unable to create visit intake: ${res.message}") } } } ``` ### 3. Join the video call The patient has two ways to join the video call: - **Embedded browser call:** opens the video call in an Android WebView. - **Via VSeeKit:** opens the video call in the VSeeKit native video view. ![Video call options](https://developers.vsee.com/images/guides/clinickit/android-enter-waiting-room/video-call-options.png) The app only needs to pass a `VisitResponse` to the `startVideoCall` function: ```kotlin fun startVideoCall(visit: VisitResponse) { if (performCallUsingVseeKit) { videoCallManager.startVideoCall(visit) } else { findNavController().navigate( PreWaitingRoomFragmentDirections.actionPreWaitingRoomToWebCall(url, visitId = visit.id) ) } } ``` ### 4. In the video call The patient waits for their provider to join the video call. ![In video call](https://developers.vsee.com/images/guides/clinickit/android-enter-waiting-room/in-call.png)