A production-ready chat proxy server that securely forwards requests to Travrse AI. Built with Hono and optimized for Vercel, but also works on other Node.js platforms like Railway, Fly.io, and traditional servers.
This example uses shared flow configurations and utilities from the vanilla-agent-proxy package, making it easy to maintain and extend.
- Secure API key handling - Never exposes your Travrse API key to the browser
- Multiple flow configurations:
- Basic conversational assistant
- Directive-enabled flow (via flow ID)
- Shopping assistant with JSON actions
- Stripe checkout integration - Uses Stripe REST API (no SDK required)
- CORS support - Configurable allowed origins
- Auto port selection - Automatically finds available port for local development
- Node.js 20+ (or use the version specified in
.nvmrcif present) - pnpm (or npm/yarn)
- Install dependencies:
pnpm install- Create a
.envfile in this directory:
TRAVRSE_API_KEY=tv_test_xxx
TRAVRSE_FLOW_ID=flow_xxx # Optional, for directive-enabled flow
STRIPE_SECRET_KEY=sk_test_xxx # Optional, for checkout functionality
FRONTEND_URL=http://localhost:5173 # Optional, defaults to http://localhost:5173- Start the development server:
pnpm devThe server will start on port 43111 (or next available port) and automatically reload on file changes.
| Endpoint | Method | Description |
|---|---|---|
/api/chat/dispatch |
POST | Basic conversational assistant (default flow) |
/api/chat/dispatch-directive |
POST | Directive-enabled flow (requires TRAVRSE_FLOW_ID) |
/api/chat/dispatch-action |
POST | Shopping assistant with JSON actions (message, nav_then_click, message_and_click, checkout) |
/api/checkout |
POST | Stripe checkout session creation (requires STRIPE_SECRET_KEY) |
/form |
POST | Form submission handler for directive demo |
- Install Vercel CLI:
npm i -g vercel- Deploy:
vercel- Set environment variables in Vercel dashboard:
TRAVRSE_API_KEY(required)TRAVRSE_FLOW_ID(optional)STRIPE_SECRET_KEY(optional)FRONTEND_URL(optional)
- Push your code to GitHub/GitLab/Bitbucket
- Import the project in Vercel dashboard
- Set the root directory to
examples/vercel-edge - Configure environment variables
- Deploy
Set these in the Vercel dashboard (Settings → Environment Variables):
- TRAVRSE_API_KEY (required): Your Travrse API key
- TRAVRSE_FLOW_ID (optional): Flow ID for directive-enabled endpoint
- STRIPE_SECRET_KEY (optional): Stripe secret key for checkout functionality
- FRONTEND_URL (optional): Your frontend URL for checkout redirect URLs
This example works on any Node.js hosting platform:
- Install Railway CLI:
npm i -g @railway/cli - Run
railway init - Set environment variables:
railway variables set TRAVRSE_API_KEY=xxx - Deploy:
railway up
- Install Fly CLI:
curl -L https://fly.io/install.sh | sh - Run
fly launch - Set secrets:
fly secrets set TRAVRSE_API_KEY=xxx - Deploy:
fly deploy
- Build the project:
pnpm build-
Set environment variables on your server
-
Start the server:
node dist/server.jsOr use a process manager like PM2:
pm2 start dist/server.js --name chat-proxyThis example uses shared flow configurations and utilities from vanilla-agent-proxy:
- Flow configs:
SHOPPING_ASSISTANT_FLOWfromvanilla-agent-proxy/flows - Stripe helpers:
createCheckoutSessionfromvanilla-agent-proxy/utils
This eliminates code duplication across deployment examples and makes maintenance easier.
| Example | Best For | Deployment | Dependencies |
|---|---|---|---|
| vercel-edge (this) | Quick start, Node.js platforms | Vercel, Railway, Fly.io | Node.js runtime |
| cloudflare-workers | Edge computing, global scale | Cloudflare Workers | None (edge runtime) |
For production edge deployment with global low latency, see the cloudflare-workers example.