VoiceRouter

azure-webhook

Voice Router SDK - Webhook Normalization / azure-webhook

azure-webhook

Classes

AzureWebhookHandler

Azure webhook handler

Handles webhook callbacks from Azure Speech Services API:

  • TranscriptionCreated - Transcription job created
  • TranscriptionRunning - Transcription is processing
  • TranscriptionSucceeded - Transcription completed successfully
  • TranscriptionFailed - Transcription failed with error

Azure supports optional webhook signature verification using a shared secret.

Examples

import { AzureWebhookHandler } from '@meeting-baas/sdk';

const handler = new AzureWebhookHandler();

// Validate webhook
const validation = handler.validate(req.body);
if (!validation.valid) {
  return res.status(400).json({ error: validation.error });
}

// Parse webhook
const event = handler.parse(req.body);
console.log('Event type:', event.eventType);
console.log('Action:', event.raw.action);
// Verify webhook signature (if configured in Azure)
const isValid = handler.verify(req.body, {
  signature: req.headers['x-azure-signature'],
  secret: process.env.AZURE_WEBHOOK_SECRET,
  rawBody: req.rawBody
});

if (!isValid) {
  return res.status(401).json({ error: 'Invalid signature' });
}
const event = handler.parse(req.body);

if (event.eventType === 'transcription.completed') {
  // Extract transcription ID from self link
  const transcriptionId = event.data?.id;

  // Fetch full transcript using AzureAdapter.getTranscript(transcriptionId)
  console.log('Transcription completed:', transcriptionId);
}

Extends

Constructors

Constructor

new AzureWebhookHandler(): AzureWebhookHandler

Returns

AzureWebhookHandler

Inherited from

BaseWebhookHandler.constructor

Methods

createErrorEvent()

protected createErrorEvent(payload, errorMessage): UnifiedWebhookEvent

Helper method to create error response

Parameters
ParameterType
payloadunknown
errorMessagestring
Returns

UnifiedWebhookEvent

Inherited from

BaseWebhookHandler.createErrorEvent

matches()

matches(payload, _options?): boolean

Check if payload matches Azure webhook format

Parameters
ParameterType
payloadunknown
_options?{ queryParams?: Record<string, string>; userAgent?: string; }
_options.queryParams?Record<string, string>
_options.userAgent?string
Returns

boolean

Overrides

BaseWebhookHandler.matches

parse()

parse(payload, _options?): UnifiedWebhookEvent

Parse Azure webhook payload to unified format

Parameters
ParameterType
payloadunknown
_options?{ queryParams?: Record<string, string>; }
_options.queryParams?Record<string, string>
Returns

UnifiedWebhookEvent

Overrides

BaseWebhookHandler.parse

validate()

validate(payload, options?): WebhookValidation

Validate webhook payload structure

Checks if payload has required fields and correct types

Parameters
ParameterTypeDescription
payloadunknownRaw webhook payload
options?{ queryParams?: Record<string, string>; userAgent?: string; }Optional context (query params, headers, etc.)
options.queryParams?Record<string, string>-
options.userAgent?string-
Returns

WebhookValidation

Validation result with details

Inherited from

BaseWebhookHandler.validate

verify()

verify(payload, options): boolean

Verify Azure webhook signature

Azure can optionally sign webhooks using HMAC-SHA256. The signature is sent in the X-Azure-Signature header.

Note: Signature verification is optional in Azure and must be configured when creating the webhook.

Parameters
ParameterTypeDescription
payloadunknownWebhook payload
optionsWebhookVerificationOptionsVerification options with signature and secret
Returns

boolean

true if signature is valid or no signature provided

Example
const isValid = handler.verify(req.body, {
  signature: req.headers['x-azure-signature'],
  secret: process.env.AZURE_WEBHOOK_SECRET,
  rawBody: req.rawBody
});
Overrides

BaseWebhookHandler.verify

Properties

provider

readonly provider: TranscriptionProvider = "azure-stt"

Provider name

Overrides

BaseWebhookHandler.provider

Functions

createAzureWebhookHandler()

createAzureWebhookHandler(): AzureWebhookHandler

Factory function to create an Azure webhook handler

Returns

AzureWebhookHandler

On this page