diff --git a/supabase/functions/create-google-meet-event/index.ts b/supabase/functions/create-google-meet-event/index.ts index 8b22d78..cc0cbcf 100644 --- a/supabase/functions/create-google-meet-event/index.ts +++ b/supabase/functions/create-google-meet-event/index.ts @@ -246,8 +246,31 @@ serve(async (req: Request): Promise => { const eventDataResult = await calendarResponse.json(); console.log("Event created:", eventDataResult.id); + console.log("Full event response:", JSON.stringify(eventDataResult, null, 2)); - // Update the slot with the meet link + // Check if conference data was created + if (eventDataResult.conferenceData && eventDataResult.conferenceData.entryPoints) { + const meetLink = eventDataResult.conferenceData.entryPoints.find((ep: any) => ep.entryPointType === "video")?.uri; + + if (meetLink) { + await supabase + .from("consulting_slots") + .update({ meet_link: meetLink }) + .eq("id", body.slot_id); + + return new Response( + JSON.stringify({ + success: true, + meet_link: meetLink, + event_id: eventDataResult.id, + html_link: eventDataResult.htmlLink, + }), + { headers: { ...corsHeaders, "Content-Type": "application/json" } } + ); + } + } + + // Fallback to hangoutLink for backwards compatibility if (eventDataResult.hangoutLink) { await supabase .from("consulting_slots")