External Services
Integrate your AI Agents with any external API or service. External Services provide a robust foundation for connecting to third-party systems like Discord, Stripe, webhooks, and custom admin interfaces. With built-in route registration using Hono framework, request handling, and OpenAPI support, you can rapidly build production-ready integrations.
Key Features
- Route Registration: Automatically register HTTP endpoints using Hono framework
- Webhook Support: Built-in webhook validation and processing for services like Discord, Stripe, GitHub
- OpenAPI Integration: Generate client SDKs and documentation from OpenAPI specifications
- Request/Response Handling: Type-safe request parsing and response formatting with Hono context
- Authentication: Built-in support for API keys, OAuth, and custom authentication schemes
- Error Handling: Graceful error management with retry logic and circuit breakers
Getting Started
External Services extend the base Service class and use the registerRoutes method with Hono framework to expose HTTP endpoints:
External services automatically register their routes when added to an agent using the Hono framework:
Examples
Discord Webhook Service
Capture Discord messages and process them with your AI agent:
Stripe Payment Service
Handle Stripe webhooks and payment processing:
Admin Agent Service
Create a VS Code-like admin interface for configuration management:
Agent Integration
Integrate external services with your AI agents:
Secret Variables
Configure your external services with secrets:
Then run npm run codegen to automatically generate the in env.d.ts for typed access to secrets
To set a secret in your remote deployment run wrangler secret put SECRET_KEY then past the value in the following prompt request.
Best Practices
Security
Error Handling
Advanced Configuration
Middleware Integration
Use Hono middleware for authentication and request processing:
OpenAPI Integration
Generate service clients from OpenAPI specifications:
Limitations
- Request Size: Maximum 100MB per webhook request
- Timeout: 30 second timeout for external API calls
- Rate Limiting: Built-in rate limiting of 1000 requests per minute per service
- Concurrency: Maximum 50 concurrent external requests per service
Related Services
- Workflows - Trigger workflows from external events
- Secret Manager - Secure API key management
- Analytics Engine - Track external service metrics