Add input gathering feature to Bird API client and routes, integrate multi-gate selection flow in birdVoiceWebhooksRoute, and enhance error handling for invalid or expired sessions.

This commit is contained in:
Jeppe Bundgaard
2026-03-04 13:43:19 +01:00
parent 84ba2a1fad
commit 342209fd2f
3 changed files with 159 additions and 45 deletions
@@ -159,6 +159,36 @@ class birdVoiceCallsRoute
'modules_bird_voice_calls_say' => 'Say a message on a voice call by ID via Bird',
]);
// Gather input on an active call
$this->post('/bird/voice/calls/{id}/gather', function () {
global $response;
// Permission: gather input on a voice call via Bird
self::requirePermission('modules_bird_voice_calls_gather');
$client = new bird();
$id = (string)$this->fromRoute('id');
if ($id === null || $id === '') {
$response->error('Missing id', 400);
}
$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();
unset($payload['workspaceId'], $payload['channelId']);
$res = $client->gatherMessage($ws, $ch, $id, $payload);
$response->success($res ?? ['status' => 'ok']);
}, [
'modules_bird_voice_calls_gather' => 'Gather input on a voice call by ID via Bird',
]);
// Place test outbound call and hang up when accepted
$this->post('/bird/voice/calls/test-outbound', function () {
global $response;