Skip to content

create_session

create_session(
    assistant_id: UuidOrArn,
    name: Name,
    *,
    config_overrides: Optional[QConnectClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    description: Optional[Description] = None,
    tags: Optional[Tags] = None,
    tag_filter: Optional[TagFilter] = None,
    ai_agent_configuration: Optional[AIAgentConfigurationMap] = None,
    contact_arn: Optional[GenericArn] = None,
    orchestrator_configuration_list: Optional[OrchestratorConfigurationList] = None,
    remove_orchestrator_configuration_list: Optional[bool] = None,
) -> CreateSessionResponse

Creates a session. A session is a contextual container used for generating recommendations. Connect Customer creates a new Amazon Q in Connect session for each contact on which Amazon Q in Connect is enabled.

Parameters:

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

  • assistant_id (UuidOrArn) –

    The identifier of the Amazon Q in Connect assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.

  • name (Name) –

    The name of the session.

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

    The description.

  • tags (Optional[Tags], default: None ) –

    The tags used to organize, track, or control access for this resource.

  • tag_filter (Optional[TagFilter], default: None ) –

    An object that can be used to specify Tag conditions.

  • ai_agent_configuration (Optional[AIAgentConfigurationMap], default: None ) –

    The configuration of the AI Agents (mapped by AI Agent Type to AI Agent version) that should be used by Amazon Q in Connect for this Session.

  • contact_arn (Optional[GenericArn], default: None ) –

    The Amazon Resource Name (ARN) of the email contact in Connect Customer. Used to retrieve email content and establish session context for AI-powered email assistance.

  • orchestrator_configuration_list (Optional[OrchestratorConfigurationList], default: None ) –

    The list of orchestrator configurations for the session being created.

  • remove_orchestrator_configuration_list (Optional[bool], default: None ) –

    The list of orchestrator configurations to remove from the session.

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.

  • ResourceNotFoundException –

    The specified resource does not exist.

  • UnauthorizedException –

    You do not have permission to perform this action.

  • 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 create_session(
    self,
    assistant_id: "capo_qconnect.types.uuid_or_arn.UuidOrArn",
    name: "capo_qconnect.types.name.Name",
    *,
    config_overrides: Optional[QConnectClientConfig] = None,
    client_token: Optional["capo_qconnect.types.client_token.ClientToken"] = None,
    description: Optional["capo_qconnect.types.description.Description"] = None,
    tags: Optional["capo_qconnect.types.tags.Tags"] = None,
    tag_filter: Optional["capo_qconnect.types.tag_filter.TagFilter"] = None,
    ai_agent_configuration: Optional[
        "capo_qconnect.types.ai_agent_configuration_map.AIAgentConfigurationMap"
    ] = None,
    contact_arn: Optional["capo_qconnect.types.generic_arn.GenericArn"] = None,
    orchestrator_configuration_list: Optional[
        "capo_qconnect.types.orchestrator_configuration_list.OrchestratorConfigurationList"
    ] = None,
    remove_orchestrator_configuration_list: Optional[bool] = None,
) -> "capo_qconnect.types.create_session_response.CreateSessionResponse":
    """<p>Creates a session. A session is a contextual container used for generating recommendations. Connect Customer creates a new Amazon Q in Connect session for each contact on which Amazon Q in Connect is enabled.</p>

    Args:
        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="http://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/">Making retries safe with idempotent APIs</a>.</p>
        assistant_id: <p>The identifier of the Amazon Q in Connect assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
        name: <p>The name of the session.</p>
        description: <p>The description.</p>
        tags: <p>The tags used to organize, track, or control access for this resource.</p>
        tag_filter: <p>An object that can be used to specify Tag conditions. </p>
        ai_agent_configuration: <p>The configuration of the AI Agents (mapped by AI Agent Type to AI Agent version) that should be used by Amazon Q in Connect for this Session.</p>
        contact_arn: <p>The Amazon Resource Name (ARN) of the email contact in Connect Customer. Used to retrieve email content and establish session context for AI-powered email assistance.</p>
        orchestrator_configuration_list: <p>The list of orchestrator configurations for the session being created.</p>
        remove_orchestrator_configuration_list: <p>The list of orchestrator configurations to remove from the session.</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.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_qconnect.errors.unauthorized_exception.UnauthorizedException: <p>You do not have permission to perform this action.</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.create_session_request.CreateSessionRequest]",
    ) -> OperationResponse[
        "capo_qconnect.types.create_session_response.CreateSessionResponse"
    ]:
        import capo_qconnect._operations.wisdom_service.create_session

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSession")
    )
    input_: capo_qconnect.types.create_session_request.CreateSessionRequest = {
        "assistant_id": assistant_id,
        "name": name,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags
    if tag_filter is not None:
        input_["tag_filter"] = tag_filter
    if ai_agent_configuration is not None:
        input_["ai_agent_configuration"] = ai_agent_configuration
    if contact_arn is not None:
        input_["contact_arn"] = contact_arn
    if orchestrator_configuration_list is not None:
        input_["orchestrator_configuration_list"] = orchestrator_configuration_list
    if remove_orchestrator_configuration_list is not None:
        input_["remove_orchestrator_configuration_list"] = (
            remove_orchestrator_configuration_list
        )

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