We’re building a *Doctor Consultation Telehealth A...
# sdk-web
l
We’re building a Doctor Consultation Telehealth Application using React.js and using LiveKit for video calling. ### Here’s our current implementation flow (Standalone): - We do not manually create LiveKit rooms — Livekit created when a user initiates a call. - We use LiveKit webhooks (primarily `room_started `and participant-related events) to: - Update our `callLog `table with the generated
roomId
. - Track and store
participant join/left
events. - Maintain a complete call record for audit and analytics purposes. ### Our requirement: Whenever a patient books an appointment, we insert a record into the `callLog `table containing the `appointmentId `and the scheduled appointment time. At this stage, the `roomId `is not yet available, as the LiveKit room has not been created Once the scheduled appointment time arrives and either patient or doctor initiates the call , a LiveKit room is created, At that point, we need to update the existing `callLog `record with the corresponding `roomId `linked to the
appointmentId
. *_*We’re considering two potential approaches:*_* ### Option 1: - After the LiveKit room is auto-created when a call is initiated, - Update the room metadata with the
appointmentId
. - Use a RoomMetadataChanged event to detect this and call our backend API to update the `callLog `table with the `roomId `corresponding to the existing
appointmentId
.
Note: I have currently implemented the first two steps of Option 1 in our existing flow.
### Option 2: - Instead of auto room creation, we manually create the LiveKit room in the backend when the appointment time arrives or when the first participant initiates the call. - While creating the room, we set the metadata with the
appointmentId
. - Use the `room_started `**webhook** from LiveKit to update our `callLog `table with both `appointmentId `and
roomId
. ### What we’re looking for: - Is there a recommended or best-practice approach for this kind of mapping (*appointment ↔️ room*)? - Are there any potential pitfalls with relying on metadata update events vs using the `room_started `**webhook**? - Is there any better approach to keep appointment and room in sync? *Any guidance or suggestions would be really helpful 🙏* Thanks in Advance
h
as you control the backend that generates the participant tokens, you also have 2 things that you can do: 1. When issuing the participant token, set the room name using the appointmentId or some other ID that you can identify the appointmentId 2. When issuing the participant token, add the appointmentId to that participant's attributes. As long as participants can't update their own attributes, you will have on the participant "to which appointmentId this participant token refers to" Both ideas may not be the ideal solution, but might help if you want to achieve it with a small amount of changes
r
Indeed, just set room id in the jwt. A room with that id will be created.