VoiceRouter

assemblyai-webhook

Voice Router SDK - Webhook Normalization / assemblyai-webhook

assemblyai-webhook

Classes

AssemblyAIWebhookHandler

AssemblyAI webhook handler

Handles webhook callbacks from AssemblyAI API:

  • completed - Transcription completed successfully
  • error - Transcription failed with error

AssemblyAI supports webhook signature verification using HMAC-SHA256.

Examples

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

const handler = new AssemblyAIWebhookHandler();

// 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);
if (event.eventType === 'transcription.completed') {
  console.log('Transcript ID:', event.data?.id);
}
// Verify webhook signature
const isValid = handler.verify(req.body, {
  signature: req.headers['x-assemblyai-signature'],
  secret: process.env.ASSEMBLYAI_WEBHOOK_SECRET,
  rawBody: req.rawBody
});

if (!isValid) {
  return res.status(401).json({ error: 'Invalid signature' });
}

Extends

Constructors

Constructor

new AssemblyAIWebhookHandler(): AssemblyAIWebhookHandler

Returns

AssemblyAIWebhookHandler

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 AssemblyAI 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 AssemblyAI 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 AssemblyAI webhook signature

AssemblyAI uses HMAC-SHA256 for webhook signature verification. The signature is sent in the X-AssemblyAI-Signature header.

Parameters
ParameterTypeDescription
payloadunknownWebhook payload
optionsWebhookVerificationOptionsVerification options with signature and secret
Returns

boolean

true if signature is valid

Example
const isValid = handler.verify(req.body, {
  signature: req.headers['x-assemblyai-signature'],
  secret: process.env.ASSEMBLYAI_WEBHOOK_SECRET,
  rawBody: req.rawBody // Raw request body as string or Buffer
});
Overrides

BaseWebhookHandler.verify

Properties

provider

readonly provider: TranscriptionProvider = "assemblyai"

Provider name

Overrides

BaseWebhookHandler.provider

Functions

createAssemblyAIWebhookHandler()

createAssemblyAIWebhookHandler(): AssemblyAIWebhookHandler

Factory function to create an AssemblyAI webhook handler

Returns

AssemblyAIWebhookHandler

On this page