diff --git a/services/nginx/app/routes/birdVoiceWebhooksRoute.php b/services/nginx/app/routes/birdVoiceWebhooksRoute.php new file mode 100644 index 00000000..3d82ff8b --- /dev/null +++ b/services/nginx/app/routes/birdVoiceWebhooksRoute.php @@ -0,0 +1,42 @@ +post('/bird/voice/calls/webhook/inbound', function () { + global $response; + // Permission: trigger a voice call via Bird webhooks (intended for incoming call webhooks, but can be used for any call webhooks) + self::requirePermission('modules_bird_voice_call_webhooks_trigger'); + $client = new bird(); + // Require workspace/channel per Bird API docs + $ws = $this->normalizeOptionalString($this->fromRequest('workspaceId') ?? $this->fromQuery('workspaceId')); + $ch = $this->normalizeOptionalString($this->fromRequest('channelId') ?? $this->fromQuery('channelId')); + if ($ws === '') { + $ws = $this->getConfiguredWorkspaceId($client); + } + if ($ch === '') { + $ch = $this->getConfiguredChannelId($client); + } + if ($ws === '' || $ch === '') { + $response->error('Missing required parameters: workspaceId, channelId', 400); + } + $payload = $this->getParametersAsArray(); + $slack = new Slack(); + $slack->send_message('Webhook received for incoming voice call: ' . json_encode($payload), 'Bird Voice Call Webhooks'); + $response->success($res ?? ['status' => 'ok']); + }, [ + 'modules_bird_voice_call_webhooks_trigger' => 'Trigger a voice call via Bird webhooks', + ]); + } +} \ No newline at end of file