sendVoiceMessage method

Future<SendVoiceMessageResult> sendVoiceMessage({
  1. required String destinationPhoneNumber,
  2. required String originationIdentity,
  3. String? configurationSetName,
  4. Map<String, String>? context,
  5. bool? dryRun,
  6. String? maxPricePerMinute,
  7. String? messageBody,
  8. VoiceMessageBodyTextType? messageBodyTextType,
  9. bool? messageFeedbackEnabled,
  10. String? protectConfigurationId,
  11. int? timeToLive,
  12. VoiceId? voiceId,
})

Allows you to send a request that sends a voice message. This operation uses Amazon Polly to convert a text script into a voice message.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter destinationPhoneNumber : The destination phone number in E.164 format.

Parameter originationIdentity : The origination identity to use for the voice call. This can be the PhoneNumber, PhoneNumberId, PhoneNumberArn, PoolId, or PoolArn.

Parameter configurationSetName : The name of the configuration set to use. This can be either the ConfigurationSetName or ConfigurationSetArn.

Parameter context : You can specify custom data in this field. If you do, that data is logged to the event destination.

Parameter dryRun : When set to true, the message is checked and validated, but isn't sent to the end recipient.

Parameter maxPricePerMinute : The maximum amount to spend per voice message, in US dollars.

Parameter messageBody : The text to convert to a voice message.

Parameter messageBodyTextType : Specifies if the MessageBody field contains text or speech synthesis markup language (SSML).

  • TEXT: This is the default value. When used the maximum character limit is 3000.
  • SSML: When used the maximum character limit is 6000 including SSML tagging.

Parameter messageFeedbackEnabled : Set to true to enable message feedback for the message. When a user receives the message you need to update the message status using PutMessageFeedback.

Parameter protectConfigurationId : The unique identifier for the protect configuration.

Parameter timeToLive : How long the voice message is valid for. By default this is 72 hours.

Parameter voiceId : The voice for the Amazon Polly service to use. By default this is set to "MATTHEW".

Implementation

Future<SendVoiceMessageResult> sendVoiceMessage({
  required String destinationPhoneNumber,
  required String originationIdentity,
  String? configurationSetName,
  Map<String, String>? context,
  bool? dryRun,
  String? maxPricePerMinute,
  String? messageBody,
  VoiceMessageBodyTextType? messageBodyTextType,
  bool? messageFeedbackEnabled,
  String? protectConfigurationId,
  int? timeToLive,
  VoiceId? voiceId,
}) async {
  _s.validateNumRange(
    'timeToLive',
    timeToLive,
    5,
    259200,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'PinpointSMSVoiceV2.SendVoiceMessage'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DestinationPhoneNumber': destinationPhoneNumber,
      'OriginationIdentity': originationIdentity,
      if (configurationSetName != null)
        'ConfigurationSetName': configurationSetName,
      if (context != null) 'Context': context,
      if (dryRun != null) 'DryRun': dryRun,
      if (maxPricePerMinute != null) 'MaxPricePerMinute': maxPricePerMinute,
      if (messageBody != null) 'MessageBody': messageBody,
      if (messageBodyTextType != null)
        'MessageBodyTextType': messageBodyTextType.value,
      if (messageFeedbackEnabled != null)
        'MessageFeedbackEnabled': messageFeedbackEnabled,
      if (protectConfigurationId != null)
        'ProtectConfigurationId': protectConfigurationId,
      if (timeToLive != null) 'TimeToLive': timeToLive,
      if (voiceId != null) 'VoiceId': voiceId.value,
    },
  );

  return SendVoiceMessageResult.fromJson(jsonResponse.body);
}