Skip to content

send_message

send_message(
    assistant_id: UuidOrArn,
    session_id: UuidOrArn,
    type: MessageType,
    message: MessageInput,
    *,
    config_overrides: Optional[QConnectClientConfig] = None,
    ai_agent_id: Optional[UuidOrArnOrEitherWithQualifier] = None,
    conversation_context: Optional[ConversationContext] = None,
    configuration: Optional[MessageConfiguration] = None,
    client_token: Optional[ClientToken] = None,
    orchestrator_use_case: Optional[NonEmptyString] = None,
    metadata: Optional[MessageMetadata] = None,
    origin_request_id: Optional[NonEmptyString] = None,
) -> SendMessageResponse

Submits a message to the Amazon Q in Connect session.

Parameters:

  • assistant_id (UuidOrArn) –

    The identifier of the Amazon Q in Connect assistant.

  • session_id (UuidOrArn) –

    The identifier of the Amazon Q in Connect session.

  • type (MessageType) –

    The message type.

  • message (MessageInput) –

    The message data to submit to the Amazon Q in Connect session.

  • ai_agent_id (Optional[UuidOrArnOrEitherWithQualifier], default: None ) –

    The identifier of the AI Agent to use for processing the message.

  • conversation_context (Optional[ConversationContext], default: None ) –

    The conversation context before the Amazon Q in Connect session.

  • configuration (Optional[MessageConfiguration], default: None ) –

    The configuration of the SendMessage request.

  • 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 AWS SDK populates this field.For more information about idempotency, see Making retries safe with idempotent APIs.

  • orchestrator_use_case (Optional[NonEmptyString], default: None ) –

    The orchestrator use case for message processing.

  • metadata (Optional[MessageMetadata], default: None ) –

    Additional metadata for the message.

  • origin_request_id (Optional[NonEmptyString], default: None ) –

    Request identifier from the origin system, used for end-to-end tracing across spans.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

  • ConflictException –

    The request could not be processed because of conflict in the current state of the resource. For example, if you're using a Create API (such as CreateAssistant) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.

  • DependencyFailedException –

    The request failed because it depends on another request that failed.

  • RequestTimeoutException –

    The request reached the service more than 15 minutes after the date stamp on the request or more than 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp on the request is more than 15 minutes in the future.

  • ResourceNotFoundException –

    The specified resource does not exist.

  • ServiceQuotaExceededException –

    You've exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use service quotas to request a service quota increase.

  • ThrottlingException –

    The throttling limit has been exceeded.

  • ValidationException –

    The input fails to satisfy the constraints specified by a service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_qconnect/_services/q_connect.py
def send_message(
    self,
    assistant_id: "capo_qconnect.types.uuid_or_arn.UuidOrArn",
    session_id: "capo_qconnect.types.uuid_or_arn.UuidOrArn",
    type: "capo_qconnect.types.message_type.MessageType",
    message: "capo_qconnect.types.message_input.MessageInput",
    *,
    config_overrides: Optional[QConnectClientConfig] = None,
    ai_agent_id: Optional[
        "capo_qconnect.types.uuid_or_arn_or_either_with_qualifier.UuidOrArnOrEitherWithQualifier"
    ] = None,
    conversation_context: Optional[
        "capo_qconnect.types.conversation_context.ConversationContext"
    ] = None,
    configuration: Optional[
        "capo_qconnect.types.message_configuration.MessageConfiguration"
    ] = None,
    client_token: Optional["capo_qconnect.types.client_token.ClientToken"] = None,
    orchestrator_use_case: Optional[
        "capo_qconnect.types.non_empty_string.NonEmptyString"
    ] = None,
    metadata: Optional[
        "capo_qconnect.types.message_metadata.MessageMetadata"
    ] = None,
    origin_request_id: Optional[
        "capo_qconnect.types.non_empty_string.NonEmptyString"
    ] = None,
) -> "capo_qconnect.types.send_message_response.SendMessageResponse":
    """<p>Submits a message to the Amazon Q in Connect session.</p>

    Args:
        assistant_id: <p>The identifier of the Amazon Q in Connect assistant.</p>
        session_id: <p>The identifier of the Amazon Q in Connect session.</p>
        type: <p>The message type.</p>
        message: <p>The message data to submit to the Amazon Q in Connect session.</p>
        ai_agent_id: <p>The identifier of the AI Agent to use for processing the message.</p>
        conversation_context: <p>The conversation context before the Amazon Q in Connect session.</p>
        configuration: <p>The configuration of the <a href="https://docs.aws.amazon.com/connect/latest/APIReference/API_amazon-q-connect_SendMessage.html">SendMessage</a> request.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the AWS SDK populates this field.For more information about idempotency, see Making retries safe with idempotent APIs.</p>
        orchestrator_use_case: <p>The orchestrator use case for message processing.</p>
        metadata: <p>Additional metadata for the message.</p>
        origin_request_id: <p>Request identifier from the origin system, used for end-to-end tracing across spans.</p>

    Raises:
        capo_qconnect.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_qconnect.errors.conflict_exception.ConflictException: <p>The request could not be processed because of conflict in the current state of the resource. For example, if you're using a <code>Create</code> API (such as <code>CreateAssistant</code>) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.</p>
        capo_qconnect.errors.dependency_failed_exception.DependencyFailedException: <p>The request failed because it depends on another request that failed.</p>
        capo_qconnect.errors.request_timeout_exception.RequestTimeoutException: <p>The request reached the service more than 15 minutes after the date stamp on the request or more than 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp on the request is more than 15 minutes in the future.</p>
        capo_qconnect.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_qconnect.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You've exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use service quotas to request a service quota increase.</p>
        capo_qconnect.errors.throttling_exception.ThrottlingException: <p>The throttling limit has been exceeded.</p>
        capo_qconnect.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by a service.</p>
        capo_qconnect.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_qconnect.types.send_message_request.SendMessageRequest]",
    ) -> OperationResponse[
        "capo_qconnect.types.send_message_response.SendMessageResponse"
    ]:
        import capo_qconnect._operations.wisdom_service.send_message

        output, http_response = (
            capo_qconnect._operations.wisdom_service.send_message.send_message(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_qconnect.types.send_message_request.SendMessageRequest",
    ) -> dict[str, Any]:
        import capo_qconnect.types.send_message_request

        return capo_qconnect.types.send_message_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("SendMessage", redact_input=_redact_input),
    )
    input_: capo_qconnect.types.send_message_request.SendMessageRequest = {
        "assistant_id": assistant_id,
        "session_id": session_id,
        "type": type,
        "message": message,
    }
    if ai_agent_id is not None:
        input_["ai_agent_id"] = ai_agent_id
    if conversation_context is not None:
        input_["conversation_context"] = conversation_context
    if configuration is not None:
        input_["configuration"] = configuration
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if orchestrator_use_case is not None:
        input_["orchestrator_use_case"] = orchestrator_use_case
    if metadata is not None:
        input_["metadata"] = metadata
    if origin_request_id is not None:
        input_["origin_request_id"] = origin_request_id

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output