GETTING STARTED
Your First Agent
This tutorial guides you through building a complete customer support agent with tools, memory, and deployment. By the end, you will have a production-ready agent handling real conversations.
1. Choose an Agent Type
Start by deciding what your agent will do. The SDK provides 8 pre-built templates, but you can also create a fully custom agent. For this tutorial, we will build a Customer Support agent.
Choose your template
// Using a pre-built template
const agent = await client.agents.create({
name: "Acme Support",
template: "customer-support", // pre-configured defaults
model: "claude-sonnet-4-20250514",
});
// Or start from scratch
const customAgent = await client.agents.create({
name: "Acme Support",
model: "claude-sonnet-4-20250514",
systemPrompt: "...", // full control
});
Note
Templates provide sensible defaults for system prompts, temperature, and token limits. You can override any setting after creation.
2. Write a System Prompt
The system prompt defines your agent's personality, knowledge, and behavioral constraints. A well-crafted prompt is the single most important factor in agent quality.
System prompt example
const systemPrompt = `You are a customer support agent for Acme Corp,
an e-commerce company selling electronics.
## Your Role
- Help customers with orders, returns, and product questions
- Be concise, friendly, and professional
- Always verify the customer's identity before sharing order details
## Rules
- Never share internal pricing or inventory data
- Escalate to a human agent for: refunds over $500, legal issues, complaints
- Always confirm actions before executing them
- If unsure, say so rather than guessing
## Tone
- Professional but warm
- Use the customer's name when known
- Keep responses under 200 words unless detail is needed`;
Tips for effective system prompts:
- -Be specific about the agent's role, company, and domain
- -Include clear boundaries -- what the agent should and should not do
- -Define escalation criteria for edge cases
- -Specify the desired tone and response length
3. Configure Parameters
Fine-tune how your agent generates responses:
Parameters
const agent = await client.agents.create({
name: "Acme Support",
model: "claude-sonnet-4-20250514",
systemPrompt: systemPrompt,
parameters: {
temperature: 0.3, // lower = more consistent
maxTokens: 1024, // max response length
topP: 0.9, // nucleus sampling
stopSequences: ["END"], // stop generation triggers
},
memory: {
enabled: true, // persist conversation history
maxTurns: 50, // remember last 50 exchanges
summarize: true, // auto-summarize old turns
},
metadata: {
team: "support",
version: "1.0",
environment: "production",
},
});
4. Add Custom Tools
Tools give your agent the ability to take actions. Here is a complete example with three tools for a support agent:
Full tools setup
const agent = await client.agents.create({
name: "Acme Support",
model: "claude-sonnet-4-20250514",
systemPrompt: systemPrompt,
tools: [
{
name: "lookup_order",
description: "Retrieve order details by order ID or email",
parameters: {
type: "object",
properties: {
orderId: { type: "string", description: "Order ID like ORD-12345" },
email: { type: "string", format: "email" },
},
},
handler: "https://api.acme.com/webhooks/orders/lookup",
},
{
name: "initiate_return",
description: "Start a return process for an order item",
parameters: {
type: "object",
properties: {
orderId: { type: "string" },
itemId: { type: "string" },
reason: {
type: "string",
enum: ["defective", "wrong_item", "not_as_described", "changed_mind"],
},
},
required: ["orderId", "itemId", "reason"],
},
handler: "https://api.acme.com/webhooks/returns/initiate",
},
{
name: "escalate_to_human",
description: "Transfer the conversation to a human agent",
parameters: {
type: "object",
properties: {
reason: { type: "string" },
priority: { type: "string", enum: ["normal", "urgent"] },
},
required: ["reason"],
},
handler: "https://api.acme.com/webhooks/escalate",
},
],
});
5. Test Your Agent
Before deploying, test your agent with various scenarios:
Test scenarios
// Test basic greeting
const r1 = await client.agents.execute(agent.id, {
input: "Hi, I need help with an order",
});
console.log("Greeting:", r1.output);
// Test tool usage
const r2 = await client.agents.execute(agent.id, {
input: "Can you look up order ORD-48211?",
conversationId: r1.conversationId,
});
console.log("Tool call:", r2.toolCalls);
console.log("Response:", r2.output);
// Test edge case - escalation
const r3 = await client.agents.execute(agent.id, {
input: "I want to speak to a manager about a legal issue",
});
console.log("Escalation:", r3.output);
console.log("Escalated:", r3.toolCalls.some(t => t.name === "escalate_to_human"));
6. Deploy to Production
Once testing is complete, deploy your agent:
Deploy
// Update the agent status
await client.agents.update(agent.id, {
status: "active",
metadata: {
...agent.metadata,
deployedAt: new Date().toISOString(),
},
});
// Set up a webhook for monitoring
await client.webhooks.create({
url: "https://api.acme.com/webhooks/agent-events",
events: ["execution.completed", "execution.failed", "tool.error"],
agentId: agent.id,
});
console.log("Agent deployed:", agent.id);
Note
Monitor your agent's performance in the dashboard. You can view conversation logs, tool call success rates, and token usage metrics in real time.
Next Steps
- -Add streaming for real-time chat interfaces
- -Configure webhooks for event-driven workflows
- -Build a multi-agent system with specialized roles