Creating an Agent Glyph
This guide walks you through creating an Agent glyph for workflow automation.
What is an Agent Glyph?
An Agent glyph orchestrates multi-step workflows by communicating with external services via webhooks.
Prerequisites
- Glyphrun account
- Webhook endpoint (n8n, Make.com, custom server)
- Understanding of HTTP APIs
Step 1: Set Up Your Webhook
Using n8n
- Create a new workflow in n8n
- Add a Webhook trigger node
- Configure to receive POST requests
- Copy the webhook URL
Webhook Payload
Your endpoint will receive:
{
"run_id": "run_abc123",
"glyph_id": "glyph_xyz",
"glyph_slug": "my-agent",
"glyph_name": "My Agent",
"inputs": {
"field1": "value1",
"field2": "value2"
},
"user_id": "did:privy:xxx",
"timestamp": 1702000000000
}Response Format
Return results as JSON:
{
"status": "success",
"output": "Your result here",
"metadata": {
"steps_completed": 3,
"duration_ms": 5000
}
}Step 2: Define Your Glyph
Basic Information
- Name - Clear, action-oriented title
- Slug - URL-friendly identifier
- Description - What the agent does
- Category - LAUNCH, SECURE, or OPTIMIZE
Step 3: Configure Agent Settings
const agentConfig = {
webhookUrl: 'https://your-n8n.com/webhook/xxx',
webhookMethod: 'POST',
webhookHeaders: {
'X-Custom-Header': 'value'
},
timeoutSeconds: 60,
maxRetries: 3,
retryDelayMs: 1000,
// For async/long-running tasks
pollUrl: 'https://your-n8n.com/poll/xxx',
pollIntervalMs: 2000
}Configuration Options
| Option | Description | Default |
|---|---|---|
webhookUrl | Endpoint to call | Required |
webhookMethod | HTTP method | POST |
webhookHeaders | Custom headers | |
timeoutSeconds | Max execution time | 60 |
maxRetries | Retry attempts | 3 |
pollUrl | Async polling endpoint | null |
pollIntervalMs | Polling interval | 2000 |
Step 4: Design Input Schema
Define inputs users will provide:
const inputSchema = [
{
name: 'targetWallet',
label: 'Wallet Address',
type: 'text',
required: true,
placeholder: '0x...'
},
{
name: 'action',
label: 'Action',
type: 'select',
required: true,
options: ['monitor', 'analyze', 'report']
},
{
name: 'duration',
label: 'Duration (hours)',
type: 'number',
required: false,
default: 24
}
]Step 5: Handle Async Workflows
For long-running tasks, use polling:
Initial Response
{
"status": "pending",
"job_id": "job_123",
"message": "Processing started"
}Poll Endpoint
The poll endpoint is called until completion:
{
"status": "completed",
"output": "Final results here",
"metadata": {...}
}Status Values
pending- Still processingcompleted- Success, results readyfailed- Error occurred
Step 6: Set Pricing
Agents use custom pricing:
const pricing = {
model: 'per-run',
amount: 0.10, // $0.10 per run
currency: 'USDC'
}Consider:
- Your infrastructure costs
- External API costs
- Execution time
- Value delivered
Step 7: Testing
Before publishing:
- Test the webhook - Ensure it handles all inputs
- Test timeouts - Verify behavior on slow responses
- Test errors - Handle failures gracefully
- Test polling - For async workflows
Example: Wallet Monitor Agent
// Glyph Configuration
{
name: 'Wallet Activity Monitor',
slug: 'wallet-monitor',
type: 'agent',
category: 'optimize',
agentConfig: {
webhookUrl: 'https://n8n.example.com/webhook/wallet-monitor',
webhookMethod: 'POST',
timeoutSeconds: 120,
pollUrl: 'https://n8n.example.com/poll/wallet-monitor',
pollIntervalMs: 5000
},
inputSchema: [
{
name: 'walletAddress',
label: 'Wallet to Monitor',
type: 'text',
required: true
},
{
name: 'alertThreshold',
label: 'Alert Threshold (USD)',
type: 'number',
default: 1000
}
],
pricing: {
model: 'per-run',
amount: 0.15,
currency: 'USDC'
}
}Best Practices
Webhook Design
- Use authentication headers
- Validate incoming payloads
- Return meaningful errors
- Log all requests
Error Handling
- Return clear error messages
- Include error codes
- Provide recovery suggestions
Performance
- Optimize for speed
- Use async for long tasks
- Set appropriate timeouts
Next Steps
Last updated on: