plugins/plugin-ngrok/README.md
A powerful ngrok tunnel plugin for ElizaOS that enables agents to expose local services to the internet with a production-ready dashboard.
npm install @elizaos/plugin-ngrok
Get your ngrok auth token (optional but recommended):
Configure your environment:
# .env file
NGROK_AUTH_TOKEN=your_auth_token_here # Optional but recommended
NGROK_REGION=us # Optional: us, eu, ap, au, sa, jp, in
NGROK_SUBDOMAIN=my-app # Optional: requires paid plan
Use in your agent:
import ngrokPlugin from '@elizaos/plugin-ngrok';
const agent = new Agent({
plugins: [ngrokPlugin],
// ... other config
});
The plugin includes a beautiful, production-ready web dashboard for managing your tunnels.
# Start both API server and dashboard
npm run demo:full
# Or run them separately:
npm run demo:api # Start API server on port 3001
npm run dev # Start dashboard on port 5173
Visit http://localhost:5173 to access the dashboard.
This package does not expose ngrok-specific actions. It registers
NgrokService under serviceType = "tunnel" when its credentials are present.
User-facing tunnel operations go through the canonical TUNNEL action with
action=start | stop | status.
This plugin includes comprehensive test coverage across multiple test types:
# Run all plugin tests (unit + E2E)
npm test
# Run with coverage report
npm run test:coverage
# Run unit tests only
npm run test:unit
# Run in watch mode
npm run test:watch
# Run integration tests (requires ngrok installed)
npm run test:integration
# Run E2E tests (uses real ngrok API)
npm run test:e2e
# Run Cypress tests headlessly
npm run test:cypress
# Open Cypress interactive mode
npm run cypress:open
The plugin includes an Express API server for the dashboard:
Returns the current tunnel status.
Response:
{
"active": true,
"url": "https://abc123.ngrok.io",
"port": 3000,
"startedAt": "2024-01-01T00:00:00.000Z",
"provider": "ngrok",
"uptime": "15 minutes"
}
Starts a new tunnel.
Request Body:
{
"port": 3000,
"region": "eu", // optional
"subdomain": "my-app" // optional, requires paid plan
}
Stops the active tunnel.
interface TunnelStatus {
active: boolean;
url: string | null;
port: number | null;
startedAt: Date | null;
provider: string;
}
interface TunnelConfig {
provider?: 'ngrok' | 'cloudflare' | 'localtunnel';
authToken?: string;
region?: string;
subdomain?: string;
}
interface ITunnelService {
start(port: number): Promise<string>;
stop(): Promise<void>;
getUrl(): string | null;
isActive(): boolean;
getStatus(): TunnelStatus;
}
plugin-ngrok/
โโโ src/
โ โโโ actions/ # Agent actions
โ โโโ services/ # NgrokService implementation
โ โโโ types/ # TypeScript types
โ โโโ frontend/ # React dashboard
โ โโโ __tests__/ # Test suites
โโโ demo/ # Demo applications
โโโ cypress/ # Cypress E2E tests
โโโ dist/ # Build output
# Build plugin and dashboard
npm run build
# Build plugin only
tsup src/index.ts --format esm --dts
# Build dashboard only
vite build
# Watch plugin changes
npm run dev:plugin
# Run dashboard dev server
npm run dev
# Run everything in dev mode
npm run demo:full
| Variable | Description | Default | Required |
|---|---|---|---|
NGROK_AUTH_TOKEN | Your ngrok authentication token | - | No (but recommended) |
NGROK_REGION | Tunnel region (us, eu, ap, au, sa, jp, in) | us | No |
NGROK_SUBDOMAIN | Custom subdomain (requires paid plan) | - | No |
NGROK_DEFAULT_PORT | Default port for tunnels | 3000 | No |
API_PORT | Port for the API server | 3001 | No |
If you see "ngrok is not installed", install it using:
# macOS
brew install ngrok
# Linux
snap install ngrok
# Windows
choco install ngrok
Without an auth token, tunnels will have limited functionality. Get a free token at ngrok.com.
Make sure the port you're trying to tunnel is actually running a service and is not blocked by a firewall.
Contributions are welcome! Please ensure all tests pass and add tests for new features:
git checkout -b feature/amazing-feature)npm test)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This plugin is part of the ElizaOS project. See the main project for license information.
For issues and feature requests, please use the GitHub issue tracker.
For questions and discussions, join the ElizaOS community on Discord.