createNotification method

Future<CreateNotificationResponse> createNotification({
  1. required Map<LocaleCode, String> content,
  2. required String instanceId,
  3. required List<String> recipients,
  4. String? clientToken,
  5. DateTime? expiresAt,
  6. String? predefinedNotificationId,
  7. ConfigurableNotificationPriority? priority,
  8. Map<String, String>? tags,
})

Creates a new notification to be delivered to specified recipients. Notifications can include localized content with links, and an optional expiration time. Recipients can be specified as individual user ARNs or instance ARNs to target all users in an instance.

May throw AccessDeniedException. May throw DuplicateResourceException. May throw InternalServiceException. May throw InvalidParameterException. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter content : The localized content of the notification. A map where keys are locale codes and values are the notification text in that locale. Content supports links. Maximum 250 characters per locale.

Parameter instanceId : The identifier of the Amazon Connect instance. You can find the instance ID in the Amazon Resource Name (ARN) of the instance.

Parameter recipients : A list of Amazon Resource Names (ARNs) identifying the recipients of the notification. Can include user ARNs or instance ARNs to target all users in an instance. Maximum of 200 recipients.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

Parameter expiresAt : The timestamp when the notification should expire and no longer be displayed to users. If not specified, defaults to one week from creation.

Parameter priority : The priority level of the notification. Valid values are HIGH and LOW. High priority notifications are displayed above low priority notifications.

Parameter tags : The tags used to organize, track, or control access for this resource. For example, { "Tags": {"key1":"value1", "key2":"value2"} }.

Implementation

Future<CreateNotificationResponse> createNotification({
  required Map<LocaleCode, String> content,
  required String instanceId,
  required List<String> recipients,
  String? clientToken,
  DateTime? expiresAt,
  String? predefinedNotificationId,
  ConfigurableNotificationPriority? priority,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'Content': content.map((k, e) => MapEntry(k.value, e)),
    'Recipients': recipients,
    'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (expiresAt != null) 'ExpiresAt': unixTimestampToJson(expiresAt),
    if (predefinedNotificationId != null)
      'PredefinedNotificationId': predefinedNotificationId,
    if (priority != null) 'Priority': priority.value,
    if (tags != null) 'Tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/notifications/${Uri.encodeComponent(instanceId)}',
    exceptionFnMap: _exceptionFns,
  );
  return CreateNotificationResponse.fromJson(response);
}