Skip to content

TwimlResponseType

function TwimlResponseType(contentType?): MethodDecorator;

Defined in: lib/twiml/twiml.interceptor.ts:135

Route-level (or controller-method-level) override for the Content-Type header TwimlInterceptor writes when it serializes a TwiML response returned from that handler. Takes precedence over the interceptor’s constructor option and its built-in default.

Parameter Type Description
contentType? string The Content-Type header to use for this handler’s TwiML responses. Omit to fall back to the interceptor’s own configuration.

MethodDecorator

@Controller('voice')
@UseInterceptors(TwimlInterceptor)
export class VoiceController {
@Post('incoming')
@TwimlResponseType('application/xml')
handleIncomingCall(): VoiceResponse {
const response = new VoiceResponse();
response.say('Hello from NestJS');
return response;
}
}