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:
-
ConflictException–There was an issue processing your request.
-
InternalServiceError–Unexpected error during processing of request.
-
InvalidRequestException–Your request input doesn't meet the constraints required by AWS Chatbot.
-
LimitExceededException–You have exceeded a service limit for AWS Chatbot.
-
UnauthorizedException–The request was rejected because it doesn't have valid credentials for the target resource.
-
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'}])
Source code in docs_src/capo_chatbot/_services/async_chatbot.py
2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 | |