Skip to content

start_assistant_contact async

start_assistant_contact(
    instance_id: InstanceId,
    ai_agent: AiAgentInput,
    participant_details: ParticipantDetails,
    *,
    config_overrides: Optional[AsyncConnectClientConfig] = None,
    initial_message: Optional[ChatMessage] = None,
    attributes: Optional[Attributes] = None,
    client_token: Optional[ClientToken] = None,
    persistent_chat: Optional[PersistentChat] = None,
    related_contact_id: Optional[ContactId] = None,
) -> StartAssistantContactResponse

Starts a chat contact with an AI agent.

Use the returned ParticipantToken with the CreateParticipantConnection operation.

For more information about chat, see the following topics in the Connect Customer Administrator Guide:

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.

  • ai_agent (AiAgentInput) –

    The AI agent configuration for this contact.

  • participant_details (ParticipantDetails) –

    The display name and other details that identify the chat participant.

  • initial_message (Optional[ChatMessage], default: None ) –

    The initial message to send to the newly created chat.

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

    A map of key-value pairs to associate with the contact. We make these attributes available to flows as standard contact attributes.

    You can provide up to 32,768 UTF-8 bytes across all key-value pairs for each contact.

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

  • persistent_chat (Optional[PersistentChat], default: None ) –

    The configuration that enables persistent chat. For more information about persistent chat and its use cases, see Enable persistent chat.

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

    The identifier of an Connect Customer contact related to the new assistant contact.

    You cannot provide both RelatedContactId and PersistentChat.

Raises:

Source code in docs_src/capo_connect/_services/async_connect.py
async def start_assistant_contact(
    self,
    instance_id: "capo_connect.types.instance_id.InstanceId",
    ai_agent: "capo_connect.types.ai_agent_input.AiAgentInput",
    participant_details: "capo_connect.types.participant_details.ParticipantDetails",
    *,
    config_overrides: Optional[AsyncConnectClientConfig] = None,
    initial_message: Optional["capo_connect.types.chat_message.ChatMessage"] = None,
    attributes: Optional["capo_connect.types.attributes.Attributes"] = None,
    client_token: Optional["capo_connect.types.client_token.ClientToken"] = None,
    persistent_chat: Optional[
        "capo_connect.types.persistent_chat.PersistentChat"
    ] = None,
    related_contact_id: Optional["capo_connect.types.contact_id.ContactId"] = None,
) -> "capo_connect.types.start_assistant_contact_response.StartAssistantContactResponse":
    """<p>Starts a chat contact with an AI agent.</p> <p>Use the returned <code>ParticipantToken</code> with the <a href="https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_CreateParticipantConnection.html">CreateParticipantConnection</a> operation.</p> <p>For more information about chat, see the following topics in the <i>Connect Customer Administrator Guide</i>: </p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/connect/latest/adminguide/web-and-mobile-chat.html">Concepts: Web and mobile messaging capabilities in Connect Customer</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/connect/latest/adminguide/security-best-practices.html#bp-security-chat">Connect Customer Chat security best practices</a> </p> </li> </ul>

    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>
        ai_agent: <p>The AI agent configuration for this contact.</p>
        participant_details: <p>The display name and other details that identify the chat participant.</p>
        initial_message: <p>The initial message to send to the newly created chat.</p>
        attributes: <p>A map of key-value pairs to associate with the contact. We make these attributes available to flows as standard contact attributes.</p> <p>You can provide up to 32,768 UTF-8 bytes across all key-value pairs for each contact.</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>
        persistent_chat: <p>The configuration that enables persistent chat. For more information about persistent chat and its use cases, see <a href="https://docs.aws.amazon.com/connect/latest/adminguide/chat-persistence.html">Enable persistent chat</a>.</p>
        related_contact_id: <p>The identifier of an Connect Customer contact related to the new assistant contact.</p> <note> <p>You cannot provide both <code>RelatedContactId</code> and <code>PersistentChat</code>.</p> </note>

    Raises:
        capo_connect.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient permissions to perform this action.</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.limit_exceeded_exception.LimitExceededException: <p>The allowed limit for the resource has been exceeded.</p>
        capo_connect.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found.</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.start_assistant_contact_request.StartAssistantContactRequest]",
    ) -> AsyncOperationResponse[
        "capo_connect.types.start_assistant_contact_response.StartAssistantContactResponse"
    ]:
        import capo_connect._operations.amazon_connect_service.start_assistant_contact

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StartAssistantContact")
    )
    input_: capo_connect.types.start_assistant_contact_request.StartAssistantContactRequest = {
        "instance_id": instance_id,
        "ai_agent": ai_agent,
        "participant_details": participant_details,
    }
    if initial_message is not None:
        input_["initial_message"] = initial_message
    if attributes is not None:
        input_["attributes"] = attributes
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if persistent_chat is not None:
        input_["persistent_chat"] = persistent_chat
    if related_contact_id is not None:
        input_["related_contact_id"] = related_contact_id

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