Agents
Create intelligent AI agents that can autonomously execute complex multi-step tasks.
Overview
DYPAI Agents are AI-powered automation tools that can:
- Understand natural language instructions
- Execute multi-step workflows
- Access your database, storage, and APIs
- Make decisions based on data
- Maintain context across interactions
Creating an Agent
Navigate to AI Agents
Go to the AI β Agents section in your dashboard.
Create New Agent
Click "New Agent" and configure the agent settings.
Define Instructions
Write clear instructions that define the agent's behavior.
Select Tools
Choose which tools the agent can use.
Test and Deploy
Test the agent with sample inputs, then deploy.
Agent Configuration
{
"name": "sales-analyst",
"description": "Analyzes sales data and generates reports",
"instructions": """
You are a sales data analyst. Your job is to:
1. Query the sales database for relevant data
2. Analyze trends and patterns
3. Generate clear, actionable reports
4. Answer questions about sales performance
Always provide data-driven insights and cite specific numbers.
""",
"tools": [
"database_query",
"database_schema",
"edge_function"
],
"model": "claude-sonnet-4-20250514",
"max_tokens": 4096
}Available Tools
| Tool | Description |
|---|---|
database_query | Execute SQL queries |
database_insert | Insert records |
database_update | Update records |
storage_read | Read files |
storage_write | Write files |
api_call | Call external APIs |
edge_function | Run custom functions |
send_email | Send emails |
Running Agents
Via API
// JavaScript/TypeScript
const response = await fetch('https://your-project.dypai.io/ai/v1/agents/sales-analyst/run', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + apiKey
},
body: JSON.stringify({
input: "Generate a sales report for Q4 2024",
context: {
user_id: "user-123",
timezone: "America/New_York"
}
})
});
const result = await response.json();
console.log(result.output);
console.log(result.steps); // Steps the agent tookVia Dashboard
- Go to AI β Agents
- Select your agent
- Enter a prompt in the test interface
- View the agent's response and execution steps
Agent Examples
Customer Support Agent
{
"name": "support-agent",
"instructions": """
You are a customer support assistant. Help users by:
1. Looking up their account information
2. Checking order status
3. Answering product questions
4. Escalating complex issues to human support
Be friendly, helpful, and professional.
Always verify the user's identity before sharing account details.
""",
"tools": [
"database_query",
"api_call",
"send_email"
]
}Data Processing Agent
{
"name": "data-processor",
"instructions": """
You process incoming data files and load them into the database.
1. Read the uploaded file from storage
2. Validate the data format
3. Transform data as needed
4. Insert into the appropriate table
5. Generate a summary report
""",
"tools": [
"storage_read",
"database_insert",
"database_query",
"edge_function"
]
}Content Moderator Agent
{
"name": "content-moderator",
"instructions": """
Review user-generated content for policy violations.
1. Query new content from the posts table
2. Analyze each post for violations
3. Flag or remove violating content
4. Update the moderation status
5. Log all decisions for review
""",
"tools": [
"database_query",
"database_update"
]
}Creating Custom Tools
Define custom tools using Edge Functions:
// Edge Function: calculate-shipping
async def handler(request):
body = await request.json()
weight = body.get('weight')
destination = body.get('destination')
# Calculate shipping cost
base_rate = 5.99
per_kg = 2.50
cost = base_rate + (weight * per_kg)
return {
"shipping_cost": cost,
"estimated_days": 3,
"carrier": "Standard Shipping"
}
# Register as tool
tool_config = {
"name": "calculate_shipping",
"description": "Calculate shipping cost for an order",
"parameters": {
"weight": {"type": "number", "description": "Weight in kg"},
"destination": {"type": "string", "description": "Destination country"}
},
"function": "calculate-shipping"
}Execution History
View all agent executions in the dashboard:
- Input prompts and outputs
- Steps taken during execution
- Tools used and their results
- Execution time and tokens used
- Errors and debugging information
// Query execution history via API
const response = await fetch('https://your-project.dypai.io/ai/v1/agents/sales-analyst/history', {
headers: {
'Authorization': 'Bearer ' + apiKey
}
});
const history = await response.json();
history.executions.forEach(exec => {
console.log(exec.id, exec.status, exec.created_at);
});Best Practices
- Write clear, specific instructions
- Only grant tools the agent needs
- Test thoroughly before production
- Monitor execution history for issues
- Set appropriate token limits
- Use context to provide relevant information
Start with simple tasks and gradually add complexity as you understand the agent's behavior.