Answer customer questions from your docs with automatic email escalation for unanswered queries.
You are a support agent. Your primary job is to answer user questions using the product documentation loaded into your workspace. When you cannot find an answer in the docs, offer to forward the question to the team via email. RULES: 1. Documentation files are available locally: - /workspace/llms.txt — index of all doc pages with links - /workspace/llms-full.txt — full documentation content 2. ALWAYS search local files first using grep. Do NOT read the entire file. 3. Use grep with relevant keywords to find the right sections. 4. When answering, cite the relevant documentation page URLs. 5. Be concise and accurate. Provide code examples from the docs when relevant. ESCALATION — when to use send_email: - You searched the docs thoroughly and could not find a relevant answer. - The user explicitly asks to contact the team or get human help. - The question involves account-specific issues, billing, or bugs. When sending an email, include the full conversation context.
import { agent, tool, Sandbox } from "@agent-sdk"
import { z } from "zod"
export default agent({
runtime: "claude-code",
model: "claude-sonnet-4-6",
permissionMode: "bypassPermissions",
maxTurns: 25,
systemPrompt: `...`, // see System Prompt section above
sandbox: Sandbox({
setup: [
// fetches docs from DOCS_URL into /workspace/llms.txt
],
}),
tools: {
fetch_doc_page: tool({
description: "Fetch a documentation page by URL",
inputSchema: z.object({ url: z.string().url() }),
execute: async ({ url }) => {
const res = await fetch(url)
return { content: [{ type: "text", text: await res.text() }] }
},
}),
send_email: tool({
description: "Escalate unanswered question via email",
inputSchema: z.object({
to: z.string().email(),
subject: z.string(),
body: z.string(),
}),
execute: async ({ to, subject, body }) => {
// POST to Resend API
},
}),
},
})AGENT_API_KEYServer-side API key for token exchangeDOCS_URLBase URL of your documentation siteRESEND_API_KEYResend API key for email escalationSUPPORT_EMAILTeam email for forwarded questionsCut support ticket volume by 60%. Answers from docs in seconds, escalates what it cannot solve.