DB webhook not calling edge function
the edge function code
import { createClient } from 'jsr:@supabase/supabase-js';
// Supabase client
const supabase = createClient(
Deno.env.get('SUPABASE_URL') || '',
Deno.env.get('SUPABASE_SERVICE_ROLE_KEY') || ''
);
Deno.serve(async (req) => {
try {
// Parse payload from the request
const interviewId = "95fbd144-e05a-4e1b-98b5-f064d6da84c6";
const conversationId = "lXQHtdrHqiveGaYo9kLi"
if (!conversationId || !interviewId) {
return new Response('Missing required fields: conversation_id or interview_id', {
status: 400,
});
}
// Fetch conversation details from the API
const apiKey = Deno.env.get('ELEVEN_LABS_API_KEY');
const apiUrl = `https://api.elevenlabs.io/v1/convai/conversations/${conversationId}`;
const response = await fetch(apiUrl, {
method: 'GET',
headers: { 'xi-api-key': apiKey },
});
if (!response.ok) {
return new Response(
`Failed to fetch conversation details: ${await response.text()}`,
{ status: response.status }
);
}
const conversationDetails = await response.json();
const { transcript, transcript_summary } = conversationDetails;
console.log(conversationDetails)
// Update the interview table with the summary
const { error: updateError } = await supabase
.from('interview')
.update({ summary: transcript_summary })
.eq('id', interviewId);
if (updateError) {
return new Response(`Failed to update interview: ${updateError.message}`, {
status: 500,
});
}
// Insert transcript entries into the transcripts table
const transcriptInserts = transcript.map((entry) => ({
conversation_id: conversationId,
interview_id: interviewId,
role: entry.role,
message: entry.message,
time_in_call_secs: entry.time_in_call_secs,
}));import { createClient } from 'jsr:@supabase/supabase-js';
// Supabase client
const supabase = createClient(
Deno.env.get('SUPABASE_URL') || '',
Deno.env.get('SUPABASE_SERVICE_ROLE_KEY') || ''
);
Deno.serve(async (req) => {
try {
// Parse payload from the request
const interviewId = "95fbd144-e05a-4e1b-98b5-f064d6da84c6";
const conversationId = "lXQHtdrHqiveGaYo9kLi"
if (!conversationId || !interviewId) {
return new Response('Missing required fields: conversation_id or interview_id', {
status: 400,
});
}
// Fetch conversation details from the API
const apiKey = Deno.env.get('ELEVEN_LABS_API_KEY');
const apiUrl = `https://api.elevenlabs.io/v1/convai/conversations/${conversationId}`;
const response = await fetch(apiUrl, {
method: 'GET',
headers: { 'xi-api-key': apiKey },
});
if (!response.ok) {
return new Response(
`Failed to fetch conversation details: ${await response.text()}`,
{ status: response.status }
);
}
const conversationDetails = await response.json();
const { transcript, transcript_summary } = conversationDetails;
console.log(conversationDetails)
// Update the interview table with the summary
const { error: updateError } = await supabase
.from('interview')
.update({ summary: transcript_summary })
.eq('id', interviewId);
if (updateError) {
return new Response(`Failed to update interview: ${updateError.message}`, {
status: 500,
});
}
// Insert transcript entries into the transcripts table
const transcriptInserts = transcript.map((entry) => ({
conversation_id: conversationId,
interview_id: interviewId,
role: entry.role,
message: entry.message,
time_in_call_secs: entry.time_in_call_secs,
}));