Skip to content

render_message_template async

render_message_template(
    knowledge_base_id: UuidOrArn,
    message_template_id: UuidOrArnOrEitherWithQualifier,
    attributes: MessageTemplateAttributes,
    *,
    config_overrides: Optional[AsyncQConnectClientConfig] = None,
) -> RenderMessageTemplateResponse

Renders the Amazon Q in Connect message template based on the attribute values provided and generates the message content. For any variable present in the message template, if the attribute value is neither provided in the attribute request parameter nor the default attribute of the message template, the rendered message content will keep the variable placeholder as it is and return the attribute keys that are missing.

Parameters:

  • knowledge_base_id (UuidOrArn) –

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

  • message_template_id (UuidOrArnOrEitherWithQualifier) –

    The identifier of the message template. Can be either the ID or the ARN.

  • attributes (MessageTemplateAttributes) –

    An object that specifies the values to use for variables in the message template. This object contains different categories of key-value pairs. Each key defines a variable or placeholder in the message template. The corresponding value defines the value for that variable.

Raises:

Source code in docs_src/capo_qconnect/_services/async_q_connect.py
async def render_message_template(
    self,
    knowledge_base_id: "capo_qconnect.types.uuid_or_arn.UuidOrArn",
    message_template_id: "capo_qconnect.types.uuid_or_arn_or_either_with_qualifier.UuidOrArnOrEitherWithQualifier",
    attributes: "capo_qconnect.types.message_template_attributes.MessageTemplateAttributes",
    *,
    config_overrides: Optional[AsyncQConnectClientConfig] = None,
) -> "capo_qconnect.types.render_message_template_response.RenderMessageTemplateResponse":
    """<p>Renders the Amazon Q in Connect message template based on the attribute values provided and generates the message content. For any variable present in the message template, if the attribute value is neither provided in the attribute request parameter nor the default attribute of the message template, the rendered message content will keep the variable placeholder as it is and return the attribute keys that are missing.</p>

    Args:
        knowledge_base_id: <p>The identifier of the knowledge base. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
        message_template_id: <p>The identifier of the message template. Can be either the ID or the ARN.</p>
        attributes: <p>An object that specifies the values to use for variables in the message template. This object contains different categories of key-value pairs. Each key defines a variable or placeholder in the message template. The corresponding value defines the value for that variable.</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.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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_qconnect.types.render_message_template_request.RenderMessageTemplateRequest]",
    ) -> AsyncOperationResponse[
        "capo_qconnect.types.render_message_template_response.RenderMessageTemplateResponse"
    ]:
        import capo_qconnect._operations.wisdom_service.render_message_template

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

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

        return capo_qconnect.types.render_message_template_request.redact_sensitive(
            input_
        )

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

        return (
            capo_qconnect.types.render_message_template_response.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "RenderMessageTemplate",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_qconnect.types.render_message_template_request.RenderMessageTemplateRequest = {
        "knowledge_base_id": knowledge_base_id,
        "message_template_id": message_template_id,
        "attributes": attributes,
    }

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