# Naïve — Customer Support Agent Onboarding (skill.md)

> Connect your helpdesk and knowledge base, build a live support dashboard, and let the agent triage tickets, draft grounded replies, and escalate — on its own governed inbox and number.

## Start here — read the base manifest first

This is a **use-case-specific** skill. It builds on Naïve's general agent onboarding manifest. Before doing anything below, read the base manifest and follow its operating rules (authenticate *with* the user, clarify scope, gate real-world/spending actions, respect budgets, be idempotent):

- **Base onboarding manifest:** https://usenaive.ai/skill.md

Do the base manifest's onboarding first (authenticate the user, install the CLI/SDK, verify connectivity). Then return here and layer this use-case on top.

## What you're building

A **customer support agent**: a database + a web-deployed dashboard, plus a governed `support` agent profile running on a Naïve runtime. Declare all of it as code in `naive.config.ts` and provision it with `naive up`.

## Step 1 — ask the user (discovery)

Before provisioning anything, ask the user these and confirm the answers:

- Which helpdesk do you use, and should the agent reply inside it or from its own inbox?
- Where does your source-of-truth knowledge live, and what topics are in vs. out of scope?
- What can the agent do autonomously vs. what needs human approval (refunds, credits, account changes)?
- What are your SLA targets and escalation paths (who/where to hand off)?
- What tone and brand voice should replies use?

## Step 2 — connect their existing systems

Use the `connections` primitive (autonomous OAuth) and the `vault` (per-tenant encrypted credential storage) to wire up what the user already runs on. Only connect what they confirmed in Step 1.

- Helpdesk — Zendesk, Intercom, Front, Help Scout
- Channels — a custom-domain support inbox and an SMS-capable phone number
- Knowledge — your docs/KB and macros the agent grounds answers in
- Ops — Slack/on-call for escalations and human handoff

```bash
naive connections connect <service>     # OAuth into an existing system
naive vault put <service>.api_key <key> # store any keys the user pastes
```

## Step 3 — declare the database + web app + agent (naive.config.ts)

Scaffold with `naive init`, then adapt the config below. It declares a managed Postgres database, a Vercel-hosted Next.js dashboard, object storage, a hosted runtime pool, and the governed agent-profile template — then `naive up` provisions all of it (idempotent; shows a diff).

**What goes in the config:**
- `infrastructure.web` — the web-deployed dashboard (Next.js on Vercel).
- `infrastructure.database` — managed Postgres for the app's normalized data store.
- `infrastructure.documents`/`storage` — object storage for files the agent handles.
- `runtime.pool` — a hosted microVM pool the support agent runs on (or omit for bring-your-own-runtime).
- `agentProfiles.support` — the governed profile (identity + comms + `policy` with an allow-list, a spend cap, and human approvals on real-world/money actions).

```ts
import { defineConfig, cloud, agentTemplate, policy, runtime } from "@usenaive-sdk/iac";

export default defineConfig({
  project: "customer-support-agent",

  // Path A — the support dashboard + ticket store, hosted by Naïve.
  infrastructure: {
    web: cloud.web({ framework: "nextjs", dir: "." }),           // support dashboard (Vercel)
    database: cloud.postgres({ name: "tickets", size: "serverless" }),
    attachments: cloud.bucket({ name: "support-attachments" }),
  },

  // Path B — a hosted runtime for the triage/drafting agent.
  runtime: {
    pool: runtime.pool({ name: "support", size: "small" }),
  },

  // The governed agent profile the support agent runs as.
  agentProfiles: {
    support: agentTemplate({
      identity: { kind: "business", verify: "kyb" },
      comms: { email: { domain: "per-tenant" }, phone: { sms: true } }, // support inbox + SMS
      policy: policy({
        allow: ["connections", "email", "phone", "llm", "search", "vault", "apps"],
        budget: { cap: "$75/mo", alertAt: 0.8, hard: true },
        approvals: [
          { when: "refund.issue", via: "email" },                // money-movement stays human-gated
          { when: "account.change", via: "email" },
        ],
      }),
    }),
  },
});
```

Then provision it:
```bash
naive up                                              # plan + apply everything above
naive agent-profiles provision support --user <tenant-id>   # one per tenant/customer
```

## Step 4 — primitives this agent uses

The `support` profile's `policy.allow` should grant exactly these — nothing more (least privilege):

- connections (OAuth into the helpdesk + KB)
- email + phone (custom-domain support inbox + SMS)
- llm (triage, grounded reply drafting, sentiment)
- search (KB retrieval + web lookups)
- vault (store helpdesk + tool credentials per tenant)
- apps + database + storage (dashboard, ticket store, attachments)
- cron (SLA sweeps + backlog triage)

## Step 5 — build the dashboard + data model

Use the provisioned Postgres + web app to build:

- A web-deployed support dashboard — ticket volume, SLA/first-response, CSAT, and escalation queue
- A Postgres store of tickets, conversations, and resolution outcomes across channels
- Attachment storage for screenshots, logs, and files customers send

## Step 6 — automate the ongoing work

Wire the recurring work to `cron` jobs that run the agent on the runtime pool. Keep every money-movement or irreversible action behind an approval (see the `policy.approvals` in the config).

- Triage — classify, prioritize, and route inbound tickets by intent and urgency
- Drafting — generate grounded replies from your KB with citations, ready for one-click send
- Resolution — run safe self-serve actions (order status, resets) and close resolved tickets
- Escalation — detect at-risk conversations and hand off to a human with full context

```bash
naive cron create --name "monthly-run" --schedule "0 9 1 * *" --task "<what the agent should do>"
```

## Reference

- Base onboarding manifest: https://usenaive.ai/skill.md
- Infrastructure as Code: https://usenaive.ai/docs/getting-started/iac
- Connections (OAuth): https://usenaive.ai/docs/api-reference/overview
- CLI reference: https://usenaive.ai/docs/cli/overview
- SDK reference: https://usenaive.ai/docs/sdk/overview
- All templates: https://usenaive.ai/templates
