> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # handleRequest > Dispatch one inbound request from plain HTTP primitives, without a Hono app. [as-router]: /docs/server-sdks/reference/typescript/agents/agent-base/as-router [render-swml]: /docs/server-sdks/reference/typescript/agents/agent-base/render-swml Dispatch one inbound request from plain HTTP primitives and get back a `[status, headers, body]` triple to write to the response. Use it to serve the agent from a framework the SDK has no adapter for. It performs Basic Auth, runs any routing callback, applies `onSwmlRequest` modifications, and renders SWML with [`renderSwml()`][render-swml]. For Hono-based hosts, mount [`asRouter()`][as-router] instead. ## **Parameters** **`method`** `string` — required HTTP method, such as `"GET"` or `"POST"`. --- **`url`** `string` — required The full request URL. --- **`headers`** `Record` — required Request headers as a plain object. --- **`body`** `Record | null` The already-parsed JSON body for POST requests. Omit for GET. --- ## **Returns** `Promise<[number, Record, string]>` -- The status code, response headers, and body string. A failed Basic Auth check returns `401` with a `WWW-Authenticate` header; a routing callback that redirects returns `307` with a `Location` header. ## **Example** ```typescript {8-13} import { createServer } from 'node:http'; import { AgentBase } from '@signalwire/sdk'; const agent = new AgentBase({ name: 'dispatch', route: '/' }); agent.setPromptText('You are a taxi dispatcher.'); createServer(async (req, res) => { const chunks: Buffer[] = []; for await (const chunk of req) chunks.push(chunk as Buffer); const raw = Buffer.concat(chunks).toString(); const body = raw ? JSON.parse(raw) : null; const url = `https://${req.headers.host}${req.url}`; const [status, headers, text] = await agent.handleRequest( req.method ?? 'GET', url, req.headers as Record, body, ); res.writeHead(status, headers); res.end(text); }).listen(3000); ``` > Dispatch one inbound request from plain HTTP primitives, without a Hono app.