import { VoiceSession, verifyTelnyxWebhook } from '@adrper79-dot/telephony';
app.post('/webhook/telnyx', async (c) => {
const event = await verifyTelnyxWebhook(c.req.raw, c.env.TELNYX_API_KEY);
if (event.data.event_type === 'call.answered') {
const session = new VoiceSession({
callId: event.data.payload.call_control_id,
direction: 'inbound',
voiceId: 'eleven-turbo-v2',
systemPrompt: 'You are a friendly receptionist for Acme Corp.',
env: c.env,
});
// Store session in Durable Object or KV by callId
}
return c.json({ received: true });
});