100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.
feat: add customer support ticketing agent tutorial with structured output
ShubhamSaboo5bb3905df831
diff --git a/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/README.md b/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/README.mdnew file mode 100644index 00000000..abf5ad55--- /dev/null+++ b/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/README.md@@ -0,0 +1,110 @@+# π« Customer Support Ticketing Agent with Structured Output++A tutorial demonstrating how to implement a structured customer support ticketing system using Google's ADK (Agent Development Kit) framework. This example shows how to create type-safe, structured support tickets with priority levels, categories, and resolution estimates using Pydantic schemas and Gemini 2.0 Flash model.++## Tutorial Features++- π« **Structured Support Tickets**:+ - Learn how to create comprehensive support ticket schemas+ - Understand priority levels and categorization+ - See how to estimate resolution times++- π§ **Advanced Schema Design**:+ - Complex Pydantic models with enums and optional fields+ - Proper field validation and descriptions+ - Type-safe structured responses++- π― **Real-World Application**:+ - Practical customer support use case+ - Shows how to handle different types of support requests+ - Demonstrates structured output for business processes++- π **Priority Management**:+ - Four-tier priority system (Low, Medium, High, Critical)+ - Automatic priority assignment based on issue description+ - Category-based routing for different departments++## How to Run++1. **Setup Environment**+ ```bash+ # Clone the repository+ git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git+ cd awesome-llm-apps/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent++ # Install dependencies+ pip install -r requirements.txt+ ```++2. **Configure API Keys**+ - Get Google AI API key from [Google AI Studio](https://aistudio.google.com/)+ - Set up your API credentials for Gemini access++3. **Run the Agent**+ ```bash+ # Start the ADK web interface from the root folder+ cd google_adk_tutorials/structured_output_agent/customer_support_ticket_agent+ adk web+ ```+ Then:+ 1. Open the web interface in your browser+ 2. Select the "support_ticket_creator" agent+ 3. Enter your support request (e.g., "I can't log into my account and I have an important meeting in 2 hours")+ 4. The response will be a structured JSON with all ticket details++## Tutorial Overview++This tutorial demonstrates advanced structured output implementation in Google ADK:++1. **Complex Schema Design**: Learn how to create sophisticated Pydantic models+2. **Enum Usage**: Understand how to use enums for constrained values+3. **Optional Fields**: See how to handle optional data with proper defaults+4. **Business Logic**: Learn how to implement real-world business processes++## Code Structure++- `customer_support_agent/agent.py`: Contains the main agent definition and SupportTicket schema+- `customer_support_agent/__init__.py`: Module initialization for easy imports++## Support Ticket Schema++The agent creates structured tickets with the following fields:++- **title**: Concise summary of the issue+- **description**: Detailed problem description+- **priority**: Priority level (low, medium, high, critical)+- **category**: Department (Technical, Billing, Account, Product)+- **steps_to_reproduce**: Optional list of steps for technical issues+- **estimated_resolution_time**: Estimated time to resolve++## Example Usage++**Input**: "My payment failed and I'm getting charged twice for the same service"++**Output**:+```json+{+ "title": "Duplicate payment charge issue",+ "description": "Customer reports payment failure followed by duplicate charges for the same service",+ "priority": "high",+ "category": "Billing",+ "steps_to_reproduce": null,+ "estimated_resolution_time": "4-6 hours"+}+```++## Dependencies++- `google-adk`: Google's Agent Development Kit+- `pydantic`: Data validation and settings management++## How Structured Output Works++This tutorial shows how Google ADK handles complex structured output:++1. **Input Processing**: Takes natural language support requests+2. **Context Analysis**: Analyzes the issue severity and type+3. **Structured Generation**: Creates comprehensive tickets with all required fields+4. **Validation**: Ensures output matches the defined schema and business rules++This approach demonstrates how to create reliable, business-ready structured responses in Google ADK applications.\ No newline at end of filediff --git a/google_adk_tutorials/structured_output_agent/email_generator_agent/.env.example b/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/customer_support_agent/.env.examplesimilarity index 100%rename from google_adk_tutorials/structured_output_agent/email_generator_agent/.env.examplerename to google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/customer_support_agent/.env.examplediff --git a/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/customer_support_agent/__init__.py b/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/customer_support_agent/__init__.pynew file mode 100644index 00000000..c4be8e1b--- /dev/null+++ b/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/customer_support_agent/__init__.py@@ -0,0 +1 @@+from . import agent\ No newline at end of filediff --git a/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/customer_support_agent/agent.py b/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/customer_support_agent/agent.pynew file mode 100644index 00000000..3896d2b8--- /dev/null+++ b/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/customer_support_agent/agent.py@@ -0,0 +1,46 @@+from typing import List, Optional+from enum import Enum+from google.adk.agents import LlmAgent+from pydantic import BaseModel, Field++class Priority(str, Enum):+ LOW = "low"+ MEDIUM = "medium"+ HIGH = "high"+ CRITICAL = "critical"++class SupportTicket(BaseModel):+ title: str = Field(description="A concise summary of the issue")+ description: str = Field(description="Detailed description of the problem")+ priority: Priority = Field(description="The ticket priority level")+ category: str = Field(description="The department this ticket belongs to")+ steps_to_reproduce: Optional[List[str]] = Field(+ description="Steps to reproduce the issue (for technical problems)",+ default=None+ )+ estimated_resolution_time: str = Field(+ description="Estimated time to resolve this issue"+ )++root_agent = LlmAgent(+ name="customer_support_agent",+ model="gemini-2.5-flash",+ description="Creates structured support tickets from user reports",+ instruction="""+ You are a support ticket creation assistant.++ Based on user problem descriptions, create well-structured support tickets with appropriate priority levels, categories, and resolution estimates.++ IMPORTANT: Response must be valid JSON matching the SupportTicket schema with these fields:+ - "title": Concise summary of the issue+ - "description": Detailed problem description+ - "priority": One of "low", "medium", "high", or "critical"+ - "category": Department (e.g., "Technical", "Billing", "Account", "Product")+ - "steps_to_reproduce": List of steps (for technical issues) or null+ - "estimated_resolution_time": Estimated resolution time (e.g., "2-4 hours", "1-2 days")++ Format your response as valid JSON only.+ """,+ output_schema=SupportTicket,+ output_key="support_ticket"+)\ No newline at end of filediff --git a/google_adk_tutorials/structured_output_agent/requirements.txt b/google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/requirements.txtsimilarity index 100%rename from google_adk_tutorials/structured_output_agent/requirements.txtrename to google_adk_tutorials/structured_output_agent/customer_support_ticket_agent/requirements.txtdiff --git a/google_adk_tutorials/structured_output_agent/README.md b/google_adk_tutorials/structured_output_agent/email_agent/README.mdsimilarity index 94%rename from google_adk_tutorials/structured_output_agent/README.mdrename to google_adk_tutorials/structured_output_agent/email_agent/README.mdindex a1fcafe7..e79ee2d1 100644--- a/google_adk_tutorials/structured_output_agent/README.md+++ b/google_adk_tutorials/structured_output_agent/email_agent/README.md@@ -1,4 +1,4 @@-# π§ Structured Output in Google ADK+# π§ Email Generation Agent with Structured OutputA tutorial demonstrating how to implement structured output using Google's ADK (Agent Development Kit) framework. This example uses an email generator agent to show how to create type-safe, structured responses with Pydantic schemas and Gemini 2.5 Flash model.@@ -25,7 +25,7 @@ A tutorial demonstrating how to implement structured output using Google's ADK (```bash# Clone the repositorygit clone https://github.com/Shubhamsaboo/awesome-llm-apps.git- cd awesome-llm-apps/google_adk_tutorials/structured_output_agent/email_generator_agent+ cd awesome-llm-apps/google_adk_tutorials/structured_output_agent/email_agent# Install dependenciespip install -r requirements.txt@@ -38,7 +38,7 @@ A tutorial demonstrating how to implement structured output using Google's ADK (3. **Run the Agent**```bash# Start the ADK web interface from the root folder- cd google_adk_tutorials/structured_output_agent+ cd google_adk_tutorials/structured_output_agent/email_agentadk web```Then:diff --git a/google_adk_tutorials/structured_output_agent/email_agent/email_generator_agent/.env.example b/google_adk_tutorials/structured_output_agent/email_agent/email_generator_agent/.env.examplenew file mode 100644index 00000000..f5cfcfb4--- /dev/null+++ b/google_adk_tutorials/structured_output_agent/email_agent/email_generator_agent/.env.example@@ -0,0 +1,3 @@+# If using Gemini via Google AI Studio+GOOGLE_GENAI_USE_VERTEXAI=False+GOOGLE_API_KEY="your-api-key"\ No newline at end of filediff --git a/google_adk_tutorials/structured_output_agent/email_generator_agent/__init__.py b/google_adk_tutorials/structured_output_agent/email_agent/email_generator_agent/__init__.pysimilarity index 100%rename from google_adk_tutorials/structured_output_agent/email_generator_agent/__init__.pyrename to google_adk_tutorials/structured_output_agent/email_agent/email_generator_agent/__init__.pydiff --git a/google_adk_tutorials/structured_output_agent/email_generator_agent/agent.py b/google_adk_tutorials/structured_output_agent/email_agent/email_generator_agent/agent.pysimilarity index 100%rename from google_adk_tutorials/structured_output_agent/email_generator_agent/agent.pyrename to google_adk_tutorials/structured_output_agent/email_agent/email_generator_agent/agent.pydiff --git a/google_adk_tutorials/structured_output_agent/email_agent/requirements.txt b/google_adk_tutorials/structured_output_agent/email_agent/requirements.txtnew file mode 100644index 00000000..53c77a25--- /dev/null+++ b/google_adk_tutorials/structured_output_agent/email_agent/requirements.txt@@ -0,0 +1,2 @@+google-adk>=1.5.0+pydantic>=2.0.0\ No newline at end of file