π₯Stream Call
Welcome to the Stream Calling feature documentation. This feature enables users to have real-time video and audio communication during virtual appointments, enhancing the remote healthcare experience.
Prerequisites
To use the Stream Calling feature, ensure that you meet the following requirements:
Compatible device with a webcam and microphone.
Strong and stable internet connection with sufficient bandwidth.
Access permissions to initiate and join stream calls within the virtual appointment platform.
Getting Started
A stream call session is created once a scheduled virtual appointment has been confirmed that the timing can been met by either the medical provider or their patient. An email containing a stream call link is sent to both parties for the scheduled virtual meeting.
The Stream Calling feature in Elixir is implemented using WebRTC technology, powered by Daily. Daily provides a robust and scalable solution for real-time video and audio communication, enabling seamless stream calling experiences for healthcare providers and patients.
The feature is enabled through the integration of two key code components:
The code for creating the meeting point:
async createDailySessionRoom(patientEmail: string, doctorEmail: string, appointment_id: string) {
const session = await this.sessionModel.findOne({patientEmail: aes.encrypt(patientEmail), doctorEmail: aes.encrypt(doctorEmail)}).exec()
if(session) {
await this.sessionModel.deleteOne({patientEmail: aes.encrypt(patientEmail), doctorEmail: aes.encrypt(doctorEmail)})
}
const sessionRoom = await this.sessionModel.create({ patientEmail: aes.encrypt(patientEmail), doctorEmail: aes.encrypt(doctorEmail), appointment: appointment_id });
await sessionRoom.save();
const appointment = await this.getAppointmentDetailsBySessionByID(sessionRoom._id)
const appointmentDate = new Date(appointment['date'])
const appointmentStartTimeInSeconds = Math.floor(appointmentDate.getTime()) / 1000
const appointmentDurationTime = appointment.duration
const [hours, minutes] = appointmentDurationTime.split(":")
appointmentDate.setHours( appointmentDate.getHours() + parseInt(hours, 10) )
appointmentDate.setMinutes( appointmentDate.getMinutes() + parseInt(minutes, 10) )
const appointmentEndTime = Math.floor(appointmentDate.getTime() / 1000)
const url = "https://api.daily.co/v1/rooms/"
const token = process.env.DAILY_API_KEY
const options = {headers: {"Authorization": `Bearer ${token}`}}
const data = {
privacy: "private",
properties: {
start_audio_off: true,
start_video_off: true,
nbf: appointmentStartTimeInSeconds,
exp: appointmentEndTime,
eject_at_room_exp: true,
}
}
try {
const response = await axios.post(url, data, options)
return response.data
} catch (error) {
throw error
}
}
The code that generates an authentication token for the meeting:
async createMeetingTokenForDailyRoom(roomName: string, roomExp: number) {
const url = "https://api.daily.co/v1/meeting-tokens/"
const token = process.env.DAILY_API_KEY
const options = {headers: {"Authorization": `Bearer ${token}`}}
const data = {
properties: {
room_name: roomName,
exp: roomExp
}
}
try {
const response = await axios.post(url, data, options)
return response.data.token
} catch (error) {
throw error
}
}
Last updated