Skip to content

create_task_template async

create_task_template(
    instance_id: InstanceId,
    name: TaskTemplateName,
    fields: TaskTemplateFields,
    *,
    config_overrides: Optional[AsyncConnectClientConfig] = None,
    description: Optional[TaskTemplateDescription] = None,
    contact_flow_id: Optional[ContactFlowId] = None,
    self_assign_flow_id: Optional[ContactFlowId] = None,
    constraints: Optional[TaskTemplateConstraints] = None,
    defaults: Optional[TaskTemplateDefaults] = None,
    status: Optional[TaskTemplateStatus] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateTaskTemplateResponse

Creates a new task template in the specified Connect Customer instance.

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.

  • name (TaskTemplateName) –

    The name of the task template.

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

    The description of the task template.

  • contact_flow_id (Optional[ContactFlowId], default: None ) –

    The identifier of the flow that runs by default when a task is created by referencing this template.

    Although this parameter is marked as optional, the request must contain either a ContactFlowId or a field of type QUICK_CONNECT.

  • self_assign_flow_id (Optional[ContactFlowId], default: None ) –

    The ContactFlowId for the flow that will be run if this template is used to create a self-assigned task.

  • constraints (Optional[TaskTemplateConstraints], default: None ) –

    Constraints that are applicable to the fields listed. Although this parameter is marked as optional in the API model, the service requires it when calling CreateTaskTemplate or UpdateTaskTemplate. The RequiredFields array must contain at least one element, and the field of type NAME must be included in RequiredFields.

  • defaults (Optional[TaskTemplateDefaults], default: None ) –

    The default values for fields when a task is created by referencing this template.

  • status (Optional[TaskTemplateStatus], default: None ) –

    Marks a template as ACTIVE or INACTIVE for a task to refer to it. Tasks can only be created from ACTIVE templates. If a template is marked as INACTIVE, then a task that refers to this template cannot be created.

  • fields (TaskTemplateFields) –

    Fields that are part of the template.

    The request must contain exactly one field of type NAME. This field must also be listed in the RequiredFields array within the Constraints parameter.

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

Raises:

Source code in docs_src/capo_connect/_services/async_connect.py
async def create_task_template(
    self,
    instance_id: "capo_connect.types.instance_id.InstanceId",
    name: "capo_connect.types.task_template_name.TaskTemplateName",
    fields: "capo_connect.types.task_template_fields.TaskTemplateFields",
    *,
    config_overrides: Optional[AsyncConnectClientConfig] = None,
    description: Optional[
        "capo_connect.types.task_template_description.TaskTemplateDescription"
    ] = None,
    contact_flow_id: Optional[
        "capo_connect.types.contact_flow_id.ContactFlowId"
    ] = None,
    self_assign_flow_id: Optional[
        "capo_connect.types.contact_flow_id.ContactFlowId"
    ] = None,
    constraints: Optional[
        "capo_connect.types.task_template_constraints.TaskTemplateConstraints"
    ] = None,
    defaults: Optional[
        "capo_connect.types.task_template_defaults.TaskTemplateDefaults"
    ] = None,
    status: Optional[
        "capo_connect.types.task_template_status.TaskTemplateStatus"
    ] = None,
    client_token: Optional["capo_connect.types.client_token.ClientToken"] = None,
) -> "capo_connect.types.create_task_template_response.CreateTaskTemplateResponse":
    """<p>Creates a new task template in the specified Connect Customer instance.</p>

    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>
        name: <p>The name of the task template.</p>
        description: <p>The description of the task template.</p>
        contact_flow_id: <p>The identifier of the flow that runs by default when a task is created by referencing this template.</p> <p>Although this parameter is marked as optional, the request must contain either a <code>ContactFlowId</code> or a field of type <code>QUICK_CONNECT</code>.</p>
        self_assign_flow_id: <p>The ContactFlowId for the flow that will be run if this template is used to create a self-assigned task.</p>
        constraints: <p>Constraints that are applicable to the fields listed. Although this parameter is marked as optional in the API model, the service requires it when calling <code>CreateTaskTemplate</code> or <code>UpdateTaskTemplate</code>. The <code>RequiredFields</code> array must contain at least one element, and the field of type <code>NAME</code> must be included in <code>RequiredFields</code>.</p>
        defaults: <p>The default values for fields when a task is created by referencing this template.</p>
        status: <p>Marks a template as <code>ACTIVE</code> or <code>INACTIVE</code> for a task to refer to it. Tasks can only be created from <code>ACTIVE</code> templates. If a template is marked as <code>INACTIVE</code>, then a task that refers to this template cannot be created. </p>
        fields: <p>Fields that are part of the template.</p> <p>The request must contain exactly one field of type <code>NAME</code>. This field must also be listed in the <code>RequiredFields</code> array within the <code>Constraints</code> parameter.</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>

    Raises:
        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.property_validation_exception.PropertyValidationException: <p>The property is not valid.</p>
        capo_connect.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found.</p>
        capo_connect.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The service quota has been exceeded.</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.create_task_template_request.CreateTaskTemplateRequest]",
    ) -> AsyncOperationResponse[
        "capo_connect.types.create_task_template_response.CreateTaskTemplateResponse"
    ]:
        import capo_connect._operations.amazon_connect_service.create_task_template

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTaskTemplate")
    )
    input_: capo_connect.types.create_task_template_request.CreateTaskTemplateRequest = {
        "instance_id": instance_id,
        "name": name,
        "fields": fields,
    }
    if description is not None:
        input_["description"] = description
    if contact_flow_id is not None:
        input_["contact_flow_id"] = contact_flow_id
    if self_assign_flow_id is not None:
        input_["self_assign_flow_id"] = self_assign_flow_id
    if constraints is not None:
        input_["constraints"] = constraints
    if defaults is not None:
        input_["defaults"] = defaults
    if status is not None:
        input_["status"] = status
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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