Skip to content

create_custom_action async

create_custom_action(
    definition: CustomActionDefinition,
    action_name: CustomActionName,
    *,
    config_overrides: Optional[AsyncchatbotClientConfig] = None,
    alias_name: Optional[CustomActionAliasName] = None,
    attachments: Optional[CustomActionAttachmentList] = None,
    tags: Optional[TagList] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateCustomActionResult

Creates a custom action that can be invoked as an alias or as a button on a notification.

Parameters:

  • definition (CustomActionDefinition) –

    The definition of the command to run when invoked as an alias or as an action button.

  • alias_name (Optional[CustomActionAliasName], default: None ) –

    The name used to invoke this action in a chat channel. For example, @aws run my-alias.

  • attachments (Optional[CustomActionAttachmentList], default: None ) –

    Defines when this custom action button should be attached to a notification.

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

    A map of tags assigned to a resource. A tag is a string-to-string map of key-value pairs.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency ensures that an API request completes only once. With an idempotent request, if the original request completes successfully, subsequent retries with the same client token returns the result from the original successful request.

    If you do not specify a client token, one is automatically generated by the SDK.

  • action_name (CustomActionName) –

    The name of the custom action. This name is included in the Amazon Resource Name (ARN).

Raises:

Examples:

Create an alias that invokes a Lambda function Creates an alias that invokes a Lambda function from chat channels. You can use this alias by entering 'run invoke', after which you're prompted for the function name.

>>> await client.create_custom_action(action_name='my-custom-action', definition={'CommandText': 'lambda invoke $functionName'}, alias_name='invoke')
Create a custom action to list alarms
Creates a button on all Cloudwatch notifications that lists alarms in the ‘ALARM’ state.
>>> await client.create_custom_action(action_name='describe-alarms', definition={'CommandText': 'cloudwatch describe-alarms --state-value ALARM'}, attachments=[{'NotificationType': 'CloudWatch', 'ButtonText': 'List alarms'}])
Source code in docs_src/capo_chatbot/_services/async_chatbot.py
async def create_custom_action(
    self,
    definition: "capo_chatbot.types.custom_action_definition.CustomActionDefinition",
    action_name: "capo_chatbot.types.custom_action_name.CustomActionName",
    *,
    config_overrides: Optional[AsyncchatbotClientConfig] = None,
    alias_name: Optional[
        "capo_chatbot.types.custom_action_alias_name.CustomActionAliasName"
    ] = None,
    attachments: Optional[
        "capo_chatbot.types.custom_action_attachment_list.CustomActionAttachmentList"
    ] = None,
    tags: Optional["capo_chatbot.types.tag_list.TagList"] = None,
    client_token: Optional["capo_chatbot.types.client_token.ClientToken"] = None,
) -> "capo_chatbot.types.create_custom_action_result.CreateCustomActionResult":
    """<p>Creates a custom action that can be invoked as an alias or as a button on a notification.</p>

    Args:
        definition: <p>The definition of the command to run when invoked as an alias or as an action button.</p>
        alias_name: <p>The name used to invoke this action in a chat channel. For example, <code>@aws run my-alias</code>.</p>
        attachments: <p>Defines when this custom action button should be attached to a notification.</p>
        tags: <p>A map of tags assigned to a resource. A tag is a string-to-string map of key-value pairs.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency ensures that an API request completes only once. With an idempotent request, if the original request completes successfully, subsequent retries with the same client token returns the result from the original successful request.</p> <p>If you do not specify a client token, one is automatically generated by the SDK.</p>
        action_name: <p>The name of the custom action. This name is included in the Amazon Resource Name (ARN).</p>

    Raises:
        capo_chatbot.errors.conflict_exception.ConflictException: <p>There was an issue processing your request.</p>
        capo_chatbot.errors.internal_service_error.InternalServiceError: <p>Unexpected error during processing of request.</p>
        capo_chatbot.errors.invalid_request_exception.InvalidRequestException: <p>Your request input doesn't meet the constraints required by AWS Chatbot.</p>
        capo_chatbot.errors.limit_exceeded_exception.LimitExceededException: <p>You have exceeded a service limit for AWS Chatbot.</p>
        capo_chatbot.errors.unauthorized_exception.UnauthorizedException: <p>The request was rejected because it doesn't have valid credentials for the target resource.</p>
        capo_chatbot.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Create an alias that invokes a Lambda function
        Creates an alias that invokes a Lambda function from chat channels. You can use this alias by entering 'run invoke', after which you're prompted for the function name.

        >>> await client.create_custom_action(action_name='my-custom-action', definition={'CommandText': 'lambda invoke $functionName'}, alias_name='invoke')
        Create a custom action to list alarms
        Creates a button on all Cloudwatch notifications that lists alarms in the ‘ALARM’ state.

        >>> await client.create_custom_action(action_name='describe-alarms', definition={'CommandText': 'cloudwatch describe-alarms --state-value ALARM'}, attachments=[{'NotificationType': 'CloudWatch', 'ButtonText': 'List alarms'}])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_chatbot.types.create_custom_action_request.CreateCustomActionRequest]",
    ) -> AsyncOperationResponse[
        "capo_chatbot.types.create_custom_action_result.CreateCustomActionResult"
    ]:
        import capo_chatbot._operations.wheatley_orchestration_20171011.create_custom_action

        (
            output,
            http_response,
        ) = await capo_chatbot._operations.wheatley_orchestration_20171011.create_custom_action.async_create_custom_action(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateCustomAction")
    )
    input_: capo_chatbot.types.create_custom_action_request.CreateCustomActionRequest = {
        "definition": definition,
        "action_name": action_name,
    }
    if alias_name is not None:
        input_["alias_name"] = alias_name
    if attachments is not None:
        input_["attachments"] = attachments
    if tags is not None:
        input_["tags"] = tags
    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