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
Inherited from
BaseWebhookHandler.constructor
Methods
createErrorEvent()
protectedcreateErrorEvent(payload,errorMessage):UnifiedWebhookEvent
Helper method to create error response
Parameters
| Parameter | Type |
|---|---|
payload | unknown |
errorMessage | string |
Returns
Inherited from
BaseWebhookHandler.createErrorEvent
matches()
matches(
payload,_options?):boolean
Check if payload matches Azure webhook format
Parameters
| Parameter | Type |
|---|---|
payload | unknown |
_options? | { queryParams?: Record<string, string>; userAgent?: string; } |
_options.queryParams? | Record<string, string> |
_options.userAgent? | string |
Returns
boolean
Overrides
parse()
parse(
payload,_options?):UnifiedWebhookEvent
Parse Azure webhook payload to unified format
Parameters
| Parameter | Type |
|---|---|
payload | unknown |
_options? | { queryParams?: Record<string, string>; } |
_options.queryParams? | Record<string, string> |
Returns
Overrides
validate()
validate(
payload,options?):WebhookValidation
Validate webhook payload structure
Checks if payload has required fields and correct types
Parameters
| Parameter | Type | Description |
|---|---|---|
payload | unknown | Raw webhook payload |
options? | { queryParams?: Record<string, string>; userAgent?: string; } | Optional context (query params, headers, etc.) |
options.queryParams? | Record<string, string> | - |
options.userAgent? | string | - |
Returns
Validation result with details
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
payload | unknown | Webhook payload |
options | WebhookVerificationOptions | Verification 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
Properties
provider
readonlyprovider:TranscriptionProvider="azure-stt"
Provider name
Overrides
Functions
createAzureWebhookHandler()
createAzureWebhookHandler():
AzureWebhookHandler
Factory function to create an Azure webhook handler