Introduction
Strands Agents is an open-source SDK that simplifies the development of AI agents capable of using tools, making decisions, and automating workflows — moving far beyond basic chatbot interactions.
In this article, you'll learn how to build an Agentic AI Assistant using the Strands Agents SDK, integrated with Amazon DynamoDB, to manage support tickets. The assistant will support ticket creation, updates, and retrieval in real time. In this example, you'll build an AI agent that can:
- Create a new ticket and store the details in Amazon DynamoDB table.
- Retrieve and update the ticket details in the Amazon DynamoDB table.
We’ll use Strands Agents SDK to define this agent and leverage the @tool decorator approach to define tools that securely connect to DynamoDB.
Note: The default model provider is Amazon Bedrock, and the default model is Claude 3.7 Sonnet in the US Oregon (us-west-2) region.
Prerequisites
- Install or update to the latest version of the AWS CLI.
- Get credentials to grant programmatic access.
- Visual Studio Code.
- Access to Amazon Bedrock foundation model. The default model provider is Amazon Bedroc,k and the default model is Claude 3.7 Sonnet in the US Oregon (us-west-2) region.
- Create a table in Amazon DynamoDB named “support_tickets”, with “ticket_id” as the primary key.
Create an agent using Strands Agents SDK
Perform the following steps to create and configure an agent using Strands Agents SDK.
- Open Visual Studio Code.
- Navigate to the folder where you want to create your Python file.
- Open a new PowerShell terminal in Visual Studio Code.
- Run the following command to create a virtual environment.
python -m venv .venv
- Run the following command to activate the virtual environment.
.venv\Scripts\Activate.ps1
- Run the following command to install the strands-agents SDK package.
pip install strands-agents
- Create a new Python file and name it as support_ticket_agent.py.
- Copy and paste the below code to support_ticket_agent.py.
import os
import boto3
import uuid
from strands import Agent, tool
# Set DynamoDB table name as environment variable
os.environ["TABLE_NAME"] = "support-tickets"
# Ticket ID for demo purpose
ticket_id = "a7954d69"
# Tool to create a support ticket
@tool
def create_ticket(title: str, description: str, priority: str, contact_email: str) -> dict:
table_name = os.environ["TABLE_NAME"]
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table(table_name)
ticket_id = str(uuid.uuid4())[:8]
item = {
"ticket_id": ticket_id,
"title": title,
"description": description,
"priority": priority,
"contact_email": contact_email,
"status": "New"
}
try:
table.put_item(Item=item)
return {"ticket_id": ticket_id, "message": "Ticket created successfully."}
except Exception as e:
return {"error": str(e)}
# Tool to update the ticket status
@tool
def update_ticket_status(ticket_id: str, new_status: str) -> str:
table_name = os.environ["TABLE_NAME"]
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table(table_name)
try:
table.update_item(
Key={"ticket_id": ticket_id},
UpdateExpression="SET #s = :val",
ExpressionAttributeNames={"#s": "status"},
ExpressionAttributeValues={":val": new_status}
)
return f"Ticket {ticket_id} status updated to {new_status}."
except Exception as e:
return str(e)
# Tool to get the ticket status
@tool
def get_ticket_status(ticket_id: str) -> str:
table_name = os.environ["TABLE_NAME"]
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table(table_name)
try:
response = table.get_item(Key={"ticket_id": ticket_id})
if "Item" in response:
status = response["Item"].get("status", "Unknown")
return f"Status of ticket {ticket_id} is: {status}."
else:
return f"Ticket ID {ticket_id} not found."
except Exception as e:
return str(e)
# System prompt
system_prompt = """
You are \"Agentic Support AI\", a helpful assistant managing IT support tickets.
You can create new tickets, update their statuses, check ticket status, and provide confirmations.
Always begin your replies with \"Agentic Support AI\".
If required data is missing, politely ask the user for clarification.
"""
# Create the agent
agent = Agent(
tools=[create_ticket, update_ticket_status, get_ticket_status],
system_prompt=system_prompt
)
# Demo: Create a new ticket
create_response = agent("""
My VPN is not working. Mark it as high priority. Email is [email protected].
""")
print(create_response)
- Run the following command to execute your Python code.
python -u .\support_ticket_agent.py
- Get ticket status:
# Demo: Get ticket status
status_response = agent(f"""
Can you tell me the current status of ticket ID {ticket_id}?
""")
print(status_response)
- Update the ticket status:
# Demo: Update the ticket status
update_response = agent(f"""
The issue is resolved. Please close ticket ID {ticket_id}.
""")
print(update_response)
Summary
This article walked you through creating and configuring an agentic AI support assistant to connect to Amazon DynamoDB using Strands Agents SDK. You created tools to manage support tickets — enabling creation, updates, and retrieval using natural language.
Next Steps
- Extend your agent to integrate with communication channels such as Slack or Teams for automated notifications.
- Deploy the agent using AWS Lambda or Fargate for production use.