createContact method

Future<CreateContactResponse> createContact({
  1. required Channel channel,
  2. required ContactInitiationMethod initiationMethod,
  3. required String instanceId,
  4. Map<String, String>? attributes,
  5. String? clientToken,
  6. String? description,
  7. int? expiryDurationInMinutes,
  8. InitiateAs? initiateAs,
  9. String? name,
  10. String? previousContactId,
  11. Map<String, Reference>? references,
  12. String? relatedContactId,
  13. Map<String, SegmentAttributeValue>? segmentAttributes,
  14. UserInfo? userInfo,
})
Creates a new VOICE, EMAIL, or TASK contact.

After a contact is created, you can move it to the desired state by using the InitiateAs parameter. While you can use API to create task contacts that are in the COMPLETED state, you must contact Amazon Web Services Support before using it for bulk import use cases. Bulk import causes your requests to be throttled or fail if your CreateContact limits aren't high enough.

May throw AccessDeniedException. May throw ConflictException. May throw IdempotencyException. May throw InternalServiceException. May throw InvalidParameterException. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException.

Parameter channel : The channel for the contact.

Parameter initiationMethod : Indicates how the contact was initiated.

  • For VOICE: TRANSFER and the subtype connect:ExternalAudio
  • For EMAIL: OUTBOUND | AGENT_REPLY | FLOW
  • For TASK: API
The other channels listed below are incorrect. We're working to correct this information.

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

Parameter attributes : A custom key-value pair using an attribute map. The attributes are standard Connect Customer attributes, and can be accessed in flows just like any other contact attributes.

There can be up to 32,768 UTF-8 bytes across all key-value pairs per contact. Attribute keys can include only alphanumeric, dash, and underscore characters.

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 description : A description of the contact.

Parameter expiryDurationInMinutes : Number of minutes the contact will be active for before expiring

Parameter initiateAs : Initial state of the contact when it's created. Only TASK channel contacts can be initiated with COMPLETED state.

Parameter name : The name of a the contact.

Parameter previousContactId : The ID of the previous contact when creating a transfer contact. This value can be provided only for external audio contacts. For more information, see Integrate Connect Customer Contact Lens with external voice systems in the Connect Customer Administrator Guide.

Parameter references : A formatted URL that is shown to an agent in the Contact Control Panel (CCP). Tasks can have the following reference types at the time of creation: URL | NUMBER | STRING | DATE | EMAIL | ATTACHMENT.

Parameter relatedContactId : The identifier of the contact in this instance of Connect Customer.

Parameter segmentAttributes : A set of system defined key-value pairs stored on individual contact segments (unique contact ID) using an attribute map. The attributes are standard Connect Customer attributes. They can be accessed in flows.

Attribute keys can include only alphanumeric, -, and _.

This field can be used to set Segment Contact Expiry as a duration in minutes.

Parameter userInfo : User details for the contact

Implementation

Future<CreateContactResponse> createContact({
  required Channel channel,
  required ContactInitiationMethod initiationMethod,
  required String instanceId,
  Map<String, String>? attributes,
  String? clientToken,
  String? description,
  int? expiryDurationInMinutes,
  InitiateAs? initiateAs,
  String? name,
  String? previousContactId,
  Map<String, Reference>? references,
  String? relatedContactId,
  Map<String, SegmentAttributeValue>? segmentAttributes,
  UserInfo? userInfo,
}) async {
  final $payload = <String, dynamic>{
    'Channel': channel.value,
    'InitiationMethod': initiationMethod.value,
    'InstanceId': instanceId,
    if (attributes != null) 'Attributes': attributes,
    'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (description != null) 'Description': description,
    if (expiryDurationInMinutes != null)
      'ExpiryDurationInMinutes': expiryDurationInMinutes,
    if (initiateAs != null) 'InitiateAs': initiateAs.value,
    if (name != null) 'Name': name,
    if (previousContactId != null) 'PreviousContactId': previousContactId,
    if (references != null) 'References': references,
    if (relatedContactId != null) 'RelatedContactId': relatedContactId,
    if (segmentAttributes != null) 'SegmentAttributes': segmentAttributes,
    if (userInfo != null) 'UserInfo': userInfo,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/contact/create-contact',
    exceptionFnMap: _exceptionFns,
  );
  return CreateContactResponse.fromJson(response);
}