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:

typescript

External services automatically register their routes when added to an agent using the Hono framework:

typescript

Examples

Discord Webhook Service

Capture Discord messages and process them with your AI agent:

typescript

Stripe Payment Service

Handle Stripe webhooks and payment processing:

typescript

Admin Agent Service

Create a VS Code-like admin interface for configuration management:

typescript

Agent Integration

Integrate external services with your AI agents:

typescript

Secret Variables

Configure your external services with secrets:

typescript

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

typescript

Error Handling

typescript

Advanced Configuration

Middleware Integration

Use Hono middleware for authentication and request processing:

typescript

OpenAPI Integration

Generate service clients from OpenAPI specifications:

typescript

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

Official Documentation

Contact Us

Tell us a little about your project and how to reach you.