Skip to content

get_recommendations async

get_recommendations(
    assistant_id: UuidOrArn,
    session_id: UuidOrArn,
    *,
    config_overrides: Optional[AsyncQConnectClientConfig] = None,
    max_results: Optional[MaxResults] = None,
    wait_time_seconds: Optional[WaitTimeSeconds] = None,
    next_chunk_token: Optional[NextToken] = None,
    recommendation_type: Optional[RecommendationType] = None,
) -> GetRecommendationsResponse

This API will be discontinued starting June 1, 2024. To receive generative responses after March 1, 2024, you will need to create a new Assistant in the Connect Customer console and integrate the Amazon Q in Connect JavaScript library (amazon-q-connectjs) into your applications.

Retrieves recommendations for the specified session. To avoid retrieving the same recommendations in subsequent calls, use NotifyRecommendationsReceived. This API supports long-polling behavior with the waitTimeSeconds parameter. Short poll is the default behavior and only returns recommendations already available. To perform a manual query against an assistant, use QueryAssistant.

Parameters:

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

  • session_id (UuidOrArn) –

    The identifier of the session. Can be either the ID or the ARN. URLs cannot contain the ARN.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of results to return per page.

  • wait_time_seconds (Optional[WaitTimeSeconds], default: None ) –

    The duration (in seconds) for which the call waits for a recommendation to be made available before returning. If a recommendation is available, the call returns sooner than WaitTimeSeconds. If no messages are available and the wait time expires, the call returns successfully with an empty list.

  • next_chunk_token (Optional[NextToken], default: None ) –

    The token for the next set of chunks. Use the value returned in the previous response in the next request to retrieve the next set of chunks.

  • recommendation_type (Optional[RecommendationType], default: None ) –

    The type of recommendation being requested.

Raises:

Source code in docs_src/capo_qconnect/_services/async_q_connect.py
async def get_recommendations(
    self,
    assistant_id: "capo_qconnect.types.uuid_or_arn.UuidOrArn",
    session_id: "capo_qconnect.types.uuid_or_arn.UuidOrArn",
    *,
    config_overrides: Optional[AsyncQConnectClientConfig] = None,
    max_results: Optional["capo_qconnect.types.max_results.MaxResults"] = None,
    wait_time_seconds: Optional[
        "capo_qconnect.types.wait_time_seconds.WaitTimeSeconds"
    ] = None,
    next_chunk_token: Optional["capo_qconnect.types.next_token.NextToken"] = None,
    recommendation_type: Optional[
        "capo_qconnect.types.recommendation_type.RecommendationType"
    ] = None,
) -> "capo_qconnect.types.get_recommendations_response.GetRecommendationsResponse":
    """<important> <p>This API will be discontinued starting June 1, 2024. To receive generative responses after March 1, 2024, you will need to create a new Assistant in the Connect Customer console and integrate the Amazon Q in Connect JavaScript library (amazon-q-connectjs) into your applications.</p> </important> <p>Retrieves recommendations for the specified session. To avoid retrieving the same recommendations in subsequent calls, use <a href="https://docs.aws.amazon.com/amazon-q-connect/latest/APIReference/API_NotifyRecommendationsReceived.html">NotifyRecommendationsReceived</a>. This API supports long-polling behavior with the <code>waitTimeSeconds</code> parameter. Short poll is the default behavior and only returns recommendations already available. To perform a manual query against an assistant, use <a href="https://docs.aws.amazon.com/amazon-q-connect/latest/APIReference/API_QueryAssistant.html">QueryAssistant</a>.</p>

    Args:
        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>
        session_id: <p>The identifier of the session. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
        max_results: <p>The maximum number of results to return per page.</p>
        wait_time_seconds: <p>The duration (in seconds) for which the call waits for a recommendation to be made available before returning. If a recommendation is available, the call returns sooner than <code>WaitTimeSeconds</code>. If no messages are available and the wait time expires, the call returns successfully with an empty list.</p>
        next_chunk_token: <p>The token for the next set of chunks. Use the value returned in the previous response in the next request to retrieve the next set of chunks.</p>
        recommendation_type: <p>The type of recommendation being requested.</p>

    Raises:
        capo_qconnect.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_qconnect.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_qconnect.types.get_recommendations_request.GetRecommendationsRequest]",
    ) -> AsyncOperationResponse[
        "capo_qconnect.types.get_recommendations_response.GetRecommendationsResponse"
    ]:
        import capo_qconnect._operations.wisdom_service.get_recommendations

        (
            output,
            http_response,
        ) = await capo_qconnect._operations.wisdom_service.get_recommendations.async_get_recommendations(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_qconnect.types.get_recommendations_response.GetRecommendationsResponse",
    ) -> dict[str, Any]:
        import capo_qconnect.types.get_recommendations_response

        return capo_qconnect.types.get_recommendations_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetRecommendations", redact_output=_redact_output),
    )
    input_: capo_qconnect.types.get_recommendations_request.GetRecommendationsRequest = {
        "assistant_id": assistant_id,
        "session_id": session_id,
    }
    if max_results is not None:
        input_["max_results"] = max_results
    if wait_time_seconds is not None:
        input_["wait_time_seconds"] = wait_time_seconds
    if next_chunk_token is not None:
        input_["next_chunk_token"] = next_chunk_token
    if recommendation_type is not None:
        input_["recommendation_type"] = recommendation_type

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