Use CreateAgentActionGroup with an AWS SDK or CLI - Amazon Bedrock

Use CreateAgentActionGroup with an AWS SDK or CLI

The following code example shows how to use CreateAgentActionGroup.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

Create an agent action group.

def create_agent_action_group( self, name, description, agent_id, agent_version, function_arn, api_schema ): """ Creates an action group for an agent. An action group defines a set of actions that an agent should carry out for the customer. :param name: The name to give the action group. :param description: The description of the action group. :param agent_id: The unique identifier of the agent for which to create the action group. :param agent_version: The version of the agent for which to create the action group. :param function_arn: The ARN of the Lambda function containing the business logic that is carried out upon invoking the action. :param api_schema: Contains the OpenAPI schema for the action group. :return: Details about the action group that was created. """ try: response = self.client.create_agent_action_group( actionGroupName=name, description=description, agentId=agent_id, agentVersion=agent_version, actionGroupExecutor={"lambda": function_arn}, apiSchema={"payload": api_schema}, ) agent_action_group = response["agentActionGroup"] except ClientError as e: logger.error(f"Error: Couldn't create agent action group. Here's why: {e}") raise else: return agent_action_group

For a complete list of AWS SDK developer guides and code examples, see Using this service with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.