What You’ll Build
A customer support agent that can:- Search a product knowledge base
- Look up order information
- Answer customer questions with context-aware responses
- Follow company guidelines and constraints
Prerequisites
Complete Example
Step-by-Step Walkthrough
Define Tool Functions
Create the functions that your agent will use to access data:
In production, these functions would connect to your actual databases and APIs.
Create the Agent Builder
Initialize the prompt builder and set the agent’s identity:The identity establishes who the agent is and what company it represents.
Define Capabilities
Specify what the agent can do:Capabilities help the agent understand its scope of responsibility.
Add Tools
Add the knowledge base search and order lookup tools:Each tool includes a Zod schema for type-safe parameters and an execute function.
Set Constraints
Define what the agent must and must not do:Constraints ensure the agent follows company policies and best practices.
Add Guardrails and Tone
Enable safety guardrails and set the communication style:Guardrails prevent harmful outputs, and tone ensures consistent communication.
Expected Output
When you run this example, you’ll see output similar to:Key Concepts
Tool Integration - This example shows how to integrate real data sources (knowledge base, order database) into your agent using tools with Zod schemas for type safety.
Constraints - The
must and must_not constraints ensure the agent follows company policies and maintains professional standards in all interactions.Production Patterns - The combination of guardrails, clear capabilities, and strict constraints makes this agent production-ready and safe for customer interactions.
Customization Ideas
- Add a
create_tickettool for escalating complex issues - Include a
check_inventorytool for product availability - Add constraints for handling refunds and exchanges
- Implement sentiment analysis to detect frustrated customers
- Add a
send_emailtool for follow-up communications
Next Steps
Multi-Tool Agent
Learn how to build agents with multiple specialized tools
Tools Guide
Deep dive into creating and using tools effectively