Skip to content

create_contact async

create_contact(
    instance_id: InstanceId,
    channel: Channel,
    initiation_method: ContactInitiationMethod,
    *,
    config_overrides: Optional[AsyncConnectClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    related_contact_id: Optional[ContactId] = None,
    attributes: Optional[Attributes] = None,
    references: Optional[ContactReferences] = None,
    expiry_duration_in_minutes: Optional[ExpiryDurationInMinutes] = None,
    user_info: Optional[UserInfo] = None,
    initiate_as: Optional[InitiateAs] = None,
    name: Optional[Name] = None,
    description: Optional[Description] = None,
    segment_attributes: Optional[SegmentAttributes] = None,
    previous_contact_id: Optional[ContactId] = None,
) -> CreateContactResponse

Only the VOICE, EMAIL, and TASK channels are supported.

  • For VOICE: The supported initiation method is TRANSFER. The contacts created with this initiation method have a subtype connect:ExternalAudio.

  • For EMAIL: The supported initiation methods are OUTBOUND, AGENT_REPLY, and FLOW.

  • For TASK: The supported initiation method is API. Contacts created with this API have a sub-type of connect:ExternalTask.

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.

Parameters:

  • instance_id (InstanceId) –

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

  • client_token (Optional[ClientToken], default: None ) –

    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.

  • related_contact_id (Optional[ContactId], default: None ) –

    The identifier of the contact in this instance of Connect Customer.

  • attributes (Optional[Attributes], default: None ) –

    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.

  • references (Optional[ContactReferences], default: None ) –

    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.

  • channel (Channel) –

    The channel for the contact.

    The CHAT channel is not supported. The following information is incorrect. We're working to correct it.

  • initiation_method (ContactInitiationMethod) –

    Indicates how the contact was initiated.

    CreateContact only supports the following initiation methods. Valid values by channel are:

    • 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.

  • expiry_duration_in_minutes (Optional[ExpiryDurationInMinutes], default: None ) –

    Number of minutes the contact will be active for before expiring

  • user_info (Optional[UserInfo], default: None ) –

    User details for the contact

    UserInfo is required when creating an EMAIL contact with OUTBOUND and AGENT_REPLY contact initiation methods.

  • initiate_as (Optional[InitiateAs], default: None ) –

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

  • name (Optional[Name], default: None ) –

    The name of a the contact.

  • description (Optional[Description], default: None ) –

    A description of the contact.

  • segment_attributes (Optional[SegmentAttributes], default: None ) –

    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.

    To set contact expiry, a ValueMap must be specified containing the integer number of minutes the contact will be active for before expiring, with SegmentAttributes like { "connect:ContactExpiry": {"ValueMap" : { "ExpiryDuration": { "ValueInteger": 135}}}}.

  • previous_contact_id (Optional[ContactId], default: None ) –

    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.

Raises:

Source code in docs_src/capo_connect/_services/async_connect.py
async def create_contact(
    self,
    instance_id: "capo_connect.types.instance_id.InstanceId",
    channel: "capo_connect.types.channel.Channel",
    initiation_method: "capo_connect.types.contact_initiation_method.ContactInitiationMethod",
    *,
    config_overrides: Optional[AsyncConnectClientConfig] = None,
    client_token: Optional["capo_connect.types.client_token.ClientToken"] = None,
    related_contact_id: Optional["capo_connect.types.contact_id.ContactId"] = None,
    attributes: Optional["capo_connect.types.attributes.Attributes"] = None,
    references: Optional[
        "capo_connect.types.contact_references.ContactReferences"
    ] = None,
    expiry_duration_in_minutes: Optional[
        "capo_connect.types.expiry_duration_in_minutes.ExpiryDurationInMinutes"
    ] = None,
    user_info: Optional["capo_connect.types.user_info.UserInfo"] = None,
    initiate_as: Optional["capo_connect.types.initiate_as.InitiateAs"] = None,
    name: Optional["capo_connect.types.name.Name"] = None,
    description: Optional["capo_connect.types.description.Description"] = None,
    segment_attributes: Optional[
        "capo_connect.types.segment_attributes.SegmentAttributes"
    ] = None,
    previous_contact_id: Optional["capo_connect.types.contact_id.ContactId"] = None,
) -> "capo_connect.types.create_contact_response.CreateContactResponse":
    """<important> <p>Only the VOICE, EMAIL, and TASK channels are supported. </p> <ul> <li> <p>For VOICE: The supported initiation method is <code>TRANSFER</code>. The contacts created with this initiation method have a subtype <code>connect:ExternalAudio</code>. </p> </li> <li> <p>For EMAIL: The supported initiation methods are <code>OUTBOUND</code>, <code>AGENT_REPLY</code>, and <code>FLOW</code>. </p> </li> <li> <p>For TASK: The supported initiation method is <code>API</code>. Contacts created with this API have a sub-type of <code>connect:ExternalTask</code>.</p> </li> </ul> </important> <p>Creates a new VOICE, EMAIL, or TASK contact. </p> <p>After a contact is created, you can move it to the desired state by using the <code>InitiateAs</code> parameter. While you can use API to create task contacts that are in the <code>COMPLETED</code> 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. </p>

    Args:
        instance_id: <p>The identifier of the Connect Customer instance. You can <a href="https://docs.aws.amazon.com/connect/latest/adminguide/find-instance-arn.html">find the instance ID</a> in the Amazon Resource Name (ARN) of the instance.</p>
        client_token: <p>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 <a href="https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/">Making retries safe with idempotent APIs</a>.</p>
        related_contact_id: <p>The identifier of the contact in this instance of Connect Customer. </p>
        attributes: <p>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.</p> <p>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.</p>
        references: <p>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: <code>URL</code> | <code>NUMBER</code> | <code>STRING</code> | <code>DATE</code> | <code>EMAIL</code> | <code>ATTACHMENT</code>.</p>
        channel: <p>The channel for the contact.</p> <important> <p>The CHAT channel is not supported. The following information is incorrect. We're working to correct it.</p> </important>
        initiation_method: <p>Indicates how the contact was initiated. </p> <important> <p>CreateContact only supports the following initiation methods. Valid values by channel are: </p> <ul> <li> <p>For VOICE: <code>TRANSFER</code> and the subtype <code>connect:ExternalAudio</code> </p> </li> <li> <p>For EMAIL: <code>OUTBOUND</code> | <code>AGENT_REPLY</code> | <code>FLOW</code> </p> </li> <li> <p>For TASK: <code>API</code> </p> </li> </ul> <p>The other channels listed below are incorrect. We're working to correct this information.</p> </important>
        expiry_duration_in_minutes: <p>Number of minutes the contact will be active for before expiring</p>
        user_info: <p>User details for the contact</p> <important> <p>UserInfo is required when creating an EMAIL contact with <code>OUTBOUND</code> and <code>AGENT_REPLY</code> contact initiation methods.</p> </important>
        initiate_as: <p>Initial state of the contact when it's created. Only TASK channel contacts can be initiated with <code>COMPLETED</code> state.</p>
        name: <p>The name of a the contact.</p>
        description: <p>A description of the contact.</p>
        segment_attributes: <p>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.</p> <p>Attribute keys can include only alphanumeric, -, and _.</p> <p>This field can be used to set Segment Contact Expiry as a duration in minutes.</p> <note> <p>To set contact expiry, a ValueMap must be specified containing the integer number of minutes the contact will be active for before expiring, with <code>SegmentAttributes</code> like { <code> "connect:ContactExpiry": {"ValueMap" : { "ExpiryDuration": { "ValueInteger": 135}}}}</code>. </p> </note>
        previous_contact_id: <p>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 <a href="https://docs.aws.amazon.com/connect/latest/adminguide/contact-lens-integration.html">Integrate Connect Customer Contact Lens with external voice systems</a> in the <i>Connect Customer Administrator Guide</i>.</p>

    Raises:
        capo_connect.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient permissions to perform this action.</p>
        capo_connect.errors.conflict_exception.ConflictException: <p>Operation cannot be performed at this time as there is a conflict with another operation or contact state.</p>
        capo_connect.errors.idempotency_exception.IdempotencyException: <p>An entity with the same name already exists.</p>
        capo_connect.errors.internal_service_exception.InternalServiceException: <p>Request processing failed because of an error or failure with the service.</p>
        capo_connect.errors.invalid_parameter_exception.InvalidParameterException: <p>One or more of the specified parameters are not valid.</p>
        capo_connect.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
        capo_connect.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found.</p>
        capo_connect.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The service quota has been exceeded.</p>
        capo_connect.errors.throttling_exception.ThrottlingException: <p>The throttling limit has been exceeded.</p>
        capo_connect.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_connect.types.create_contact_request.CreateContactRequest]",
    ) -> AsyncOperationResponse[
        "capo_connect.types.create_contact_response.CreateContactResponse"
    ]:
        import capo_connect._operations.amazon_connect_service.create_contact

        (
            output,
            http_response,
        ) = await capo_connect._operations.amazon_connect_service.create_contact.async_create_contact(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_connect.types.create_contact_request.CreateContactRequest",
    ) -> dict[str, Any]:
        import capo_connect.types.create_contact_request

        return capo_connect.types.create_contact_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateContact", redact_input=_redact_input),
    )
    input_: capo_connect.types.create_contact_request.CreateContactRequest = {
        "instance_id": instance_id,
        "channel": channel,
        "initiation_method": initiation_method,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if related_contact_id is not None:
        input_["related_contact_id"] = related_contact_id
    if attributes is not None:
        input_["attributes"] = attributes
    if references is not None:
        input_["references"] = references
    if expiry_duration_in_minutes is not None:
        input_["expiry_duration_in_minutes"] = expiry_duration_in_minutes
    if user_info is not None:
        input_["user_info"] = user_info
    if initiate_as is not None:
        input_["initiate_as"] = initiate_as
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if segment_attributes is not None:
        input_["segment_attributes"] = segment_attributes
    if previous_contact_id is not None:
        input_["previous_contact_id"] = previous_contact_id

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output