Skip to main content
Layercode needs to send a webhook to your backend to generate agent responses. If you’re running your backend locally, you’ll need to expose it to the internet using a tunnel service.

Setting up a tunnel with cloudflared

We recommend using cloudflared, which is free for development.
1

Install cloudflared

  • macOS: brew install cloudflared
  • Windows: winget install --id Cloudflare.cloudflared
  • Other platforms
2

Start the tunnel

Run the following command to expose your local server:
cloudflared tunnel --url http://localhost:YOUR_PORT
3

Copy your tunnel URL

After starting, cloudflared will print a public URL in your terminal, e.g.:
https://my-tunnel-name.trycloudflare.com
Add the path of your backend’s webhook endpoint to the URL, e.g.:
https://my-tunnel-name.trycloudflare.com/api/agent
/api/agent is just an example. Your actual endpoint may be different depending on your backend configuration.
4

Update your Layercode agent

  1. Go to the Layercode dashboard.
  2. Click on your agent.
  3. Click the Edit button in the ‘Your Backend’ box.
  4. Enter your Webhook URL (from the previous step) and ensure your LAYERCODE_WEBHOOK_SECRET matches your environment variable.
5

Test your agent

Open the agent Playground tab and start speaking to your voice agent!
6

Troubleshooting

If you’re having trouble, make sure your backend server is running and listening on the specified port (e.g., 3000). You can also visit the Webhook Logs tab in the agent to see the webhook requests being sent and any errors returned.
Every time you restart the cloudflared tunnel, the assigned public URL will change. Be sure to update the webhook URL in the Layercode dashboard each time you restart the tunnel.

Alternative Tunneling Solutions

Besides cloudflared, you can also use other tunneling solutions like ngrok to expose your local backend.

If using Vite:

By default, Vite blocks requests from other hosts, so you will need to add your Cloudflared (or ngrok, etc.) address to vite.config.ts in server.allowedHosts. For example:
allowedHosts: ["suggesting-sri-pair-hugh.trycloudflare.com"]
I