AgentStack Docs

Serve the Help Page from a path on your site

Forward three routes from your own site to AgentStack so the Help Page answers at your own address, without a custom domain.

There are two ways to put the Help Page on your own address.

  • A custom domain. The page answers at a subdomain you own, for example support.example.com. AgentStack manages the SSL certificate. This needs the Custom Domain add-on. See Add a custom domain.
  • A reverse proxy. Your own site forwards a few routes to AgentStack. The page answers at a path you choose, for example example.com/help. This needs no add-on. You set it up in your own stack.

This page covers the second way. Give it to your engineer, or point a coding agent at it. Read Point a coding agent at this page at the end.

The routes to forward

Forward these three routes. Replace AGENT_ID with the agent's public ID from Channels → Help Page.

Your routeForwards toCarries
/helphttps://www.agentstack.build/help/AGENT_IDThe page itself
/api/chathttps://www.agentstack.build/api/chatEach chat message. This is a POST.
/api/chat/*https://www.agentstack.build/api/chat/*The session and agent-config calls the page makes

Send every request to www.agentstack.build. The apex address redirects, and the redirect drops headers.

Rules for every platform

  1. Forward POST, not only GET. Every chat message is a POST. A read-only proxy loads the page and then answers nothing.
  2. Send Host as www.agentstack.build. Pass your own host through and AgentStack cannot tell which page you want.
  3. Turn response buffering off on /api/chat. Answers stream word by word. A buffering proxy holds the whole answer, so the page looks frozen.
  4. Leave /.well-known/* alone. Certificate checks run there. Forward it and your own SSL renewal fails.

If your own site runs Next.js

Do not use a reverse proxy. Use a custom domain instead.

The Help Page loads its own JavaScript and CSS from /_next/*. Your Next.js site serves its own files from the same path. Forward that path and you break your site. Leave it alone and the Help Page loads with no styles and no chat.

Every other platform below is safe, including a Vercel site that is not Next.js.

Vercel

Put this in vercel.json. Vercel reads the file at build time, so redeploy after you save it.

{
  "rewrites": [
    { "source": "/help", "destination": "https://www.agentstack.build/help/AGENT_ID" },
    { "source": "/api/chat", "destination": "https://www.agentstack.build/api/chat" },
    { "source": "/api/chat/:path*", "destination": "https://www.agentstack.build/api/chat/:path*" }
  ]
}

Netlify

Put this in public/_redirects. The 200 at the end of each line makes it a proxy. Leave the 200 off and Netlify sends a redirect, so visitors land on agentstack.build.

/help         https://www.agentstack.build/help/AGENT_ID   200
/api/chat     https://www.agentstack.build/api/chat        200
/api/chat/*   https://www.agentstack.build/api/chat/:splat 200

Express

Mount this above express.json(). A body parser above the proxy reads the body first, so the forwarded POST arrives empty.

import { createProxyMiddleware } from "http-proxy-middleware";
 
app.use(
  ["/help", "/api/chat"],
  createProxyMiddleware({
    target: "https://www.agentstack.build",
    changeOrigin: true,
    selfHandleResponse: false,
    pathRewrite: { "^/help$": "/help/AGENT_ID" },
  }),
);

Cloudflare Workers

Add routes for example.com/help and example.com/api/chat*. Everything else passes through untouched.

const HOST = "www.agentstack.build";
 
export default {
  async fetch(request) {
    const url = new URL(request.url);
    const mine = url.pathname === "/help" || url.pathname.startsWith("/api/chat");
    if (!mine) return fetch(request);
 
    const target = new URL(request.url);
    target.hostname = HOST;
    if (url.pathname === "/help") target.pathname = "/help/AGENT_ID";
 
    const proxied = new Request(target, request);
    proxied.headers.set("Host", HOST);
    proxied.headers.set("X-Forwarded-Host", url.hostname);
    return fetch(proxied);
  },
};

CloudFront

Add one origin, www.agentstack.build, and two behaviors. CloudFront allows only GET and HEAD by default, which blocks every chat message.

Behavior  /help        Cache: Disabled  Methods: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
Behavior  /api/chat*   Cache: Disabled  Methods: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE

Origin request policy on both behaviors: AllViewerExceptHostHeader

nginx

Keep proxy_buffering off on the chat route. Run nginx -t and reload after you save.

location = /help {
  proxy_pass       https://www.agentstack.build/help/AGENT_ID;
  proxy_set_header Host www.agentstack.build;
  proxy_ssl_server_name on;
}
 
location /api/chat {
  proxy_pass       https://www.agentstack.build/api/chat;
  proxy_set_header Host www.agentstack.build;
  proxy_buffering  off;
  proxy_read_timeout 300s;
  proxy_ssl_server_name on;
}

Caddy

flush_interval -1 keeps the answer streaming. Run caddy reload after you save.

example.com {
  handle /help {
    rewrite * /help/AGENT_ID
    reverse_proxy https://www.agentstack.build {
      header_up Host www.agentstack.build
    }
  }

  handle /api/chat* {
    reverse_proxy https://www.agentstack.build {
      header_up Host www.agentstack.build
      flush_interval -1
    }
  }
}

Apache

Load mod_proxy and mod_proxy_http first. flushpackets=on sends each part of the answer straight through. Run apachectl configtest and restart after you save.

SSLProxyEngine On
ProxyPreserveHost Off
 
ProxyPass        /help  https://www.agentstack.build/help/AGENT_ID
ProxyPassReverse /help  https://www.agentstack.build/help/AGENT_ID
 
ProxyPass        /api/chat  https://www.agentstack.build/api/chat  flushpackets=on
ProxyPassReverse /api/chat  https://www.agentstack.build/api/chat

Check your work

  1. Open example.com/help. The page loads with your agent's name and colors.
  2. Send a message. The answer appears word by word, not all at once.
  3. Open the browser network panel. The POST to /api/chat returns 200.
  4. Open the page in a private window. It works with no dashboard session.

If the page loads but no answer arrives, check rule 1 and rule 3 above. If the answer arrives in one block after a long pause, buffering is still on.

Point a coding agent at this page

Give your coding agent this prompt. Replace the agent ID and the platform.

Read https://www.agentstack.build/docs/channels/help-page-proxy and set up
the reverse proxy for my site. My platform is Netlify. The AgentStack agent
public ID is AGENT_ID. Follow the four rules for every platform.

An index of every AgentStack docs page is at https://www.agentstack.build/docs/llms.txt. Give that address to an agent that needs to find other pages on its own.

On this page